- Git
set up Github project (manual)
set timeout for credentials:
git config --global credential.helper 'cache --timeout 3600'
- set up cron (every minute)
$ crontab -e
or (run as a different user)
$ crontab -u www-data -e
in crontab
* * * * * /usr/bin/python3 /home/michal/dev/sk-local-2014/downloads/download_2.py
* * * * * /usr/bin/python3 /home/michal/dev/sk-local-2014/csv2json_media2.py
* * * * * /bin/bash /home/michal/project/gist/94f985cf439ea9212d0f/autopush.sh
- in python (whole path so it is ok from cron)
path = "/home/michal/dev/sk-local-2014/"
with open(path + 'sk-ba.csv', 'w') as outfile:
csv_writer = csv.writer(outfile,delimiter=",")
for row in datacsv:
...
#copy to gist directory
import shutil
shutil.copy2(path + 'sk_mayor.csv','/home/michal/project/gist/94f985cf439ea9212d0f')
- shell script to push to github (autopush.sh)
#!/bin/bash
cd /home/michal/project/gist/94f985cf439ea9212d0f
git add -A
git commit -m "update"
# needed to be authentized
# using git config --global credential.helper 'cache --timeout 3600'
# also good for security
git push