Spond icon indicating copy to clipboard operation
Spond copied to clipboard

`attendance.py` fails on Windows

Open elliot-100 opened this issue 3 years ago • 2 comments

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...)

elliot-100 avatar Oct 13 '22 10:10 elliot-100

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

Olen avatar Nov 20 '22 09:11 Olen

Related: #53

elliot-100 avatar Jan 11 '23 18:01 elliot-100