-
Notifications
You must be signed in to change notification settings - Fork 0
/
getTime.py
32 lines (25 loc) · 880 Bytes
/
getTime.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
from urllib import urlopen
import os
import time
resDate=urlopen('http://just-the-time.appspot.com/')
while(True):
try:
strin=r'<span id="currentTime">'
res=urlopen('http://24timezones.com/es_husohorario/mexico_city_hora_actual.php')
resDate=urlopen('http://just-the-time.appspot.com/')
timeStr=res.read().strip()
dateStr=resDate.read().strip()
particion=timeStr.split(strin)
particionDate=dateStr.split(" ")
timeAct=str(particion[1]).split(" ")
dateAct=str(particionDate[0])
print dateAct
print "sudo date -s "+dateAct+" "+timeAct[0]+" "+timeAct[1][0:2]
os.system("sudo date -s "+dateAct+" "+timeAct[0]+" "+timeAct[1][0:2])
timeStr=""
dateStr=""
particion={}
particionDate{}
time.sleep(60)
except:
time.sleep(60)