예제 #1
0
    def run(self, args):
        # e.g. needed to de-sym crashes on `pebble logs`
        self.add_arm_tools_to_path(args)

        # Only use the environment variables as defaults if no command-line arguments were specified
        # ...allowing you to leave the environment var(s) set at all times
        args_not_provided = False
        if not args.phone and not args.pebble_id and not args.qemu and not args.emulator:
            args_not_provided = True
            args.phone = os.getenv(PEBBLE_PHONE_ENVVAR)
            args.pebble_id = os.getenv(PEBBLE_BTID_ENVVAR)
            args.qemu = os.getenv(PEBBLE_QEMU_ENVVAR)
            args.emulator = os.getenv(PEBBLE_PLATFORM_ENVVAR)

        account = get_default_account(self.get_persistent_dir())

        if not account.is_logged_in():
            logging.warning(
                "You are not logged in with your Pebble Account and will not be able to receive remote pins in the emulator. Please run 'pebble login' to connect your Pebble account."
            )

        num_args = bool(args.phone) + bool(args.pebble_id) + bool(
            args.qemu) + bool(args.emulator)
        if num_args > 1:
            raise ConfigurationException(
                "You must specify only one method to connect to the watch "
                " - either Developer Connection (with --phone/%s), direct via Bluetooth (with "
                "--pebble_id/%s), via QEMU (with --qemu/%s) or via emulator (with --emulator%s"
                % (PEBBLE_PHONE_ENVVAR, PEBBLE_BTID_ENVVAR, PEBBLE_QEMU_ENVVAR,
                   PEBBLE_PLATFORM_ENVVAR))

        self.pebble = libpebble.Pebble(args.pebble_id)
        self.pebble.set_print_pbl_logs(args.verbose)
        self.virtual_pebble = False

        if args.phone:
            self.pebble.connect_via_websocket(args.phone)
        elif args.pebble_id:
            self.pebble.connect_via_lightblue(pair_first=args.pair)
        elif args.qemu:
            self.virtual_pebble = True
            self.pebble.connect_via_qemu(args.qemu)
        else:
            token = account.get_access_token() if account.is_logged_in(
            ) else None
            emulator = PebbleEmulator(self.sdk_path(args), args.debug,
                                      args.debug_phonesim,
                                      self.get_persistent_dir(), token,
                                      args.emulator)
            if args_not_provided is True:
                emulator.start(use_running_platform=True)
            else:
                emulator.start(use_running_platform=False)
            self.virtual_pebble = True

            self.pebble.connect_via_websocket(emulator.phonesim_address(),
                                              emulator.phonesim_port())
            self.pebble.set_time_utc(int(time.time()))
    def run(self, args):
        # e.g. needed to de-sym crashes on `pebble logs`
        self.add_arm_tools_to_path(args)

        # Only use the environment variables as defaults if no command-line arguments were specified
        # ...allowing you to leave the environment var(s) set at all times
        args_not_provided = False
        if not args.phone and not args.pebble_id and not args.qemu and not args.emulator:
            args_not_provided = True
            args.phone = os.getenv(PEBBLE_PHONE_ENVVAR)
            args.pebble_id = os.getenv(PEBBLE_BTID_ENVVAR)
            args.qemu = os.getenv(PEBBLE_QEMU_ENVVAR)
            args.emulator = os.getenv(PEBBLE_PLATFORM_ENVVAR)

        account = get_default_account(self.get_persistent_dir())

        if not account.is_logged_in():
            logging.warning("You are not logged in with your Pebble Account and will not be able to receive remote pins in the emulator. Please run 'pebble login' to connect your Pebble account.")

        num_args = bool(args.phone) + bool(args.pebble_id) + bool(args.qemu) + bool(args.emulator)
        if num_args > 1:
            raise ConfigurationException("You must specify only one method to connect to the watch "
                 " - either Developer Connection (with --phone/%s), direct via Bluetooth (with "
                 "--pebble_id/%s), via QEMU (with --qemu/%s) or via emulator (with --emulator%s" 
                 % (PEBBLE_PHONE_ENVVAR, PEBBLE_BTID_ENVVAR, PEBBLE_QEMU_ENVVAR, PEBBLE_PLATFORM_ENVVAR))

        self.pebble = libpebble.Pebble(args.pebble_id)
        self.pebble.set_print_pbl_logs(args.verbose)
        self.virtual_pebble = False

        if args.phone:
            self.pebble.connect_via_websocket(args.phone)
        elif args.pebble_id:
            self.pebble.connect_via_lightblue(pair_first=args.pair)
        elif args.qemu:
            self.virtual_pebble = True
            self.pebble.connect_via_qemu(args.qemu)
        else:
            token = account.get_access_token() if account.is_logged_in() else None
            emulator = PebbleEmulator(self.sdk_path(args), args.debug, args.debug_phonesim, self.get_persistent_dir(), token, args.emulator)
            if args_not_provided is True:
                emulator.start(use_running_platform=True)
            else:
                emulator.start(use_running_platform=False)
            self.virtual_pebble = True

            self.pebble.connect_via_websocket(emulator.phonesim_address(), emulator.phonesim_port())
            self.pebble.set_time_utc(int(time.time()))
 def run(self, args):
     account = get_default_account(LibPebbleCommand.get_persistent_dir())
     account.login(args)
예제 #4
0
 def run(self, args):
     account = get_default_account(LibPebbleCommand.get_persistent_dir())
     account.login(args)