码迷,mamicode.com
首页 > 编程语言 > 详细

python实现获取系统版本和mac信息上传到指定接口

时间:2016-05-18 14:36:11      阅读:414      评论:0      收藏:0      [点我收藏+]

标签:

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   

  

python实现获取系统版本和mac信息上传到指定接口

标签:

原文地址:http://www.cnblogs.com/songqingbo/p/5504899.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!