예제 #1
0
 def get_running_emulators(cls):
     running = []
     for platform, sdks in get_all_emulator_info().items():
         for sdk in sdks:
             if ManagedEmulatorTransport.is_emulator_alive(platform, sdk):
                 running.append((platform, sdk))
     return running
예제 #2
0
파일: base.py 프로젝트: tulth/pebble-tool
 def get_running_emulators(cls):
     running = []
     for platform, sdks in get_all_emulator_info().items():
         for sdk in sdks:
             if ManagedEmulatorTransport.is_emulator_alive(platform, sdk):
                 running.append((platform, sdk))
     return running
예제 #3
0
파일: util.py 프로젝트: woernsn/urchin-cgm
def set_config(config, platforms):
    for platform in platforms:
        emu = ManagedEmulatorTransport(platform)
        emu.connect()
        time.sleep(0.5)
        emu.send_packet(WebSocketPhonesimAppConfig(config=AppConfigSetup()),
                        target=MessageTargetPhone())
        time.sleep(0.5)
        emu.send_packet(WebSocketPhonesimAppConfig(config=AppConfigResponse(
            data=urllib2.quote(json.dumps(config)))),
                        target=MessageTargetPhone())
    # Wait for the watchface to re-render and request data
    time.sleep(0.5)
예제 #4
0
 def _connect_emulator(self, platform, sdk):
     connection = PebbleConnection(ManagedEmulatorTransport(platform, sdk), **self._get_debug_args())
     connection.connect()
     connection.run_async()
     # Make sure the timezone is set usefully.
     if connection.firmware_version.major >= 3:
         ts = time.time()
         tz_offset = -time.altzone if time.localtime(ts).tm_isdst and time.daylight else -time.timezone
         tz_offset_minutes = tz_offset // 60
         tz_name = "UTC%+d" % (tz_offset_minutes / 60)
         connection.send_packet(TimeMessage(message=SetUTC(unix_time=ts, utc_offset=tz_offset_minutes, tz_name=tz_name)))
     return connection
예제 #5
0
def set_config(config, platforms):
    for platform in platforms:
        emu = ManagedEmulatorTransport(platform)
        emu.connect()
        time.sleep(0.5)
        emu.send_packet(WebSocketPhonesimAppConfig(
            config=AppConfigSetup()),
            target=MessageTargetPhone()
        )
        time.sleep(0.5)
        emu.send_packet(WebSocketPhonesimAppConfig(
            config=AppConfigResponse(data=urllib2.quote(json.dumps(config)))),
            target=MessageTargetPhone()
        )
    # Wait for the watchface to re-render and request data
    time.sleep(0.5)
예제 #6
0
 def _connect(self, args):
     self._set_debugging(args.v)
     if getattr(args, 'phone', None):
         return self._connect_phone(args.phone)
     elif getattr(args, 'qemu', None):
         return self._connect_qemu(args.qemu)
     elif getattr(args, 'emulator', None):
         return self._connect_emulator(args.emulator, args.sdk)
     elif getattr(args, 'cloudpebble', None):
         return self._connect_cloudpebble()
     elif getattr(args, 'serial', None):
         return self._connect_serial(args.serial)
     else:
         if 'phone' in self.valid_connections and 'PEBBLE_PHONE' in os.environ:
             return self._connect_phone(os.environ['PEBBLE_PHONE'])
         elif 'qemu' in self.valid_connections and 'PEBBLE_QEMU' in os.environ:
             return self._connect_qemu(os.environ['PEBBLE_QEMU'])
         elif 'cloudpebble' in self.valid_connections and os.environ.get('PEBBLE_CLOUDPEBBLE', False):
             return self._connect_cloudpebble()
         elif 'serial' in self.valid_connections and 'PEBBLE_BT_SERIAL' in os.environ:
             return self._connect_serial(os.environ['PEBBLE_BT_SERIAL'])
         elif 'emulator' in self.valid_connections:
             running = []
             emulator_platform = None
             emulator_sdk = None
             if 'PEBBLE_EMULATOR' in os.environ:
                 emulator_platform = os.environ['PEBBLE_EMULATOR']
                 if emulator_platform not in pebble_platforms:
                     raise ToolError("PEBBLE_EMULATOR is set to '{}', which is not a valid platform "
                                     "(pick from {})".format(emulator_platform, ', '.join(pebble_platforms)))
                 emulator_sdk = os.environ.get('PEBBLE_EMULATOR_VERSION', sdk_version())
             else:
                 for platform, sdks in get_all_emulator_info().items():
                     for sdk in sdks:
                         if ManagedEmulatorTransport.is_emulator_alive(platform, sdk):
                             running.append((platform, sdk))
                 if len(running) == 1:
                     emulator_platform, emulator_sdk = running[0]
                 elif len(running) > 1:
                     raise ToolError("Multiple emulators are running; you must specify which to use.")
             if emulator_platform is not None:
                 return self._connect_emulator(emulator_platform, emulator_sdk)
     raise ToolError("No pebble connection specified.")
예제 #7
0
 def _connect(self, args):
     self._set_debugging(args.v)
     if getattr(args, 'phone', None):
         return self._connect_phone(args.phone)
     elif getattr(args, 'qemu', None):
         return self._connect_qemu(args.qemu)
     elif getattr(args, 'emulator', None):
         return self._connect_emulator(args.emulator)
     elif getattr(args, 'cloudpebble', None):
         return self._connect_cloudpebble()
     elif getattr(args, 'serial', None):
         return self._connect_serial(args.serial)
     else:
         if 'phone' in self.valid_connections and 'PEBBLE_PHONE' in os.environ:
             return self._connect_phone(os.environ['PEBBLE_PHONE'])
         elif 'qemu' in self.valid_connections and 'PEBBLE_QEMU' in os.environ:
             return self._connect_qemu(os.environ['PEBBLE_QEMU'])
         elif 'emulator' in self.valid_connections and 'PEBBLE_EMULATOR' in os.environ:
             platform = os.environ['PEBBLE_EMULATOR']
             if platform not in pebble_platforms:
                 raise ToolError("PEBBLE_EMULATOR is set to '{}', which is not a valid platform "
                                 "(pick from {})".format(platform, ', '.join(pebble_platforms)))
             return self._connect_emulator(platform)
         elif 'cloudpebble' in self.valid_connections and os.environ.get('PEBBLE_CLOUDPEBBLE', False):
             return self._connect_cloudpebble()
         elif 'serial' in self.valid_connections and 'PEBBLE_BT_SERIAL' in os.environ:
             return self._connect_serial(os.environ['PEBBLE_BT_SERIAL'])
         elif 'emulator' in self.valid_connections:
             running = []
             for platform in pebble_platforms:
                 if ManagedEmulatorTransport.is_platform_alive(platform):
                     running.append(platform)
             if len(running) == 1:
                 return self._connect_emulator(running[0])
             elif len(running) > 1:
                 raise ToolError("Multiple emulators are running; you must specify which to use.")
     raise ToolError("No pebble connection specified.")