Esempio n. 1
0
    def Run(self, arg_line):
        """Sets device info such as serial number."""
        args = self.arg_parser.ParseLine(arg_line)
        if args.set_serial:
            self.console.SetSerials(args.set_serial.split(","))
            logging.info("serials: %s", self.console._serials)
        if args.update:
            if args.host is None:
                if len(self.console._hosts) > 1:
                    raise ConsoleArgumentError("More than one host.")
                args.host = 0
            host = self.console._hosts[args.host]

            if args.suppress_lock_warning:
                if (type(args.suppress_lock_warning) != str
                        or args.suppress_lock_warning.lower() == "true"):
                    suppress_lock_warning = True
                else:
                    suppress_lock_warning = False

            if args.update == "single":
                self.UpdateDevice(args.server_type, host, args.lease,
                                  suppress_lock_warning)
            elif args.update == "start":
                if args.interval <= 0:
                    raise ConsoleArgumentError(
                        "update interval must be positive")
                # do not allow user to create new
                # thread if one is currently running
                if self.update_thread is not None and not hasattr(
                        self.update_thread, 'keep_running'):
                    logging.warning('device update already running. '
                                    'run device --update stop first.')
                    return
                self.update_thread = threading.Thread(
                    target=self.UpdateDeviceRepeat,
                    args=(
                        args.server_type,
                        host,
                        args.lease,
                        args.interval,
                        suppress_lock_warning,
                    ))
                self.update_thread.daemon = True
                self.update_thread.start()
            elif args.update == "stop":
                self.update_thread.keep_running = False
Esempio n. 2
0
 def Run(self, arg_line):
     """Makes a host lease command tasks from TFC."""
     args = self.arg_parser.ParseLine(arg_line)
     if args.host is None:
         if len(self.console._hosts) > 1:
             raise ConsoleArgumentError("More than one hosts.")
         args.host = 0
     tasks = self.console._hosts[args.host].LeaseCommandTasks()
     self._PrintTasks(tasks)
Esempio n. 3
0
 def Run(self, arg_line):
     """Updates build info."""
     args = self.arg_parser.ParseLine(arg_line)
     if args.update == "single":
         self.UpdateBuild(args.account_id, args.branch, args.target,
                          args.artifact_type, args.method,
                          args.userinfo_file, args.noauth_local_webserver,
                          args.verify_signed_build)
     elif args.update == "list":
         logging.info("Running build update sessions:")
         for id in self.build_thread:
             logging.info("  ID %d", id)
     elif args.update == "start":
         if args.interval <= 0:
             raise ConsoleArgumentError("update interval must be positive")
         # do not allow user to create new
         # thread if one is currently running
         if args.id is None:
             if not self.build_thread:
                 args.id = 1
             else:
                 args.id = max(self.build_thread) + 1
         else:
             args.id = int(args.id)
         if args.id in self.build_thread and not hasattr(
                 self.build_thread[args.id], 'keep_running'):
             logging.warning(
                 'build update (session ID: %s) already running. '
                 'run build --update stop first.', args.id)
             return
         self.build_thread[args.id] = threading.Thread(
             target=self.UpdateBuildLoop,
             args=(
                 args.account_id,
                 args.branch,
                 args.target,
                 args.artifact_type,
                 args.method,
                 args.userinfo_file,
                 args.noauth_local_webserver,
                 args.interval,
                 args.verify_signed_build,
             ))
         self.build_thread[args.id].daemon = True
         self.build_thread[args.id].start()
     elif args.update == "stop":
         if args.id is None:
             logging.error("--id must be set for stop")
         else:
             self.build_thread[int(args.id)].keep_running = False
Esempio n. 4
0
 def Run(self, arg_line):
     """Updates global config."""
     args = self.arg_parser.ParseLine(arg_line)
     if args.update == "single":
         self.UpdateConfig(args.account_id, args.branch, args.target,
                           args.config_type, args.method)
     elif args.update == "list":
         logging.info("Running config update sessions:")
         for id in self.schedule_thread:
             logging.info("  ID %d", id)
     elif args.update == "start":
         if args.interval <= 0:
             raise ConsoleArgumentError("update interval must be positive")
         # do not allow user to create new
         # thread if one is currently running
         if args.id is None:
             if not self.schedule_thread:
                 args.id = 1
             else:
                 args.id = max(self.schedule_thread) + 1
         else:
             args.id = int(args.id)
         if args.id in self.schedule_thread and not hasattr(
                 self.schedule_thread[args.id], 'keep_running'):
             logging.warning(
                 'config update already running. '
                 'run config --update=stop --id=%s first.', args.id)
             return
         self.schedule_thread[args.id] = threading.Thread(
             target=self.UpdateConfigLoop,
             args=(
                 args.account_id,
                 args.branch,
                 args.target,
                 args.config_type,
                 args.method,
                 args.interval,
             ))
         self.schedule_thread[args.id].daemon = True
         self.schedule_thread[args.id].start()
     elif args.update == "stop":
         if args.id is None:
             logging.error("--id must be set for stop")
         else:
             self.schedule_thread[int(args.id)].keep_running = False