-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.py
More file actions
85 lines (67 loc) · 1.7 KB
/
Copy pathservice.py
File metadata and controls
85 lines (67 loc) · 1.7 KB
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
from requests import request, RequestException
import random, time, hue
from threading import Lock
from urllib import request as rq
mutex = Lock()
def homePage(driver, url):
while True:
try:
rq.urlopen(url=url)
break
except Exception as e:
print(e)
time.sleep(1)
hue.init()
hue.base()
openWebPage(driver,url)
def openWebPage(driver, url):
global mutex
mutex.acquire()
driver.get(url)
mutex.release()
def randomize(lista):
new_list = list()
i = 0
length = len(lista)
while i < length:
i = i+1
ran = random.randint(0,length-i)
new_list.append(lista[ran])
lista.pop(ran)
return new_list
def randomFrequency():
ran = random.randint(6,30)
ran = ran*50
return ran
def transition(isOn):
hue.wrong()
time.sleep(2)
if isOn:
hue.dance()
else:
hue.right()
def send(method='GET', url=None, data=None, headers={}):
# the response dictionary, initially empty
response_dict = dict()
# check that the URL is not empty
if url is not None:
# try to call the URL
result = None
try:
# get the result
result = request(method, url, data=data, headers=headers)
except RequestException as e:
# print the error
print(e)
# check result
if result is not None:
# consider the response content as JSON and put it in the dictionary
response_dict = result.json()
return response_dict
if __name__ == '__main__':
"""a = {'p': 1, 'q': 2}
b = dict(a)
print(b)
a['s']=3
print(b)
print(chr(ord('a')+1))"""