vgrem / Office365-REST-Python-Client

Microsoft 365 & Microsoft Graph Library for Python
MIT License
1.36k stars 337 forks source link

Scheduled .BAT files work with Office365-REST-Python-Client? #595

Open sokhymi opened 2 years ago

sokhymi commented 2 years ago

I have a script that makes a copy of a file and uploads it to SharePoint. When the .bat (that refers to the .py script) is run, the file gets uploaded to SharePoint, but in Task Scheduler, the logs return a "0x1" error.

I initially thought this was a Task Scheduler issue, being that 0x1 is a widely reported issue, but another script running on the same server works fine with the same path formatting. I even tried referencing the Office365 python script in another script that I scheduled to run around the same time, but it only executes the first script that doesn't contain any Office365 library, and refuses to execute the Office365 script with a 0x1 error.

So, do scheduled scripts, for any reason, refuse to work with Office365-REST-Python-Client? Diverging from Office365, is there an alternative way to automate spreadsheet generation in SharePoint?

florinmihut-intel commented 2 years ago

I had a similar problem.

I checked my logs (in Python) and I found out:

  1. You need to use ABSOLUTE paths everywhere and be careful not to make any assumptions about the working directory and such.
  2. The user you are executing your script might not have the paths set correctly and might not see your python or the python modules, etc (check the value of the PATH and PYTHONPATH. (Check as well what user you use to run your task in the Task Scheduler).

Just my 2 cents.