Skip to content
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

Theme Editor crashes when using vim #401

Closed
orzel opened this issue Nov 27, 2023 · 2 comments · Fixed by #428
Closed

Theme Editor crashes when using vim #401

orzel opened this issue Nov 27, 2023 · 2 comments · Fixed by #428
Labels
bug Something isn't working

Comments

@orzel
Copy link

orzel commented Nov 27, 2023

When using vim and saving the file, the python code freaks out and the theme editor window dissapears.

27/11/2023 14:13:34 [DEBUG] The theme file has been updated, the preview window will refresh
Traceback (most recent call last):
  File "/home/orzel/clones/turing-smart-screen-python/theme-editor.py", line 263, in <module>
    if os.path.getmtime(theme_file) > last_edit_time:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen genericpath>", line 55, in getmtime
FileNotFoundError: [Errno 2] File o directory non esistente: 'res/themes/test/theme.yaml'

I'm not sure about the details, but I think vim handles filesaving differently than other editors. It uses rename instead of overwritting.

I use the following change, which works, but might be considered a hack, or too quick & dirty, I'll let you decide:

if os.path.exists(theme_file) and os.path.getmtime(theme_file) > last_edit_time:

@orzel orzel added the bug Something isn't working label Nov 27, 2023
@mathoudebine
Copy link
Owner

Hi @orzel, thnaks for raising this issue!
I'm okay with your change, it cannot do harm to check if the file exists in any case.
Do you want to create a PR for this? Otherwise I can commit the change myself.

@orzel
Copy link
Author

orzel commented Dec 4, 2023

For this one-liner, that's probably easier for you to just commit that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants