Olen / Spond

GNU General Public License v3.0
45 stars 22 forks source link

`attendance.py` fails on Windows #36

Closed elliot-100 closed 1 week ago

elliot-100 commented 2 years ago

Following on from #27 Run wth no parameters:

C:\Users\Elliot\dev\Spond\venv37\Scripts\python.exe C:\Users\Elliot\dev\Spond\attendance.py 
Traceback (most recent call last):
  File "C:\Users\Elliot\dev\Spond\attendance.py", line 59, in <module>
    loop.run_until_complete(main())
  File "C:\Users\Elliot\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 587, in run_until_complete
    return future.result()
  File "C:\Users\Elliot\dev\Spond\attendance.py", line 24, in main
    with open(filename, 'w', newline='') as csvfile:
OSError: [Errno 22] Invalid argument: './exports\\2023-04-11T17:45:00Z-Redacted Redacted.csv'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000002362A4D7748>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000002362A4F8C18>, 2373424.39)]']
connector: <aiohttp.connector.TCPConnector object at 0x000002362A4D7788>

Process finished with exit code 1

I think the issue is that ":" characters are not valid in Windows filenames.

(What's best practice for timestamps in filenames? This is only a sample script, and there will be other, potentially invalid characters in event headings...)

Olen commented 1 year ago

I usually replace ":" with either "_" or ".".

A simple rule is just to replace anything other than "A-z0-9.-" with "_". One could also first replacce ":" wilth "." and then replace everything else with "".

But you also have stuff like "slugify" which may be another solution https://github.com/un33k/python-slugify

elliot-100 commented 1 year ago

Related: #53

elliot-100 commented 1 week ago

I think this is probably fixed by #155, but I have abandoned trying to develop on Windows in any case