-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.py
138 lines (95 loc) · 4.7 KB
/
Utils.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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import os,shutil,subprocess
class Utils:
def __init__(self,jootaLocation):
self.jootaLocation = jootaLocation
def createLicense(self, buildNumber):
'''
Create a license for the current build
'''
# Change directory to the license generation folder
os.chdir(self.jootaLocation + 'Licensing/licgen/')
# Creates a variable for running the license tool
self.fLicrun = self.jootaLocation + 'Licensing/licgen/licgen.sh'
self.buildNumber = buildNumber
# Runs the license tool with the build number as a parameter
subprocess.call([self.fLicrun, self.buildNumber])
# Moves the license from the project folder to the selected destination
shutil.move(self.jootaLocation + 'Licensing/licgen/' + 'joota{}.lic'.format(self.buildNumber), self.jootaLocation + 'Licensing/Joota_Licenses' + '/' + 'joota{}.lic'.format(self.buildNumber))
def retrieveFromJenkins(self,buildType,userDefinedBuildNumber = None,version = None):
import urllib
os.chdir(self.jootaLocation)
if buildType == 'Stable':
address = 'http://jenkinsii:8080/job/Joota_901stable/lastSuccessfulBuild/FnMachineSpec=meerman,FnOptType=release,FnProductLabel=Joota/artifact/Archive.tgz'
self.fileName = 'Stable_Archive.tgz'
if buildType == 'Dev':
address = 'http://jenkinsii:8080/job/Joota_901dev/lastSuccessfulBuild/FnMachineSpec=meerman,FnOptType=release,FnProductLabel=Joota//artifact/Archive.tgz'
self.fileName = 'Dev_Archive.tgz'
if buildType == 'Specific':
address = 'http://jenkinsii:8080/job/Joota_901{}/{}/FnMachineSpec=meerman,FnOptType=release,FnProductLabel=Joota/artifact/Archive.tgz'.format(version,userDefinedBuildNumber)
self.fileName = '{}_Archive.tgz'.format(version)
else:
print ' no buildType'
print 'Archive Files is....' +self.fileName
#Delete Old Archives in this folder in order to make sure there is only one.
if os.path.exists(self.jootaLocation + self.fileName):
os.remove(self.jootaLocation + self.fileName)
# print 'deleted old archive.tgz'
else:
pass
lastSuccessfulBuild = urllib.URLopener()
lastSuccessfulBuild.retrieve(address, self.fileName)
def get_file_size(self,buildType,userDefinedBuildNumber = None,version = None):
import urllib
if buildType == 'Stable':
self.address = 'http://jenkinsii:8080/job/Joota_901stable/lastSuccessfulBuild/FnMachineSpec=meerman,FnOptType=release,FnProductLabel=Joota/artifact/Archive.tgz'
if buildType == 'Dev':
self.address = 'http://jenkinsii:8080/job/Joota_901dev/lastSuccessfulBuild/FnMachineSpec=meerman,FnOptType=release,FnProductLabel=Joota//artifact/Archive.tgz'
if buildType == 'Specific':
self.address = 'http://jenkinsii:8080/job/Joota_901{}/{}/FnMachineSpec=meerman,FnOptType=release,FnProductLabel=Joota/artifact/Archive.tgz'.format(version,userDefinedBuildNumber)
site = urllib.urlopen(self.address)
meta = site.info()
fileSize = meta.getheaders("Content-Length")
return fileSize
def getFolderList(self,buildType):
'''
Search through your builds folder and populate a list so that the dropdown box has Content
'''
if buildType == 'Stable':
self.folderPath = self.jootaLocation +'/Joota_Builds/Stable_Builds'
self.Type = 'Stable'
if buildType == 'Dev':
self.folderPath = self.jootaLocation +'/Joota_Builds/Dev_Builds'
self.Type = 'Dev'
if buildType == 'Integration':
self.folderPath = self.jootaLocation +'/Joota_Builds/Integration_Builds'
self.Type = 'Integration'
if not os.path.exists(self.folderPath):
os.makedirs(self.folderPath)
else:
pass
# Empty the list
self.buildList = []
# loop through all the folders within the folder Joota_Downloads and append them to the list self.buildList
for file in os.listdir(self.folderPath):
if file == '.DS_Store':
pass
else:
self.buildList.append(file)
print self.buildList.sort(key = lambda x: os.stat(os.path.join(self.folderPath, x)).st_mtime)
# for item in self.buildList:
# print item
return self.buildList
def runBuild(self,buildType,build):
if buildType == 'Stable':
self.JootaCrashReportPath = self.jootaLocation + 'Joota_Builds/Stable_Builds/' + build + '/joota.app/Contents/MacOS/joota'
# print self.JootaCrashReportPath
if buildType == 'Dev':
self.JootaCrashReportPath = self.jootaLocation + 'Joota_Builds/Dev_Builds/' + build + '/joota.app/Contents/MacOS/joota'
# print self.JootaCrashReportPath
if buildType == 'Integration':
self.JootaCrashReportPath = self.jootaLocation + 'Joota_Builds/Integration_Builds/' + build + '/joota.app/Contents/MacOS/joota'
# print self.JootaCrashReportPath
# Create the extension beacuse subprocess says so....
extension = '-dboff:crashreport'
#Run Joota with crash report
subprocess.Popen([self.JootaCrashReportPath, extension])