Esempio n. 1
0
    def Single_Device(self):
        '''处理监控单设备数据'''
        single_device_url_list = []
        single_device_json_data_list = []
        self.device_data_list = []

        ####获取restful设备目录####
        restful_json_data = UrlJsonApi()
        monitor_devices_url = "%s/v1.0/stonefab/%s/hsweb/devices" % (
            self.ip_address, self.dev_id)
        devices_json_data = restful_json_data.url_method(
            1, monitor_devices_url)
        devices_data = json.loads(devices_json_data)

        ####设置全局变量,供其他函数调用####
        self.devices_data_Single = devices_data

        ####获取restful整页面设备数据地址列表####
        for i in devices_data['devices']:
            single_device_url = "%s/v1.0/stonefab/%s/rtmore/device/%s" % (
                self.ip_address, self.dev_id, i['did'])
            single_device_url_list.append(single_device_url)

        ####获取restful单设备数据####
        for i in single_device_url_list:
            i = str(i)
            single_device_json_data = restful_json_data.url_method(1, i)
            single_device_json_data = json.loads(single_device_json_data)
            single_device_json_data_list.append(single_device_json_data)

        ####设置全局变量,供其他函数调用####
        self.device_data_list = single_device_json_data_list

        #print single_device_json_data_list
        return single_device_json_data_list
Esempio n. 2
0
    def Multi_Devices(self):
        '''处理监控多设备页面数据'''
        multi_devices_url_list = []
        multi_devices_json_data_list = []

        ####获取restful多设备目录####
        restful_json_data = UrlJsonApi()
        monitor_devices_url = "%s/v1.0/stonefab/%s/devices" % (self.ip_address,
                                                               self.dev_id)
        devices_json_data = restful_json_data.url_method(
            1, monitor_devices_url)
        devices_data = json.loads(devices_json_data)

        ####获取restful多设备数据地址列表####
        for i in devices_data['devices']:
            multi_devices_url = "%s/v1.0/stonefab/%s/rtshort/device/%s" % (
                self.ip_address, self.dev_id, i['did'])
            multi_devices_url_list.append(multi_devices_url)

        ####获取restful多设备数据####
        for i in multi_devices_url_list:
            i = str(i)
            multi_devices_json_data = restful_json_data.url_method(1, i)
            multi_devices_json_data = json.loads(multi_devices_json_data)
            multi_devices_json_data_list.append(multi_devices_json_data)

        ####设置全局变量,供其他函数调用####
        self.multi_devices_json_data_list = multi_devices_json_data_list
        self.Multi_short_devices_data = devices_data

        #print multi_devices_json_data_list
        return multi_devices_json_data_list
Esempio n. 3
0
    def Simple_Devices(self):
        simple_devices_url_list = []
        simple_devices_json_data_list = []

        ####获取restful简单设备目录####
        restful_json_data = UrlJsonApi()
        monitor_devices_url = "%s/v1.0/stonefab/0001/devices" % self.ip_address
        devices_json_data = restful_json_data.url_method(
            1, monitor_devices_url)
        devices_data = json.loads(devices_json_data)

        ####获取restful简单设备数据地址列表####
        for i in devices_data['devices']:
            simple_devices_url = "%s/v1.0/stonefab/0001/rtshort/device/%s" % (
                self.ip_address, i['did'])
            simple_devices_url_list.append(simple_devices_url)

        ####获取restful简单设备数据####
        for i in simple_devices_url_list:
            i = str(i)
            simple_devices_json_data = restful_json_data.url_method(1, i)
            simple_devices_json_data = json.loads(simple_devices_json_data)
            simple_devices_json_data_list.append(simple_devices_json_data)
        #print simple_devices_json_data_list
        return simple_devices_json_data_list
Esempio n. 4
0
    def Single_Subdid_Data(self, subdid=''):
        ''' 单设备页面获取下一级设备数据 用于页面生成设备切换按钮 '''

        subdid_list = []
        Subdid_Name_list = []
        subdev = []
        single_device_url_list = []
        single_device_json_data_list = []
        restful_json_data = UrlJsonApi()

        #### 判断subdid 是否是空值 ####
        if subdid == '':
            subdid_list = []
            subdev = []

        else:
            #### 构造设备列表 ####
            subdid = subdid
            subdid_list = subdid.split('_')

            #### 构造设备的api url地址 ####
            for i in subdid_list:
                single_device_url = "%s/v1.0/stonefab/%s/rtmore/device/%s" % (
                    self.ip_address, self.dev_id, i)
                single_device_url_list.append(single_device_url)

            #### 获取设备的所有信息 ####
            for i in single_device_url_list:
                i = str(i)
                single_device_json_data = restful_json_data.url_method(1, i)
                single_device_json_data = json.loads(single_device_json_data)
                single_device_json_data_list.append(single_device_json_data)

            #### 获取设备的名称 ####
            for j in single_device_json_data_list:
                Subdid_Name_list.append(str(j['name']))

            #### 构造设备信息字典 ####
            for i in range(len(subdid_list)):
                subd_dict = {}
                subd_dict['id'] = subdid_list[i]
                subd_dict['name'] = Subdid_Name_list[i]
                subdev.append(subd_dict)

        #print subdid_list
        #print Subdid_Name_list
        #print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
        return subdid_list, subdev
Esempio n. 5
0
    def Tables_Url(self,dev_name,table_type,table_time):
        '''处理动态的url,并生产相应的json数据 '''

        #### 产生一个url地址 ####
        tables_url = "%s/v1.0/stonefab/%s/report/device/%s/%s?time=%s" %(self.ip_address,self.dev_id,dev_name,table_type,table_time)

        #### 获取数据 ####
        restful_json_data = UrlJsonApi()
        table_json_data = restful_json_data.url_method(1,tables_url)
        table_data = json.loads(table_json_data)
        
        ####设置全局变量,供其他函数调用####
        self.table_data = table_data
        
        #### 返回一个字典数据####
        print table_data
        return table_data
Esempio n. 6
0
    def Multi_Devices(self):
        multi_devices_url_list = []
        multi_devices_json_data_list = []

        ####获取restful整页面设备目录####
        restful_json_data = UrlJsonApi()
        monitor_devices_url = "%s/v1.0/stonefab/0001/hsweb/devices" % self.ip_address
        devices_json_data = restful_json_data.url_method(
            1, monitor_devices_url)
        devices_data = json.loads(devices_json_data)

        ####获取restful整页面设备数据地址列表####
        for i in devices_data['devices']:
            multi_devices_url = "%s/v1.0/stonefab/0001/rtmore/device/%s" % (
                self.ip_address, i['did'])
            multi_devices_url_list.append(multi_devices_url)

        ####获取restful简单设备数据####
        for i in multi_devices_url_list:
            i = str(i)
            multi_devices_json_data = restful_json_data.url_method(1, i)
            multi_devices_json_data = json.loads(multi_devices_json_data)
            multi_devices_json_data_list.append(multi_devices_json_data)
        print multi_devices_json_data_list