I set a python script as a "always on" task but it keeps running into the same exception. However, when I run the script as a "scheduled task" it works completely fine. Here is what the always on log shows...
Jul 11 03:44:38 Logged in
Jul 11 03:44:38 File exported
Jul 11 03:44:38 Driver closed
Jul 11 03:44:38 Rename failed
Jul 11 03:44:38 Traceback (most recent call last):
Jul 11 03:44:38 File "/home/user/folder/script.py", line 74, in <module>
Jul 11 03:44:38 newest_file = max(glob.iglob('*.csv'), key=os.path.getctime)
Jul 11 03:44:38 ValueError: max() arg is an empty sequence
Here is the code block this error relates to...
try:
newest = max(glob.iglob('report*.csv'), key=os.path.getctime)
dst = time.strftime("%H-%M %m-%d-%Y.csv")
os.rename(newest, dst)
except:
print('Rename failed')
else:
print('Renamed')
I feel like this could be an issue with the time module or the working directory. Not really sure. Any thoughts on how I can get this error resolved?