-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to pure PyUSB interface #56
Conversation
79bd8dc
to
6cbbdf2
Compare
Sorry for the delay in testing this, works absolutely fine as far as I can see on the PnP printer, great job! The only thing I had to change was the udev rule, my arch system did not have a 'plugdev' group, and it advises to use this (see Allowing_regular_users_to_use_device);
I did need to reboot though, resetting udev didn't seem to work. After that, flawless so far. Thank you for your efforts, this version looks amazing. |
Wonderful, thanks so much @nathancatlow for the feedback!!! I'll make note of your instructions under the Arch section when it comes time to merge. |
This allows it to work on Windows
Hi @nathancatlow, does it work with the following rule?
(I inserted |
@nathancatlow, I have a different refresh procedure for udev which should hopefully work across Linux distributions. I hope this will save you from having to reset? sudo udevadm control --reload-rules
sudo udevadm trigger --attr-match=idVendor="0922" |
The latest commit on this branch runs for me in a Windows virtual machine if I set the driver to WinUSB using Zadig. |
I hope to receive my PNP today and I'll test this branch. I've never used this software before so this should be a representative example of a new user. |
That's very valuable, thanks! Please try installing with just pipx and run |
Okay, here's what I've done:
I'll restart my machine and see if it helps. |
1.4.1 doesn't work for me either so that's probably not related to this discussion. :/ |
Oh, this is really excellent data!!! I'm glad you're testing this on a fresh setup. For reference, here's what it looks like for me:
I am really wondering what's leading to the timeout. It's interesting that the kernel driver is active for you (hence the detach) but not for me. Perhaps that has something to do with it. It's really tough for me to properly debug this stuff because I hit "works for me". 😄
That's really great to know. Did you try it with the nonexistent What's the name of the group on your system? Is it |
Okay, I got it to work on version 2.0.0. I succeeded after I left it connected to USB charger for some 20 minutes :) About udev rules, the default content of a rules file didn't work until I changed the group name in the rules file. I changed it to If Debian and derivatives also have I'll post some response codes I extracted from my failed attempts. |
I was just now flipping through some of the issues, and I noticed here that @MatthiasLohr also uses the I wonder if this is a standard, and I wonder if we can detect it. (Maybe we could parse |
|
Just yesterday I installed the same software on my girlfriend's laptop with Linux Mint, also worked fine. The script may run command "groups" and see which groups the user belongs to. If there's |
But what would you do then with this information? Without root, you can't do anything about that. The better, maybe best way, IMO: Use udev. If installed as root, install a udev rule, which raises the privileges of that device (will need to collect a list of VID/PID of the respective devices) so everyone can write to it. |
Any ideas on how to make the process less cumbersome? I thought the autogenerated instructions here in v2 were a big step forward. If we can detect the correct group name, then we can autogenerate the correct instructions for adding the udev rule. Maybe we do something like prioritize I'd prefer to keep dymoprint user-installable, and I'd like to avoid something that directly modifies the udev config without user intervention. |
I don't see it as a big problem that there are no root privileges at the time of installation. I think the install script (bash?) shoud do the following:
I don't think manipulating udev is a big deal, after all a new file with unique name is being created and this can be reverted easily. EDIT: I believe that |
Maybe we could do the trick of curling an install script and piping it to I think we only need Git for development installs. On my Ubuntu 20.04 install, I'm in |
Frankly, I don't see it as a threat to allow everyone to access DYMO printer, not just users from some specific group, to which everyone belongs anyway. Perhaps we're wasting time trying to restrict access to some specific group. |
Agreed. I don't know much about udev, but if there's a simple rule for "all users" then let's use it. |
What the... sorry guys, aber why bash scripts, pacman, etc...? Hey, it's python! Lets's use pip packages, that is what they have been invented for. I think it is extremely easy to argue how to solve and then solve it.
End of the magic. Should cover any cases, uses standard Python PIP packes (with some easy to add post installation script, invoked by the setup routing), and each user can decide to install it as root or not, and otherwise grant root privileges for udev or not. No curl, no git, no bash, no pipes. |
That's what I meant with "raise privieleges". Just allow everyone to access the printer. Unfortunately, I guess, it's one rule per device (identified by usb vendor and product id, short VID/PID). Example:
|
The point of bringing up bash and apt was to install pip or pipx in the first place. :) Python surely can do that, but guerilla installation of pip, outside the jurisdiction of a package manager is... regrettable. With udev simplified down to granting access to anyone, your bullet-point flowchart sounds OK to me. |
I would leave that out of configuration, since that covers more than just this project. I actually try to avoid things offering me a longish bash script for installation. Always have the fear that "something" might happen.
This leaves the room for the question what is "outside the jurisdiction". But in general, I agrees on that. However, a lot of (per-default installed as root) debian packages bring and install their udev rules in /etc/udev/rules.d/*. Beside that it's pip and not apt, I personally don't see any reason not to do it similar, if it is decided to need udev rules.
That's correct. Just take my line I posted above and duplicate it per different product id (presumably, vendor id should be same for all?). Then, we could just write the file |
If udev rules can be applied by installation script of dymoprint's pip package, then I think it should be done - in this case removal of a package will reverse this change and delete udev rules file, which is perfect. Unfortunately I don't know anything about packaging, be it pip or apt. I think you got me convinced here. Perhaps the installation should be simple enough so no script shall be needed. A manual like:
|
Full ACK on that. I can support with pip packaging if required. How to proceed on this? |
Well, the usual workflow is to fork this repository onto your own account, commit changes to it, and then do a pull request back into this repository. Then a bunch of random people like you and me will debate on it, and hopefully the owner of this repository will accept the change. |
I'd like to keep things as simple as possible. I feel like install scripts are a bit of an antipattern, but the problem in this case is how to set up the udev rule while:
and these two are somewhat in conflict. The current v2 approach is:
I actually feel like this strikes a decent balance between 1 and 2. And if we modify the current udev rule so that everyone gains access, I think it should be reliable. Before sinking more time and discussion into scripts, I'm very interested to know specifically what you find cumbersome in this approach. |
That's a good question. Personally I think it's too hard to notice there is an instruction at the end of dymoprint output, because before that there's 15 lines of error traceback. Most users will just ignore reading that. There's no instruction available in dymoprint_gui at all, and many users will flock over this tool. And finally, allowing everyone to access just this class of devices is not a big deal. Isn't that what Windows does all the time? But I get it, it's not right to change someone's udev rules without saying anything. But in the end, the user will have to type in a sudo password, and will be notified what this is for. |
Ok, but we can catch the exception and print only the instruction.
Ya, it's not so mature yet.
Agreed.
Ya, and I kind of like that the command is directly tied to the permissions error. If we did this during a setup script, then maybe we add unnecessary rules. And then if something in the permissions change, then in order to fix it, the user want to run the setup script again. Then the setup script becomes some bit of magic. So... let's suppose we suppress the traceback on the permissions error, and we improve the instruction in |
I think the pip setup script already exists (setup.py), it's a matter of extending it. I would really prefer having that udev rule file added by a setup script, and deleted when the package is removed. I can't see a reason for changing anything in that udev rule file in the future. It is a separate file that has Rule files have, by convention, a number as a file name prefix. The purpose of that is to assign priority. We could assign it priority 00, and let it be overridden by other rules if there's ever any conflict with preexisting rules. |
So how about merging this thing already? Nobody said it's not working. |
@tomek-szczesny, as you wish 😉 |
I would veto anything involving This discussion seems to be continuing in #67 |
Closes #51
This should drastically simplify everything if it works. It may even lead to platform-independence! (MacOS + Windows)
Currently we're using primarily the raw HID file interface. In parallel we have an experimental PyUSB interface.
There's a lot of effort in maintaining these two separate interfaces. Also, the old HID file interface requires the awkward usb_modeswitch utility. PyUSB should make things nicer.
Please also try experimenting with removing the
usb_modeswitch
config. Same with the udev config, since the program should also provide custom instructions for configuring udev permissions.Please test this and provide feedback here. Remember to include the model. I made the output rather verbose, so this should be helpful in diagnosing any issues. Thanks!!!
Install command:
pipx install --pip-args=pre --force dymoprint==2.0.0b0 # OR pipx install --force git+https://github.com/computerlyrik/dymoprint@pyusb-only
Revert to release version: