Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions cmds/cmd_package/cmd_package_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,36 +133,30 @@ def is_user_mange_package(bsp_package_path, pkg):
break
return False

is_China_ip = None

class GeographyLocation():
_is_china = False

def __init__(self):
try:
ip = requests.get('https://ifconfig.me/ip').content.decode()
url = 'http://www.ip-api.com/json/' + ip
if requests.get(url).json()['country'] == 'China':
self._is_china = True
else:
self._is_china = False
except:
if (-time.timezone)/3600 == 8:
self._is_china = True
else:
self._is_china = False

if(self._is_china):
print("[Use Gitee server]")
def need_using_mirror_download():
global is_China_ip
if is_China_ip != None:
return is_China_ip
try:
ip = requests.get('https://ifconfig.me/ip').content.decode()
url = 'http://www.ip-api.com/json/' + ip
if requests.get(url).json()['country'] == 'China':
is_China_ip = True
else:
print("[Use Github server]")

def isChina (self):
return self._is_china
is_China_ip = False
except:
if (-time.timezone)/3600 == 8:
is_China_ip = True
else:
is_China_ip = False

iplocation = GeographyLocation()
if(is_China_ip):
print("[Use Gitee server]")
else:
print("[Use Github server]")

def need_using_mirror_download():
return iplocation.isChina()

def is_git_url(package_url):
return package_url.endswith('.git')
Expand Down