forked from mattfair/SeleniumFactory-for-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParseSauceURL.py
56 lines (42 loc) · 1.33 KB
/
ParseSauceURL.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
import json
class ParseSauceURL:
def __init__(self, url):
self.url = url
self.fields = {}
fields = self.url.split(':')[1][1:].split('&')
for field in fields:
[key, value] = field.split('=')
self.fields[key] = value
def getValue(self, key):
if key in self.fields:
return self.fields[key]
else:
return ""
def getUserName(self):
return self.getValue("username")
def getAccessKey(self):
return self.getValue("access-key")
def getJobName(self):
return self.getValue("job-name")
def getOS(self):
return self.getValue("os")
def getBrowser(self):
return self.getValue('browser')
def getBrowserVersion(self):
return self.getValue('browser-version')
def getFirefoxProfileURL(self):
return self.getValue('firefox-profile-url')
def getMaxDuration(self):
try:
return int(self.getValue('max-duration'))
except:
return 0
def getIdleTimeout(self):
try:
return int(self.getValue('idle-timeout'))
except:
return 0
def getUserExtensionsURL(self):
return self.getValue('user-extensions-url')
def toJSON(self):
return json.dumps(self.fields, sort_keys=False)