Skip to content

Live and instant reload of Jinja templates and Python source code without restarting OctoPrint.

License

Notifications You must be signed in to change notification settings

clonesht/OctoPrint-DevHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dev Helper

Live and instant reload of Jinja templates and Python source code without restarting OctoPrint.

screenshot

Motivation

During plugin development, I found it slow and frustrating to restarting OctoPrint after every modification.

Setup

Install via the bundled Plugin Manager or manually using this URL:

https://github.com/clonesht/OctoPrint-DevHelper/archive/main.zip

Usage

Reload jinja template

  • Modify the template files
  • Enter a part of the local fs path of the template file you want to reload to the Part of template file path field. (eg. dev_helper_sidebar if you want to reload the ~/.octoprint/plugins/dev_helper/templates/dev_helper_sidebar.jinja2 file.)
  • Hit the Clear cache button.
  • It should display Done: Cleared template cache: 1 at the bottom of the sidebar widget.
  • When reloading the page you should see the effect of the modifications immediately.

Reload python source code

  • Modify .py files
  • Enter the module (package) name of the plugin you want to reload. (eg. dev_helper)
  • Enter the class name from the module you want to update in the memory. (eg. DevHelperPlugin)
  • Hit the Reload class button.
  • It should display Done: Reloaded object: 1 at the bottom of the sidebar widget.
  • It will reload the module, then update the class instances function source code with the updated one.
  • Note: It won't __init__ the class instances again, so it's not 100% solution, but should be fine in most cases.

Remote eval console (disabled by default)

  • Create a ~/.octoprint/data/dev_helper/enable_eval file to enable this feature
  • Run command from JS console using res = await OctoPrint.simpleApiCommand("dev_helper", "eval", {"cmd": "dir(self)"})

About

Live and instant reload of Jinja templates and Python source code without restarting OctoPrint.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published