Forums

Running scheduled tasks with subprocess module git bash commands

Hey guys,

I'm trying to run a daily python script that uses the subprocess module to run git commands to push log files to the repo. Is there a command to tell the Task to run with bash instead of python interpreter?

I don't believe you can call git commands from python interpreter.

Thanks!

Hi, look at the section "Non-Python scripts" of this help page: https://help.pythonanywhere.com/pages/ScheduledTasks/.

You could run git commands from Python btw. The problem might be rather your git setup -- if it requires an authentication (or any interactivity), such script obiously won't work correctly as a scheduled task.

A little related: Does anyone know how to make the scheduled task (a python-file that logs .txt-files) push its changes in the directory, to the GitHub-repo at the end of each finished task? I am using git commands from bash from time to time, and wonder if GitPython is a package I should look into using? Would be awesome to automate it and would love to see an example.

You could try something like this - https://www.pygit2.org/

Thanks alot, will check this out!

Let us know if you encounter problems.