Runs the firmware command.

        Args:
          self (FirmwareCommand): the ``FirmwareCommand`` instance
          args (Namespace): arguments to parse

        Returns:
          ``None``
333741
def run(self, args):
        
        jlink = self.create_jlink(args)
        if args.downgrade:
            if not jlink.firmware_newer():
                print('DLL firmware is not older than J-Link firmware.')
            else:
                jlink.invalidate_firmware()

                try:
                    # Change to the firmware of the connected DLL.
                    jlink.update_firmware()
                except pylink.JLinkException as e:
                    # On J-Link versions < 5.0.0, an exception will be thrown as
                    # the connection will be lost, so we have to re-establish.
                    jlink = self.create_jlink(args)

                print('Firmware Downgraded: %s' % jlink.firmware_version)
        elif args.upgrade:
            if not jlink.firmware_outdated():
                print('DLL firmware is not newer than J-Link firmware.')
            else:
                try:
                    # Upgrade the firmware.
                    jlink.update_firmware()
                except pylink.JLinkException as e:
                    # On J-Link versions < 5.0.0, an exception will be thrown as
                    # the connection will be lost, so we have to re-establish.
                    jlink = self.create_jlink(args)
                print('Firmware Updated: %s' % jlink.firmware_version)

        return None
481580
async def _update_firmware(filename, loop):
    
    try:
        from opentrons import robot
    except ModuleNotFoundError:
        res = "Unable to find module `opentrons`--not updating firmware"
        rc = 1
        log.error(res)
    else:
        # ensure there is a reference to the port
        if not robot.is_connected():
            robot.connect()

        # get port name
        port = str(robot._driver.port)
        # set smoothieware into programming mode
        robot._driver._smoothie_programming_mode()
        # close the port so other application can access it
        robot._driver._connection.close()

        # run lpc21isp, THIS WILL TAKE AROUND 1 MINUTE TO COMPLETE
        update_cmd = 'lpc21isp -wipe -donotstart {0} {1} {2} 12000'.format(
            filename, port, robot.config.serial_speed)
        proc = await asyncio.create_subprocess_shell(
            update_cmd,
            stdout=asyncio.subprocess.PIPE,
            loop=loop)
        rd = await proc.stdout.read()
        res = rd.decode().strip()
        await proc.communicate()
        rc = proc.returncode

        if rc == 0:
            # re-open the port
            robot._driver._connection.open()
            # reset smoothieware
            robot._driver._smoothie_reset()
            # run setup gcodes
            robot._driver._setup()

    return res, rc
222720
def run_command(self, cmd, argv):
        
        try:
            Command = self.get_command_class(cmd)
        except CommandError, e:
            self.stderr.write(str(e) + '\n')
            self.show_help()
            sys.exit(-1)
        command = Command(stdout=self.stdout, stderr=self.stderr)
        command.run_from_argv(argv)
305687
def run(self):
        
        try:
            if self.command == "pxer":
                self.ipmi_method(command="pxe")
                if self.status == 0 or self.status == None:
                    self.command = "reboot"
                else:
                    return
                    
            self.ipmi_method(self.command)
        
        except Exception as e:
            self.error = str(e)
573639
def command(self, cmd, *args):
        
        self._serial_interface.command(cmd)
        if len(args) > 0:
            self._serial_interface.data(list(args))
815639
def run(argv)
      dup_argv = argv.dup
      begin
        @opt_parse.order! dup_argv
      rescue OptionParser::InvalidOption => e
      end

      command_to_run = dup_argv.join " "

      # Run on all devices
      if @options[:index]
        devices = get_connected_devices
        device = devices[@options[:index]]
        if device.nil?
          raise "Requested device #{@options[:index]} but only have #{devices.length} devices connected."
        end

        run_adb_command command_to_run, device

        return
      end

      # Run on a specific device
      if @options[:name]
        if !@config.key? "aliases"
          raise "No aliases defined in your ~/nadb.config file"
        end

        device = @config["aliases"][@options[:name]]
        if device.nil?
          raise "Requested device not found in aliases"
        end
        
        run_adb_command command_to_run, device

        return
      end

      # Run on all connected devices
      if @options[:all]
        devices = get_connected_devices
        devices.each do |device|
          run_adb_command command_to_run, device
        end
        return
      end

      # Just pass everything to adb as we got it
      passthrough_command = argv.join " "
      run_adb_command passthrough_command
    end
302950
def frame_from_firmware(self, firmware):
        ''''''
        # see Tools/scripts/generate-manifest for this map:
        frame_to_mavlink_dict = {
            "quad": "QUADROTOR",
            "hexa": "HEXAROTOR",
            "y6": "ARDUPILOT_Y6",
            "tri": "TRICOPTER",
            "octa": "OCTOROTOR",
            "octa-quad": "ARDUPILOT_OCTAQUAD",
            "heli": "HELICOPTER",
            "Plane": "FIXED_WING",
            "Tracker": "ANTENNA_TRACKER",
            "Rover": "GROUND_ROVER",
            "PX4IO": "ARDUPILOT_PX4IO",
        }
        mavlink_to_frame_dict = { v : k  for k,v in frame_to_mavlink_dict.items() }
        x = firmware["mav-type"]
        if firmware["mav-autopilot"] != "ARDUPILOTMEGA":
            return x
        if x in mavlink_to_frame_dict:
            return mavlink_to_frame_dict[x]

        return x
944966
def run(self, cmd):
        
        # TODO: can this be removed ?
        import __main__
        main_dict = __main__.__dict__
        return self.runctx(cmd, main_dict, main_dict)
1290503
def begin(self):
        
        # Assert CS pin low for a second for PN532 to be ready.
        self._gpio.set_low(self._cs)
        time.sleep(1.0)
        # Call GetFirmwareVersion to sync up with the PN532.  This might not be
        # required but is done in the Arduino library and kept for consistency.
        self.get_firmware_version()
        self._gpio.set_high(self._cs)
1374004
def rerun(version="3.7.0"):
    
    from commandlib import Command

    Command(DIR.gen.joinpath("py{0}".format(version), "bin", "python"))(
        DIR.gen.joinpath("state", "examplepythoncode.py")
    ).in_dir(DIR.gen.joinpath("state")).run()
1130857
def respond_fw_config(self, msg):
        """"""
        (req_fw_type,
         req_fw_ver,
         req_blocks,
         req_crc,
         bloader_ver) = fw_hex_to_int(msg.payload, 5)
        _LOGGER.debug(
            'Received firmware config request with firmware type %s, '
            'firmware version %s, %s blocks, CRC %s, bootloader %s',
            req_fw_type, req_fw_ver, req_blocks, req_crc, bloader_ver)
        fw_type, fw_ver, fware = self._get_fw(
            msg, (self.requested, self.unstarted))
        if fware is None:
            return None
        if fw_type != req_fw_type:
            _LOGGER.warning(
                'Firmware type %s of update is not identical to existing '
                'firmware type %s for node %s',
                fw_type, req_fw_type, msg.node_id)
        _LOGGER.info(
            'Updating node %s to firmware type %s version %s from type %s '
            'version %s', msg.node_id, fw_type, fw_ver, req_fw_type,
            req_fw_ver)
        msg = msg.copy(sub_type=self._const.Stream.ST_FIRMWARE_CONFIG_RESPONSE)
        msg.payload = fw_int_to_hex(
            fw_type, fw_ver, fware['blocks'], fware['crc'])
        return msg
888161
def get_firmware(self):
        
        uri = "{}/firmware".format(self.data["uri"])
        return self._helper.do_get(uri)
592571
def run(command, **kwargs):
  
  print command
  p = Popen(shlex.split(command), **kwargs)
  p.wait()

  return p.returncode
1197244
def run_local(self, commands):
        
        process = subprocess.Popen(
            commands.get('cli_command'),
            shell=self.shell,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
        )

        out, err = process.communicate()

        # display app output
        self.run_display_app_output(out)
        self.run_display_app_errors(err)

        # Exit Code
        return self.run_exit_code(process.returncode)
991210
def run(self):
        
        args = self._process_flags()

        self.todofile = TodoFile.TodoFile(config().todotxt())
        self.todolist = TodoList.TodoList(self.todofile.read())

        try:
            (subcommand, args) = get_subcommand(args)
        except ConfigError as ce:
            error('Error: ' + str(ce) + '. Check your aliases configuration')
            sys.exit(1)

        if subcommand is None:
            CLIApplicationBase._usage()

        if self._execute(subcommand, args) == False:
            sys.exit(1)
        else:
            self._post_execute()
57819
def execute(self):
        
        # Ensure that we have commands registered
        if not self.commands or self._parser is None:
            raise NotImplementedError(
                "No commands registered with this program!"
            )

        # Handle input from the command line
        args = self.parser.parse_args()                # Parse the arguments

        try:

            handle_default_args(args)                  # Handle the default args

            if not hasattr(args, 'func'):              # Handle no subcommands
                self.parser.print_help()
                self.exit(0)

            msg = args.func(args)                      # Call the default function
            msg = "{}\n".format(msg) if msg else ''    # Format the message
            self.exit(0, msg)                          # Exit cleanly with message

        except Exception as e:
            if hasattr(args, 'traceback') and args.traceback:
                traceback.print_exc()

            msg = color.format(str(e), color.RED)
            self.exit(1, msg)
1316316
def run_command(self, command):
        
        self.display = DISPLAYS["stdout"]
        self.conf["pagesize"] = 0
        self.onecmd(command)