Change-Id: Id0ac12616cf90659c619567fea5ea173eeeb67e6
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4645
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Divya Thaluru <dthaluru@vmware.com>
... | ... |
@@ -113,11 +113,11 @@ class photonPublish: |
113 | 113 |
newCount = len(checkResults[const.new]) |
114 | 114 |
|
115 | 115 |
if(updateCount + newCount == 0): |
116 |
- print 'Remote is up to date.' |
|
116 |
+ print('Remote is up to date.') |
|
117 | 117 |
return |
118 | 118 |
|
119 | 119 |
#push updates |
120 |
- print 'Updating %d files' % updateCount |
|
120 |
+ print('Updating %d files' % updateCount) |
|
121 | 121 |
for new in checkResults[const.updates]: |
122 | 122 |
filePath = new[const.path] |
123 | 123 |
fileName = os.path.basename(filePath) |
... | ... |
@@ -126,7 +126,7 @@ class photonPublish: |
126 | 126 |
self.updateFile(fullPath, pathName) |
127 | 127 |
|
128 | 128 |
#push new files |
129 |
- print 'Pushing %d new files' % newCount |
|
129 |
+ print('Pushing %d new files' % newCount) |
|
130 | 130 |
for new in checkResults[const.new]: |
131 | 131 |
filePath = new[const.path] |
132 | 132 |
fileName = os.path.basename(filePath) |
... | ... |
@@ -142,11 +142,11 @@ class photonPublish: |
142 | 142 |
filesToPush = glob.glob(filePath) |
143 | 143 |
for fileToPush in filesToPush: |
144 | 144 |
result = self.pushFile(fileToPush, pathName) |
145 |
- print result |
|
145 |
+ print(result) |
|
146 | 146 |
results.append(result) |
147 | 147 |
|
148 | 148 |
def pushFile(self, fileToPush, pathName): |
149 |
- print 'Pushing file %s to path %s' % (fileToPush, pathName) |
|
149 |
+ print('Pushing file %s to path %s' % (fileToPush, pathName)) |
|
150 | 150 |
result = {} |
151 | 151 |
auth = HTTPBasicAuth(self._config['user'], self._config['apikey']) |
152 | 152 |
|
... | ... |
@@ -182,7 +182,7 @@ class photonPublish: |
182 | 182 |
return result |
183 | 183 |
|
184 | 184 |
def updateFile(self, fileToPush, pathName): |
185 |
- print 'Updating file %s at path %s' % (fileToPush, pathName) |
|
185 |
+ print('Updating file %s at path %s' % (fileToPush, pathName)) |
|
186 | 186 |
result = {} |
187 | 187 |
auth = HTTPBasicAuth(self._config['user'], self._config['apikey']) |
188 | 188 |
|
... | ... |
@@ -219,10 +219,10 @@ class photonPublish: |
219 | 219 |
|
220 | 220 |
#publishes pending content. Works with details from conf file. |
221 | 221 |
def publish(self): |
222 |
- print 'Publishing pending files to %s/%s/%s' \ |
|
222 |
+ print('Publishing pending files to %s/%s/%s' \ |
|
223 | 223 |
% (self._config['repo'], |
224 | 224 |
self._config['package'], |
225 |
- self._config['version']) |
|
225 |
+ self._config['version'])) |
|
226 | 226 |
result = {} |
227 | 227 |
auth = HTTPBasicAuth(self._config['user'], self._config['apikey']) |
228 | 228 |
|
... | ... |
@@ -242,10 +242,10 @@ class photonPublish: |
242 | 242 |
return req.json() |
243 | 243 |
|
244 | 244 |
def showUsage(): |
245 |
- print 'photonpublish.py --files /rpms/*.rpm' |
|
246 |
- print 'if you need to override config, --config /conf.conf' |
|
247 |
- print 'if you need to override user/apikey, provide' |
|
248 |
- print '--user username --apikey apikey' |
|
245 |
+ print('photonpublish.py --files /rpms/*.rpm') |
|
246 |
+ print('if you need to override config, --config /conf.conf') |
|
247 |
+ print('if you need to override user/apikey, provide') |
|
248 |
+ print('--user username --apikey apikey') |
|
249 | 249 |
|
250 | 250 |
def validate(context): |
251 | 251 |
return len(context['config']) > 0 and len(context['files']) > 0 |
... | ... |
@@ -287,10 +287,10 @@ def main(argv): |
287 | 287 |
if(context['mode'] == 'upload'): |
288 | 288 |
publish.push(context['files'], context['path']) |
289 | 289 |
elif(context['mode'] == 'check'): |
290 |
- print publish.check(context['files']) |
|
290 |
+ print(publish.check(context['files'])) |
|
291 | 291 |
|
292 |
- except Exception, e: |
|
293 |
- print "Error: %s" % e |
|
292 |
+ except Exception as e: |
|
293 |
+ print("Error: %s" % e) |
|
294 | 294 |
sys.exit(1) |
295 | 295 |
|
296 | 296 |
if __name__ == "__main__": |
... | ... |
@@ -22,10 +22,10 @@ class publishTool: |
22 | 22 |
#check local files against remote repo |
23 | 23 |
def check(self): |
24 | 24 |
result = self._publish.check(self._context['srcroot']) |
25 |
- print 'Updates: %d' % len(result[const.updates]) |
|
26 |
- print 'New: %d' % len(result[const.new]) |
|
27 |
- print 'Verified: %d' % len(result[const.verified]) |
|
28 |
- print 'Obsoletes: %d' % len(result[const.obsoletes]) |
|
25 |
+ print('Updates: %d' % len(result[const.updates])) |
|
26 |
+ print('New: %d' % len(result[const.new])) |
|
27 |
+ print('Verified: %d' % len(result[const.verified])) |
|
28 |
+ print('Obsoletes: %d' % len(result[const.obsoletes])) |
|
29 | 29 |
return result |
30 | 30 |
|
31 | 31 |
def hasPendingSync(self, advice): |
... | ... |
@@ -37,26 +37,26 @@ class publishTool: |
37 | 37 |
advice = self.check() |
38 | 38 |
if(not self._context['silent']): |
39 | 39 |
if not self.hasPendingSync(advice): |
40 |
- print 'No changes to push.' |
|
40 |
+ print('No changes to push.') |
|
41 | 41 |
return |
42 | 42 |
choice = raw_input('Continue? y/N:') |
43 |
- if choice <> 'y': |
|
44 |
- print 'Aborted on user command' |
|
43 |
+ if choice != 'y': |
|
44 |
+ print('Aborted on user command') |
|
45 | 45 |
return |
46 |
- print 'push local changes to remote...' |
|
46 |
+ print('push local changes to remote...') |
|
47 | 47 |
self._publish.syncRemote(self._context['srcroot'], advice) |
48 | 48 |
|
49 | 49 |
|
50 | 50 |
def printsha1(self, files, label): |
51 |
- print 'sha1sum of %s >>>' % label |
|
51 |
+ print('sha1sum of %s >>>' % label) |
|
52 | 52 |
for f in files: |
53 |
- print '%s - %s' % (f['name'], f['sha1']) |
|
53 |
+ print('%s - %s' % (f['name'], f['sha1'])) |
|
54 | 54 |
|
55 | 55 |
def makesha1(self): |
56 | 56 |
advice = self.check() |
57 | 57 |
verified = len(advice[const.verified]) |
58 | 58 |
if(verified <= 0): |
59 |
- print 'no files verified. nothing to do.' |
|
59 |
+ print('no files verified. nothing to do.') |
|
60 | 60 |
return |
61 | 61 |
self.printsha1(advice[const.verified], const.verified) |
62 | 62 |
|
... | ... |
@@ -68,7 +68,7 @@ class publishTool: |
68 | 68 |
verified = advice[const.verified] |
69 | 69 |
verifiedLen = len(advice[const.verified]) |
70 | 70 |
if(verifiedLen <= 0): |
71 |
- print 'no files verified. nothing to do.' |
|
71 |
+ print('no files verified. nothing to do.') |
|
72 | 72 |
return |
73 | 73 |
|
74 | 74 |
with open(self._context['sha1file'], 'w') as sha1file: |
... | ... |
@@ -82,31 +82,31 @@ class publishTool: |
82 | 82 |
pendingCount = len(pending) |
83 | 83 |
if(not self._context['silent']): |
84 | 84 |
if pendingCount == 0: |
85 |
- print 'No pending changes to publish.' |
|
85 |
+ print('No pending changes to publish.') |
|
86 | 86 |
return |
87 |
- print 'Found %d pending files to publish' % pendingCount |
|
87 |
+ print('Found %d pending files to publish' % pendingCount) |
|
88 | 88 |
choice = raw_input('Continue? y/N:') |
89 |
- if choice <> 'y': |
|
90 |
- print 'Aborted on user command' |
|
89 |
+ if choice != 'y': |
|
90 |
+ print('Aborted on user command') |
|
91 | 91 |
return |
92 |
- print self._publish.publish() |
|
92 |
+ print(self._publish.publish()) |
|
93 | 93 |
|
94 | 94 |
def showUsage(): |
95 |
- print 'Usage:' |
|
96 |
- print 'check status: publishTool.py \ |
|
95 |
+ print('Usage:') |
|
96 |
+ print('check status: publishTool.py \ |
|
97 | 97 |
--config <config file> --srcroot <source root folder> \ |
98 |
- print 'push files: publishTool.py \ |
|
98 |
+--action check') |
|
99 |
+ print('push files: publishTool.py \ |
|
99 | 100 |
--config <config file> --srcroot <source root folder> \ |
100 |
- print 'publish pushed files: publishTool.py \ |
|
101 |
- print 'make sha1 file: publishTool.py \ |
|
101 |
+--action push') |
|
102 |
+ print('publish pushed files: publishTool.py \ |
|
103 |
+--config <config file> folder> --action publish') |
|
104 |
+ print('make sha1 file: publishTool.py \ |
|
102 | 105 |
--config <config file> folder> --srcroot <source root folder> \ |
103 |
- print 'write sha1 file: publishTool.py \ |
|
106 |
+--action makesha1') |
|
107 |
+ print('write sha1 file: publishTool.py \ |
|
104 | 108 |
--config <config file> folder> --srcroot <source root folder> \ |
109 |
+--sha1file <sha1 file path> --action writesha1') |
|
105 | 110 |
|
106 | 111 |
# |
107 | 112 |
def main(argv): |
... | ... |
@@ -135,7 +135,7 @@ def main(argv): |
135 | 135 |
elif opt == '--help': |
136 | 136 |
showUsage() |
137 | 137 |
return |
138 |
- except Exception, e: |
|
138 |
+ except Exception as e: |
|
139 | 139 |
showUsage() |
140 | 140 |
sys.exit(1) |
141 | 141 |
|
... | ... |
@@ -151,8 +151,8 @@ def main(argv): |
151 | 151 |
tool.writesha1() |
152 | 152 |
elif(context['action'] == 'publish'): |
153 | 153 |
tool.publish() |
154 |
- except Exception, e: |
|
155 |
- print "Error: %s" % e |
|
154 |
+ except Exception as e: |
|
155 |
+ print("Error: %s" % e) |
|
156 | 156 |
sys.exit(1) |
157 | 157 |
|
158 | 158 |
|
... | ... |
@@ -15,7 +15,7 @@ done < <(find "${SCRIPTS_DIR}/../" -name "*.json" -type f -not -path "*stage*") |
15 | 15 |
echo "Checking all python code is compilable..." |
16 | 16 |
while read f; do |
17 | 17 |
echo "Checking:${f}" |
18 |
- if ! python -m py_compile "${f}"; then |
|
18 |
+ if ! python3 -m py_compile "${f}"; then |
|
19 | 19 |
echo "Please check:${f} for complitation errors" |
20 | 20 |
exit 1 |
21 | 21 |
fi |