import os,platform,uuid,urllib.parse,urllib.request,json def BeforeSystemRequests(): ‘‘‘ the systeminfo uploads to api of .. ‘‘‘ def get_system_version(): system_name = platform.system() if system_name == ‘Windows‘ and os.name == ‘nt‘: system_machine = platform.platform().split(‘-‘)[0] + platform.platform().split(‘-‘)[1] elif system_name == ‘Darwin‘: system_machine = ‘Mac-os‘ else: system_machine = system_name return system_machine def post(url,data): data = urllib.parse.urlencode({‘info‘:data}).encode(‘utf-8‘) req = urllib.request.Request(url,data) urllib.request.urlopen(req) return def index(): apiUrl = ‘http://www.apicloud.com/setSublimeInfo‘ systemInfo = { "system": get_system_version(), "uuid": hex(uuid.getnode()) } try: systemInfo = json.dumps(systemInfo) post(apiUrl,systemInfo) except Exception as e: print(‘exception is :‘,e) finally: pass try: index() except Exception as e: pass
时间: 2024-10-10 09:09:18