Closed flying-sheep closed 4 years ago
By the way, perhaps we should use this opportunity to change the default name.
"Python SoundCard" would certainly be better than "audio". Or perhaps, we could even do something like " ".join(sys.argv)
by default. But I am not sure whether that's actually a good idea... Do you have a preference?
I created a little function to infer the appname. Please tell me if you think the full path or parameters are too valuable information to throw away. I think keeping things too long is confusing here.
I agree. As long as it's reasonably obvious to the user that this is the Python script they're running, a short name is better than a longer one.
Could you give an example of how your function would handle, say python mycoolscript.py
and ./mycoolscript.py
?
As this functionality is currently pulseaudio/Linux-only, I'd prefer to keep it inside pulseaudio.py instead of a separate file for now.
Okay!
$ cd /tmp
$ echo >mycoolscript.py <EOF
#!/usr/bin/env python3
import sys, os
print(os.path.basename(sys.argv[0]))
EOF
$ chmod +x mycoolscript.py
$ python3 mycoolscript.py
mycoolscript.py
$ ./mycoolscript.py
mycoolscript.py
$ python -m mycoolscript
mycoolscript.py
I’ll also fix the package case, which currently does:
$ mkdir mycoolscript
$ mv mycoolscript.py mycoolscript/__main__.py
$ python -m mycoolscript
__main__.py
/edit: done, the last one now returns “mycoolscript”
Cool, thank you very much!
This looks very good to me! Only one small change is still needed, that I missed last time (sorry): The documentation for SoundCard is built from the Linux source, so the docstrings of set_name
and get_name
need to mention that they are only implemented for Linux at the moment.
Done. I also edited the doc config:
It didn’t work for me, as it infinitely hung here:
Great work! Thank you.
Do you feel this is ready to merge?
Yeah, I think so!
Thank you very much for your contribution, and a pleasant conversation!
(Should I forget to cut a new release for SoundCard in a month or so, feel free to ping me on this thread.)
Fixes #81
Fun fact: This is the 3rd time in my life that a non-trivial piece of code in unfamiliar territory worked on the first try.