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
|
from misc import idToText, textToId, getSnapshots, printJSONHeader
class GetSnapshots:
def __init__(
self, host, platform, branch, sha11, sha12):
self.host = host
self.platform = platform
self.branch = branch
self.sha11 = sha11
self.sha12 = sha12
self.host_id = textToId("host", host)
self.platform_id = textToId("platform", platform)
self.branch_id = textToId("branch", branch)
self.sha11_id = textToId("sha1", sha11)
self.sha12_id = textToId("sha1", sha12)
def execute(self):
self.snapshots = getSnapshots(
self.host_id, self.platform_id, self.branch_id, self.sha11_id,
self.sha12_id)
self.writeOutput()
def writeOutputAsJSON(self):
printJSONHeader()
print "{"
# Snapshots:
print "\"snapshots\": ["
first_row = True
for sha1_id, timestamp in self.snapshots:
if not first_row:
print ",",
first_row = False
print (
"[\"" + str(idToText("sha1", sha1_id)) + "\", " +
str(timestamp) + "]")
print "]"
print "}"
class GetSnapshotsAsJSON(GetSnapshots):
def writeOutput(self):
self.writeOutputAsJSON()
|