-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaravananPyApplication.py
More file actions
90 lines (66 loc) · 2.33 KB
/
SaravananPyApplication.py
File metadata and controls
90 lines (66 loc) · 2.33 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import subprocess
import shutil
import sys
from subprocess import Popen, PIPE
currentWorkingDir = os.getcwd()
repoPath = currentWorkingDir + "\SaravananPyApp"
#Getting Version of Git and Python
gitVersion = os.popen("git --version").read()
print('git --version: ' + str(gitVersion))
pythonVersion = sys.version
print('Python Version: ' + str(pythonVersion))
#sys.exit()
lastCommitID = ""
currentCommitID = ""
if not os.path.exists(repoPath):
os.system("git clone https://Santhosh2211992:TestGit22@github.com/Santhosh2211992/SaravananPyApp.git")
os.chdir(repoPath)
cmd = "git rev-parse HEAD"
lastCommitID = os.popen(cmd).read()
currentCommitID = lastCommitID
#print("lastCommitID: ", lastCommitID)
#print("currentCommitID: ", currentCommitID)
else:
os.chdir(repoPath)
cmd = "git rev-parse HEAD"
lastCommitID = os.popen(cmd).read()
os.system("git pull")
cmd = "git rev-parse HEAD"
currentCommitID = os.popen(cmd).read()
#print("lastCommitID: ", lastCommitID)
#print("currentCommitID: ", currentCommitID)
#checking if lastcommitID and currentCommitID are matching
if (lastCommitID == currentCommitID):
print("No new commits, skipping the build")
else:
print("New changes are available, Building...")
source = os.path.join(repoPath, 'build' + '.' + 'bat')
#####source = repoPath + "\" + "build.bat"
#print("source: " + source)
#####destination = currentWorkingDir + "\build.bat"
destination = currentWorkingDir
shutil.copy(source, destination)
os.chdir(currentWorkingDir)
cmdlinePassing = "build.bat" + " " + "SaravananPyApp"
#print("cmdlinePassing: " + cmdlinePassing)
#os.system(cmdlinePassing) # need to do error handling here
p = Popen(['build.bat', 'SaravananPyApp'], stdout=PIPE, stderr=PIPE)
output, error = p.communicate()
output=output.decode("utf-8")
error=error.decode("utf-8")
if p.returncode != 0: ## error case
print("output : " + str(output))
print ("********************")
print("Error : " + str(error))
## call email function
## fetch all changes happend
## attach logs of output and error
else:
# add/update contents of bin folder
os.chdir(repoPath)
# # Git push the built changes to remote
os.system("git add .")
os.system("git commit -m \"Build successfully completed for changes\"")
os.system("git push origin")
## Email function