Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Qt utilities to enable hot-reloading of python/Qt code
Have you been using Jupyter Notebook's magic functions such as
%load_ext autoreload
%autoreload 2
where you might have been editing code in VSCode or Pycharm and executing actions in Jupyter Notebook?
Or have you previously used LiClipse which has Debugger Auto-Reload?
Well, qtreload
provides similar capabilities by 'hot-reloading' python modules when there are changes to
the source code. It operates by generating a list of all possible modules/submodules for a specific project and
then using QFileWatcher
to observe any changes to these files.
This library should be used when developing Qt code in Python and you are not interested in continually having to restart your application. (See limitations to find out when its still required).
You can instantiate the QtReloadWidget
manually or using the install_hot_reload
function.
Note! Make sure to instantiate QApplication before running this code.
Using QtReloadWidget
:
from qtreload.qt_reload import QtReloadWidget
# you can specify list of modules that should be monitored
list_of_widgets = ["napari", "spyder", "..."]
widget = QtReloadWidget(list_of_modules)
That's pretty much it. Now every time you make changes to your source code in e.g. napari
will be reflected in your interpreter.
Using install_hot_reload
requires two environment variabels being set, namely:
QTRELOAD_HOT_RELOAD=1
QTRELOAD_HOT_RELOAD_MODULES="napari, spyder"
Then you can just execute the following:
from qtreload.install import install_hot_reload
install_hot_reload()
There are countless examples where this approach really well. Some examples:
on_run
but when you execute this function, you notice that you misspelled some variable. In normal circumstances you would need to restart the application. Now, however, you can correct it in your IDE, save, and try running again.While this approach can be extremely useful and can save a lot of time, it has a couple of limitations:
___init__.py
cannot be reloadedQMainWindow
and just added a new button, this button will now be shown. In order to show it, you will still need to restart the application. If, however, you were modyfing a plugin or a dialog that is shown upon clicking on e.g. menu item, these changes WILL take place.The hot-reload code is directly copied from the PyDev debugger developed by fabioz with minimal changes to remove any dependencies
See https://github.com/fabioz/PyDev.Debugger/blob/main/_pydevd_bundle/pydevd_reload.py
FAQs
Qt utilities to enable hot-reloading of python/Qt code
We found that qtreload demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.