SSIS Execute Process Task for Python script to API with OAuth2 - Access denied to the file with saved token

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 01:28:45

I found the problem. And it was related with the properties of Execute Process Task step of SSIS Package...

As I noticed above, I executed Python script by .bat file with the command inside: C:\Python27\python.exe C:\BI\API\Python_GoogleAnalytics_Reporting\v3_api_analytics\google_analytics_api_v3_10krows_nosampling_multiple_profiles.py. Execution of the .bat itself worked fine, but execution of the same .bat from SSIS Package as Execute Process Task step - returns the errors above.

In the logs of errors in the beginning we see:

C:\Program Files (x86)\Microsoft SQL Server\110\DTS\binn> C:\Python27\python.exe C:\BI\API\Python_GoogleAnalytics_Reporting\v3_api_analytics\google_analytics_api_v3_10krows_nosampling_multiple_profiles.py

C:\Python27\lib\site-packages\oauth2client_helpers.py:260: UserWarning: Cannot access analytics.dat: No such file or directory

warnings.warn(_MISSING_FILE_MESSAGE.format(filename))

What says initially, that there is no file analytics.dat in the working folder of script. But I expected, that script executes in the same folder where it is located and there already had existed file C:\BI\API\Python_GoogleAnalytics_Reporting\v3_api_analytics\analytics.dat

But then I noticed, that on the first place in that message (I marked it as bold) is working folder of the external script execution, script starts in the SSIS folder.

I found, that when the process is launched from SSIS, it's not being run from the same folder as the executable .bat file located. What is different from the direct .bat file execution.

So, it is necessary additionally specify working folder property of Execute Process Task step of SSIS Package.

I set such property value:

Working directory: C:\BI\API\Python_GoogleAnalytics_Reporting\v3_api_analytics\

And everything works fine!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!