forked from ganeshrajadev/awesome-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
push_todays_script.py
30 lines (25 loc) · 1.03 KB
/
push_todays_script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os,subprocess
from constants import WORKING_DIR
os.chdir(WORKING_DIR)
cmd = "git add ."
subprocess.check_output(cmd, shell=True)
status= "git status -s"
returned_value = subprocess.check_output(status, shell=True)
print('updated files:', returned_value)
if not returned_value==b'':
commit_message='"Done Changed in the following files '
if len(str(returned_value).split(r'\n'))>0:
for file_name in str(returned_value).split(r'\n'):
commit_message=commit_message+file_name[5:]+" "
cmd= "git commit -m "+commit_message+r'"'
print("Commit message ",subprocess.check_output(cmd, shell=True))
try:
cmd= "git push origin master"
result = subprocess.check_output(cmd, shell=True)
print(result)
except:
cmd = "git pull"
returned_value = subprocess.check_output(cmd, shell=True)
cmd = "git push origin master"
result = subprocess.check_output(cmd, shell=True)
print(result)