Closed simonkuehling closed 2 years ago
Hey @simonkuehling the plugin does work, although I've only tried it directly with one model of printer.
If plugins are enabled, and the brother plugin is installed, you should see something like this in the settings screen:
Have you got any other plugins working?
Oh, thanks for the immediate reply! well, now I'm curious - i have no other plugins installed so far. In the admin panel I do see the plugin listed:
But in the settings page there is no entry for it in the left navigation menu:
Besides running invoke plugins
(for installing) and invoke update
(just in case), do I need to do anything else in order for it to show up?
After you enable the plugin (via the admin interface) you'll also need to reboot the server and worker programs (or containers if your running in docker)
hm, I did restart all docker containers after enabling - also cleared the browser cache for good measure - but it still does not show up. It's a docker installation at latest
release running in production mode...
What would the best entry point be to dig deeper and see what is going on?
I suspect I am just missing something - although I went through the docs over and over again.
Please start by showing what is on the "Plugins" tab on the settings screen:
Sure - this is my view of that screen:
Hmm does not look like the plugin is installed.
Can you run the following command (from within the context of your docker container)
Well, it does indeed look like it is not installed (is this the correct way to access a shell inside a docker container? I'm new to debugging in docker):
pi@inventree:~/inventree $ docker exec -it inventree-server /bin/bash
bash-5.1$ pip show inventree-brother-plugin
WARNING: Package(s) not found: inventree-brother-plugin
during invoke plugins
it looks like it was actually installed, though:
[...]
Installing plugin packages from '/home/inventree/data/plugins.txt'
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/inventree/inventree-brother-plugin (from -r /home/inventree/data/plugins.txt (line 2))
Cloning https://github.com/inventree/inventree-brother-plugin to /tmp/pip-req-build-0iduvmsf
Running command git clone --filter=blob:none --quiet https://github.com/inventree/inventree-brother-plugin /tmp/pip-req-build-0iduvmsf
Resolved https://github.com/inventree/inventree-brother-plugin to commit 8da445a56b2ee73de099c319b2ab6e0fe3cb3012
Preparing metadata (setup.py): started
Preparing metadata (setup.py): still running...
Preparing metadata (setup.py): finished with status 'done'
Collecting brother_ql@ git+https://github.com/pklaus/brother_ql/@56cf4394ad750346c6b664821ccd7489ec140dae
Cloning https://github.com/pklaus/brother_ql/ (to revision 56cf4394ad750346c6b664821ccd7489ec140dae) to /tmp/pip-install-3f527eqx/brother-ql_24cbe86fa7774039acbec22a65643801
Running command git clone --filter=blob:none --quiet https://github.com/pklaus/brother_ql/ /tmp/pip-install-3f527eqx/brother-ql_24cbe86fa7774039acbec22a65643801
Running command git rev-parse -q --verify 'sha^56cf4394ad750346c6b664821ccd7489ec140dae'
Running command git fetch -q https://github.com/pklaus/brother_ql/ 56cf4394ad750346c6b664821ccd7489ec140dae
Resolved https://github.com/pklaus/brother_ql/ to commit 56cf4394ad750346c6b664821ccd7489ec140dae
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: click in /usr/lib/python3.8/site-packages (from brother_ql@ git+https://github.com/pklaus/brother_ql/@56cf4394ad750346c6b664821ccd7489ec140dae->inventree-brother-plugin==0.2->-r /home/inventree/data/plugins.txt (line 2)) (8.1.2)
Collecting future
Downloading future-0.18.2.tar.gz (829 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 829.2/829.2 KB 2.8 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Collecting packbits
Downloading packbits-0.6.tar.gz (2.2 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: pillow>=3.3.0 in ./.local/lib/python3.8/site-packages (from brother_ql@ git+https://github.com/pklaus/brother_ql/@56cf4394ad750346c6b664821ccd7489ec140dae->inventree-brother-plugin==0.2->-r /home/inventree/data/plugins.txt (line 2)) (9.0.1)
Collecting pyusb
Downloading pyusb-1.2.1-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.4/58.4 KB 2.0 MB/s eta 0:00:00
Collecting attrs
Downloading attrs-21.4.0-py2.py3-none-any.whl (60 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.6/60.6 KB 2.1 MB/s eta 0:00:00
Building wheels for collected packages: inventree-brother-plugin, brother_ql, future, packbits
Building wheel for inventree-brother-plugin (setup.py): started
Building wheel for inventree-brother-plugin (setup.py): finished with status 'done'
Created wheel for inventree-brother-plugin: filename=inventree_brother_plugin-0.2-py3-none-any.whl size=4700 sha256=da7a7c6c71eef143b1aee0cc300b99d84370797d688e1adaf07f9300747b3c4a
Stored in directory: /tmp/pip-ephem-wheel-cache-477gpxls/wheels/47/f0/59/a4b774041938ddce17da35368f20a92f0eb8d03100b90d5177
Building wheel for brother_ql (setup.py): started
Building wheel for brother_ql (setup.py): finished with status 'done'
Created wheel for brother_ql: filename=brother_ql-0.9.dev0-py3-none-any.whl size=47782 sha256=08bd6ecbd9323b2a1b2116b00e4667dee199bce1484927b4a26085876a8debdd
Stored in directory: /home/inventree/.cache/pip/wheels/a6/d7/d2/c59840f61da93814b20787c824d849bbc214ebf8bece319fb7
Building wheel for future (setup.py): started
Building wheel for future (setup.py): finished with status 'done'
Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491070 sha256=2663a42d82e07984d10669578ec57c7083b59e0fbe8ed9ba476984a4e0fd8df6
Stored in directory: /home/inventree/.cache/pip/wheels/8e/70/28/3d6ccd6e315f65f245da085482a2e1c7d14b90b30f239e2cf4
Building wheel for packbits (setup.py): started
Building wheel for packbits (setup.py): finished with status 'done'
Created wheel for packbits: filename=packbits-0.6-py3-none-any.whl size=2683 sha256=5f11e3af92e32a1fb29ec68b22ce6fc7f390782bf4e20cb3d6778c551de10ca3
Stored in directory: /home/inventree/.cache/pip/wheels/88/4a/a2/f102b45c6ef1607ebda7aac166d590a2c9115267ae8b274904
Successfully built inventree-brother-plugin brother_ql future packbits
Installing collected packages: packbits, pyusb, future, attrs, brother_ql, inventree-brother-plugin
Successfully installed attrs-21.4.0 brother_ql-0.9.dev0 future-0.18.2 inventree-brother-plugin-0.2 packbits-0.6 pyusb-1.2.1
[...]
How strange...
Can you try manually installing from the shell:
pip install git+https://github.com/inventree/inventree-brother-plugin
and then restarting the server and checking again?
I just remembered a probably important note - when first trying to install the plugin, I got a warning about the install location of the packages not being in the PATH:
[...]
Successfully built inventree-brother-plugin brother_ql future packbits
Installing collected packages: packbits, pyusb, future, attrs, brother_ql, inventree-brother-plugin
WARNING: The scripts futurize and pasteurize are installed in '/home/inventree/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts brother_ql, brother_ql_analyse, brother_ql_create, brother_ql_debug, brother_ql_info and brother_ql_print are installed in '/home/inventree/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed attrs-21.4.0 brother_ql-0.9.dev0 future-0.18.2 inventree-brother-plugin-0.2 packbits-0.6 pyusb-1.2.1
[...]
To resolve that I tried adding the path in prod-config.env:
[...]
PATH="/home/inventree/.local/bin:${PATH}"
[...]
...and ran invoke plugins
again. This time without that error. But that was clearly not the right fix...
How strange...
Can you try manually installing from the shell:
pip install git+https://github.com/inventree/inventree-brother-plugin
and then restarting the server and checking again?
that did the trick! Seems to work now.
Looks like it was installed somewhere differently by invoke plugins
- maybe a specific path is indeed missing somewhere?
That's intriguing!
There are some subtleties here which may be caused by the differences between a "production" docker image (which you seem to be running) and a "development" docker image (which I mostly run, as I am always tinkering...)
In the production image, the required python packages are "baked in" when the image is built:
In a production image, calling invoke install
shouldn't do anything, as the required packages are already installed and are "pinned".
The development image however sets up a virtual environment (within the mounted "data" directory) and installs required packages at "runtime" when the invoke update
command is performed.
So, the main differences here is that in the development image, when I run invoke plugins
it is running within the context of a virtual environment at /home/inventree/dev/env/
. But this does not appear to be the case for you...
A couple of things to try, not sure where it will lead...
Can you run these commands from within the docker container shell, and see how they compare to mine?
It could also be related to the permissions of the 'inventree' user/group within the docker image?
@matmair do you want to weigh in on this one?
I am running a production docker image here, correct.
Here's the python and invoke versions from inside:
pi@inventree:~/inventree $ docker exec -it inventree-server /bin/bash
bash-5.1$ which python
bash-5.1$ python --version
bash: python: command not found
bash-5.1$ which python3
/usr/bin/python3
bash-5.1$ python3 --version
Python 3.8.10
bash-5.1$ which invoke
/usr/bin/invoke
bash-5.1$ invoke --version
Invoke 1.7.0
that did the trick! Seems to work now.
I spoke too soon. Manually installing made the plugin appear for the moment, but it was not persistent - after a docker reboot the package is not installed anymore...
Your suspicion about permissions sounds promising - this is what I have found inside the docker image, looks like a typo in the username/group to me: [EDIT below]
bash-5.1$ whoami
inventree
bash-5.1$ ls -ahl
total 112K
drwxr-sr-x 1 inventre inventre 4.0K Apr 6 22:32 .
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 ..
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 InvenTree
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 barcodes
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 build
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 common
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 company
-rw-r--r-- 1 inventre inventre 5.9K Apr 6 22:32 config_template.yaml
-rw-r--r-- 1 inventre inventre 139 Apr 6 22:32 gunicorn.conf.py
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 label
drwxr-sr-x 1 inventre inventre 4.0K Apr 6 22:32 locale
-rwxr-xr-x 1 inventre inventre 841 Apr 6 22:32 manage.py
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 order
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 part
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 plugin
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 plugins
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 report
drwxr-sr-x 1 inventre inventre 4.0K Apr 6 22:32 script
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 stock
drwxr-sr-x 1 inventre inventre 4.0K Apr 6 22:32 templates
drwxr-sr-x 1 inventre inventre 4.0K Apr 12 13:18 users
EDIT: well, facepalm... In all the years I never stumbled over the fact that ls
is truncating user/group names to 8 characters... so, those permissions are just fine...
@schroedingergat I would like to weigh in indeed. Thanks for the ping.
@simonkuehling thank you for opening this issue. Am I reading your name correctly into the DACH region?
Regarding the issue: changes in the production environment are not permanent, that is by design to keep it repeatable and safe. If a user wants to use plugin in production there is a setting that enables re-installment on restart in containers. The needs to be enabled.
@matmair of course! I had forgotten that little detail when in production. This should be addressed in the documentation if it is not already
@simonkuehling please try the suggested solution and let us know if it stops breaking. Could very well be that we broke something. @SchrodingersGat I am (hopefully) working on the docker docs this week. There are a few things that could be optimised. I would not advertise to enable the setting by default as it leads to possibly much longer startup times.
@simonkuehling thank you for opening this issue. Am I reading your name correctly into the DACH region?
That is indeed correct (DE)!
Regarding the issue: changes in the production environment are not permanent, that is by design to keep it repeatable and safe. If a user wants to use plugin in production there is a setting that enables re-installment on restart in containers. The needs to be enabled.
Well that totally makes sense, right... May I ask for a pointer for a name of this setting and where to put it? Is it a docker configuration or does inventree handle the plugin installations?
@simonkuehling it is in the global / server setting and named: PLUGIN_ON_STARTUP / check plugins on startup or an equivalent translation
@simonkuehling it is in the global / server setting and named: PLUGIN_ON_STARTUP / check plugins on startup or an equivalent translation
For some reason I still cannot find that setting... neither in /settings/ --> Global Settings --> Server Settings
, nor in /admin/common/inventreesettings/
I see that it is defined in /InvenTree/common/models.py, but it does not show up in the interface here (for both production and development docker installs)
@matmair this create=False
argument was added to stop the creation of database entries during system initialization, which was causing things like data importing to break.
This means that for @simonkuehling to get it working, he'll have to manually add a setting PLUGIN_ON_STARTUP
(and set it to True
) via the admin interface...
We might need to rethink this!
@simonkuehling turns out the setting is missing in the latest master. Idk how that happened - sorry about that. A fix should be merging soon (TM).
Hi @SchrodingersGat, I'm very excited to see your brother_ql integration as a plugin here - I was about to try the same, but luckily you had a go at it already. Since this is looks to be at a very early stage still - is it already meant to work in some basic form? I installed the plugin via plugins.txt in my inventree docker setup, but cannot find where the configuration is done in the interface. The plugin system is enabled and the inventree-brother-plugin installation went through during invoke update, though.
I'm happy to give it a try and provide feedback for brother models QL-720NW and QL-1110NWB!