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

Invalid default screenshot file name in Windows. #993

Closed
kmonson opened this issue Oct 23, 2022 · 2 comments · Fixed by #995
Closed

Invalid default screenshot file name in Windows. #993

kmonson opened this issue Oct 23, 2022 · 2 comments · Fixed by #995
Labels
bug Something isn't working

Comments

@kmonson
Copy link

kmonson commented Oct 23, 2022

Default screenshot filename format in App.save_screenshot (specifically time_format) results in colons in the default file name. This is invalid in Windows.

OSError: [Errno 22] Invalid argument: './textual demo 2022-10-23 16:00:23 341765.svg'

An additional replace call here is probably needed: https://github.com/Textualize/textual/blob/main/src/textual/app.py#L538

@davep davep added the bug Something isn't working label Oct 24, 2022
@davep
Copy link
Contributor

davep commented Oct 24, 2022

Good catch, thanks.

davep added a commit to davep/textual that referenced this issue Oct 24, 2022
This extends the set of reserved characters that are guarded against when
auto-generating a screenshot filename. The extension covers the most likely
candidates taken from:

   https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions

This could be spun out into a more general filename cleaning function, which
takes OS and filesystem into account and covers every single reserved
character, but for the purposes of this bit of code this should be more than
enough.

Addresses Textualize#993.
@davep davep linked a pull request Oct 24, 2022 that will close this issue
davep added a commit to davep/textual that referenced this issue Oct 25, 2022
As per this suggestion:

  Textualize#995 (comment)

the default time format changes to one with no problematic characters within
it. For the moment at least I'm going to keep the stripping of reserved
characters as the user of the code could still pass in problematic format
strings.

See Textualize#993.
@github-actions
Copy link

Did we solve your problem?

Glad we could help!

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
Development

Successfully merging a pull request may close this issue.

2 participants