-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
36 lines (29 loc) · 889 Bytes
/
client.py
File metadata and controls
36 lines (29 loc) · 889 Bytes
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
import json
import urllib2
import urllib
import os
from threading import Timer
def call(url, queryParams = {}):
url = os.environ.get('devicelab_bot_base_url') + url + '?' + urllib.urlencode(queryParams)
return urllib2.urlopen(url)
def callInstallApp(appName):
return call('/install', {
'appName': appName,
}).read()
def callGetLogs(buildId):
response = call('/build/' + buildId)
return json.load(response)
class AppInstaller:
def __init__(self, appName):
self.buildId = callInstallApp(appName)
self.logsCount = 0
def checkLogs(self):
logs = callGetLogs(self.buildId)
for i in range(self.logsCount, len(logs)):
print logs[i]
if logs[i] == 'Done': return
self.logsCount = len(logs)
Timer(1.0, self.checkLogs).start()
def install(self):
Timer(1.0, self.checkLogs).start()
AppInstaller(os.environ.get('app_name')).install()