Skip to content

Commit e53d11f

Browse files
committedJul 15, 2017
feat : check_update function added
1 parent 43d8f47 commit e53d11f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed
 

‎orangetool/orangetool_system.py

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import subprocess as sub
33
import time
4+
import requests
45
logo='''
56
________ __ .__
67
\_____ \____________ ____ ____ _____/ |_ ____ ____ | |
@@ -11,7 +12,29 @@
1112
'''
1213
ip_pattern=r"(?:[0-9]{1,3}\.){3}[0-9]{1,3}"
1314
api_1="http://ipinfo.io/ip"
14-
VERSION="orangetool-v0.22"
15+
VERSION="0.22"
16+
UPDATE_URL="http://www.orangetool.ir/version"
17+
def check_update(DEBUG=False):
18+
'''
19+
This function check orangetool site for newversion
20+
:param DEBUG: Flag for using Debug mode
21+
:type DEBUG:bool
22+
:return: True if new version is available
23+
'''
24+
try:
25+
new_version=requests.get(UPDATE_URL).text
26+
if float(new_version)>VERSION:
27+
print("New Version ("+new_version+") Of Orangetool Is Available")
28+
return True
29+
else:
30+
print("Update!")
31+
return False
32+
except Exception as e:
33+
if DEBUG==True:
34+
print(str(e))
35+
return "Error"
36+
37+
1538

1639
def get_temp(Zone=0,DEBUG=False):
1740
'''
@@ -101,7 +124,7 @@ def version():
101124
:return: return orangetool-version number as string
102125
'''
103126
print(logo)
104-
return VERSION
127+
return "orangetool-v"+VERSION
105128

106129

107130
def wakeup(day=0,hour=0,minute=0,DEBUG=False):

0 commit comments

Comments
 (0)