-
Notifications
You must be signed in to change notification settings - Fork 1k
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
refactor: Use pathlib on platformdirs folders #1484
base: master
Are you sure you want to change the base?
Conversation
custombtn.txt was deprecated before Printrun 2.x but the code was left. The code didn't even work as expected so this potentially breaking change has a very low chance of affecting any users. Closes kliment#1236 The `configfile` function was outdated and only used for handling custombtn.txt so it is safe to remove as well. Closes kliment#1286
* Use more modern pathlib.Path instead of os.path. * Initialize app dirs right after variable creation to avoid checking for their existence all the time. * Read/write files using `with` statements instead of manually opening and closing them. * Remove `data_dir` variable which is not used.
History file and cache dir are created during `pronsole` initialization so no need to check for their existence.
Update read/write history methods to use a pathlib.Path file instead of a file name. Existence check is removed from these functions because such check belongs to caller functions instead.
`sharedfile` is not used and therefore removed
The with statements can only be grouped since Python 3.10. Fall back to nested with statements for now.
Many thanks for testing. I just pushed a commit hoping to fix that one. Let me know if that works now. Also fixed a regression that was picked up by the GitHub Actions. |
That one is working fine now, but found another one: I got an logging error when Log to console is activated. I did a connect and disconnect. When I then try to close the Pronterface Window I'm not able to do so and got the second traceback w/o been able to close Pronterface. I need to kill the process manually. Edit: I forgot to mention that the errors happen only if I run from the binary file - running from source is fine. Terminal output:
|
Can you confirm this error does not happen on the master branch as well? Because the code regarding logging is not affected by the PR I believe. I'm unable to reproduce the behavior. |
Hi, I need to take a closer look what happen with introducing this change (#1473) and why it fails in such a strange way and more over why there is no entry with the error in the log file as well... Anyway, with this observation your PR works fine and we need to address the logging problem as an new issue. |
Works also fine on macOS. 🚀 |
@rockstorm101, I created a new issue for my finding regarding the logging issue #1485. |
Here is some refactoring to clean up the code base a bit. Nothing in this PR is written in stone so please feel free to reject/criticize/suggest changes. I tried to make commits self-explanatory but here is a summary:
printrun/pronsole
:their existence all the time.
with
statements instead of manually opening andclosing them.
data_dir
variable which is not used.printrun/pronterface
:pronsole
initialization so noneed to check for their existence.
printrun/utils
:name. Existence check is removed from these functions because such check
belongs to caller functions instead.
lookup_file
function and their respective callerssharedfile
is not used and therefore removed