Exemplo n.º 1
0
    def setUp(self):
        warnings.simplefilter("ignore", ResourceWarning)
        warnings.simplefilter("ignore", DeprecationWarning)
        warnings.simplefilter("ignore", InsecureRequestWarning)

        logging.info("{} setUp {}".format("-" * 5, "-" * 5))
        self.driver = Device.boot_app()
Exemplo n.º 2
0
def test_devices():
  pass
  from utils.device import Device, AmazonBasics, LogitechMouse
  from array import array
  device = Device(array('B', [0x29, 0xA7, 0x95, 0xCC, 0x09]), [5], [array('B',[0x01, 0x23, 0x45])], 'Test')
  device.status = 'Test'
  config.devices.append(device)
  device = AmazonBasics(array('B', [0x61, 0x8E, 0x9C, 0xCD, 0x03]), [3], array('B', [0x3C, 0x2A]))
  # device = Device(array('B', [0x61, 0x8E, 0x9C, 0xCD, 0x03]), [3], [], 'Test')
  device.status = 'Test'
  config.devices.append(device)
  device = Device(array('B', [0x98, 0xA3, 0x24, 0x69, 0x07]), [62], [], 'Test')
  device.status = 'Test'
  config.devices.append(device)
  device = LogitechMouse(array('B', [0x42, 0x66, 0x0A, 0xB1, 0x04]), [62], array('B', [0x00, 0xC2]), array('B', [0, 0x4F, 0, 0, 0x6E, 0, 0, 0, 0, 0x43]), 'Unencrypted')
  device.status = 'Test'
  config.devices.append(device)
Exemplo n.º 3
0
    def build_device_tree(self):
        """Retrieves the device list from the HAL daemon and builds
        a tree of Device (Python) objects. The root is a virtual
        device"""
        device_names = self.hal_manager.GetAllDevices()
        device_names.sort()

        virtual_root = Device("virtual_root", None, {})
        self.device_list = [virtual_root]
        
        # first build list of Device objects
        # name == device's udi 
        for name in device_names:
            device_dbus_obj = self.bus.get_object("org.freedesktop.Hal" ,name)

            # properties is the list of hal properies of "name"
            properties = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
            #print 
            #print "#######################"
            #print properties
            #print "#######################" 
            try:
                parent_name = properties["info.parent"]
            except KeyError:
                # no parent, must be parent of virtual_root
                parent_name = "/"
            except TypeError:
                print "Error: no properties for device %s"%name
                continue
            device = Device(name, parent_name, properties)
            self.device_list.append(device)

        # set parent_device and children for each Device object
        for device in self.device_list:
            parent_name = device.parent_name
            device.parent_device = virtual_root
            if parent_name!="/":
                for p in self.device_list:
                    if p.device_name==parent_name:
                        device.parent_device = p
                        p.children.append(device)
            if device!=virtual_root and device.parent_device==virtual_root:
                virtual_root.children.append(device)
            if device==virtual_root:
                device.parent_device=None
        return virtual_root
Exemplo n.º 4
0
def main():
    device = Device(MQTT_IDENTITY)
    while True:
        try:
            time.sleep(2)
            device.publish_state()
        except KeyboardInterrupt:
            device.destroy()
            break
        except Exception as e:
            print(str(e))
            print('Unknown error, restarting..')
            device = Device(MQTT_IDENTITY)
Exemplo n.º 5
0
        y2 = int(l[0]*0.95)
        self.driver.swipe(x1, y1, x1, y2, 1000)

    @log_action
    def screenshot(self, module):
        snapshot_dir = Config.task_dir or os.path.join(PROJECT_ROOT, 'report/snapshot')
        now = time.strftime("%Y-%m-%d %H_%M_%S")
        image_file = os.path.join(snapshot_dir, "{}_{}.png".format(module, now))
        logging.debug("获取 {} 模块屏幕截图".format(module))
        logging.debug("截图文件路径: {}".format(image_file))
        self.driver.get_screenshot_as_file(image_file)

    # 按键 ---------------------------------------------------------------------
    @log_action
    def back(self):
        """按返回键"""
        self.driver.keyevent(4)


if __name__ == '__main__':
    from utils.device import Device
    driver = Device.boot_app()
    e = BaseView(driver)
    e.find_text("奢侈品")
    e.find_element("id", "com.secoo:id/home_search_input")
    e.find_yaml_element('home', 'common', 'nIcoMsg').click()
    # e.click("id", "com.secoo:id/home_search_input")
    from time import sleep
    sleep(5)
    driver.quit()
Exemplo n.º 6
0
from utils.device import Device
import sys
device_udi = '/org/freedesktop/Hal/devices/volume_uuid_C025_4348'
udi_dict = {}
bus = dbus.SystemBus()
hal_manager_obj = bus.get_object('org.freedesktop.Hal', '/org/freedesktop/Hal/Manager')
hal_manager = dbus.Interface(hal_manager_obj,'org.freedesktop.Hal.Manager')
device_names = hal_manager.GetAllDevices() 
device_udi_obj = bus.get_object("org.freedesktop.Hal", device_udi)
#print device_udi_obj

device_names.sort()

#print device_names

virtual_root = Device("virtual_root", None, {})

device_list = [virtual_root]

#print device_list

for name in device_names:
    device_dbus_obj = bus.get_object("org.freedesktop.Hal" ,name)
    properties = device_dbus_obj.GetAllProperties(dbus_interface="org.freedesktop.Hal.Device")
    try:
        parent_name = properties["info.parent"]
    except KeyError:
        # no parent, must be parent of virtual_roo
        parent_name = "/"
    except TypeError:
        print "Error: no properties for device %s"%name