Prints code and state for VM.
511585
def print_code(vm, out=sys.stdout, ops_per_line=8, registers=True):
    """"""
    if registers:
        out.write("IP: %d\n" % vm.instruction_pointer)
        out.write("DS: %s\n" % str(vm.stack))
        out.write("RS: %s\n" % str(vm.return_stack))

    def to_str(op):
        if is_embedded_push(op):
            op = get_embedded_push_value(op)

        if isstring(op):
            return '"%s"' % repr(op)[1:-1]
        elif callable(op):
            return vm.lookup(op)
        else:
            return str(op)

    for addr, op in enumerate(vm.code):
        if (addr % ops_per_line) == 0 and (addr==0 or (addr+1) < len(vm.code)):
            if addr > 0:
                out.write("\n")
            out.write("%0*d  " % (max(4, len(str(len(vm.code)))), addr))
        out.write("%s " % to_str(op))
    out.write("\n")
952151
async def manage(self):
        
        self._vms = await self.iaas.list_vms(self.name)

        vms_stat = Counter([vm.get_state() for vm in self._vms])
        missing = self.count - len(self._vms) if len(self._vms) < self.count else 0
        logging.info(
            'VMs Status: %s expected, %s in iaas, %s running, %s nearby shutdown, %s pending, %s after time shutdown, '
            '%s terminated, %s error, %s unknown, %s missing',
            self.count, len(self._vms), vms_stat[VmState.RUNNING.value], vms_stat[VmState.NEARBY_SHUTDOWN.value],
            vms_stat[VmState.PENDING.value], vms_stat[VmState.AFTER_TIME_SHUTDOWN.value],
            vms_stat[VmState.TERMINATED.value], vms_stat[VmState.ERROR.value], vms_stat[VmState.UNKNOWN.value], missing, extra=self._extra
        )
        for vm in self._vms:
            if vm.is_dead():
                logging.info("Terminate %s", vm, extra=self._extra)
                await vm.terminate()
                self.terminated += 1
        to_create = self.count - (len(self._vms) - self.terminated - vms_stat[VmState.NEARBY_SHUTDOWN.value])
        to_create = to_create if to_create > 0 else 0
        logging.debug("Create %s Vm", to_create, extra=self._extra)
        await self._create_vms(to_create)
        await self._healthcheck(self._vms)
        logging.info(
            'VMs Status update: %s terminated, %s terminated by healthcheck, %s created, %s failed healthcheck',
            self.terminated, self.healthcheck_terminated, to_create, len(self.runtime.failed_checks),
            extra=self._extra
        )
685149
def vmstat(stat):
    
    out = subprocess.check_output(["vmstat", "-s"])
    stat = stat.encode("ascii")
    for line in out.split(b"\n"):
        line = line.strip()
        if stat in line:
            return int(line.split(b" ")[0])
    raise ValueError("Can't find {} in 'vmstat' output.".format(stat))
1113644
def do_status(self, _):
        '''  '''
        server_status = self.server.is_server_running()
        if server_status == 'yes':
            print 'Server: ' + colorize('currently online', 'green')
        elif server_status == 'no':
            print 'Server: ' + colorize('currently offline', 'red')
        elif server_status == 'maybe':
            print 'Server: ' + colorize('status unknown', 'yellow')
        elif server_status == 'blocked':
            print 'Server: ' + colorize('blocked', 'red')
915780
def _main():
    """"""
    print('Platform: "%s"' % get_platform())
    print('Python version: "%s"' % get_python_version())
    print('Current installation scheme: "%s"' % _get_default_scheme())
    print()
    _print_dict('Paths', get_paths())
    print()
    _print_dict('Variables', get_config_vars())
92516
def compile(self):
        """"""
        result = TEMPLATE
        result += 'machine = Machine(' + repr(self.alphabet) + ')\n'

        for state in self.states:
            repr_state = state[0]
            for rule in self.states[state]:
                repr_state += ' ' + (','.join(rule) if rule is not None else '-')

            result += ("machine.add_state({repr_state})\n".format(repr_state=repr(repr_state)))

        result += "for line in stdin:\n"
        result += "    print(machine.execute(line))"
        return result
1058840
def print_debug(self, msg):
        """"""
        assert isinstance(msg, bytes)
        state = STATE_NAMES[self.state].encode()
        console_output(b'[dbg] ' + self.display_name.encode() + b'[' + state +
                       b']: ' + msg + b'\n')
1217511
def pretty_print_device(device):
    """"""
    logging.info('Device Instance ID: %s' % device['id'])
    if 'nickname' in device:
        logging.info('    Nickname: %s' % device['nickname'])
    if 'modelId' in device:
        logging.info('    Model: %s' % device['modelId'])
    logging.info('')
1219988
def show(self, resolve_mac=True):
        """"""

        print("%s  %s  %s  %s" % ("INDEX".ljust(5), "IFACE".ljust(35), "IP".ljust(15), "MAC"))
        for iface_name in sorted(self.data.keys()):
            dev = self.data[iface_name]
            mac = dev.mac
            if resolve_mac and iface_name != LOOPBACK_NAME:
                mac = conf.manufdb._resolve_MAC(mac)
            print("%s  %s  %s  %s" % (str(dev.win_index).ljust(5), str(dev.name).ljust(35), str(dev.ip).ljust(15), mac)     )
462277
def print_app_info(out=sys.stderr):
    """"""
    print("System info:", file=out)
    print(configuration.App, file=out)
    print("Python %(version)s on %(platform)s" %
                    {"version": sys.version, "platform": sys.platform}, file=out)
    stime = strtime(time.time())
    print("Local time:", stime, file=out)
    print("sys.argv", sys.argv, file=out)
1119323
def update(cls, id, memory, cores, console, password, background,
               max_memory):
        """"""
        if not background and not cls.intty():
            background = True

        vm_params = {}

        if memory:
            vm_params['memory'] = memory

        if cores:
            vm_params['cores'] = cores

        if console:
            vm_params['console'] = console

        if password:
            vm_params['password'] = password

        if max_memory:
            vm_params['vm_max_memory'] = max_memory

        result = cls.call('hosting.vm.update', cls.usable_id(id), vm_params)
        if background:
            return result

        # interactive mode, run a progress bar
        cls.echo('Updating your Virtual Machine %s.' % id)
        cls.display_progress(result)
898672
def vtmlprint(*values, plain=None, strict=None, **options):
    
    print(*[vtmlrender(x, plain=plain, strict=strict) for x in values],
          **options)
304817
private function printModuleState(IO $io, $ModuleState)
    {
        switch ($ModuleState) {
            case ModuleState::ENABLED:
                $io->writeLine('The following modules are currently enabled:');
                $io->writeLine('');

                return;
            case ModuleState::NOT_FOUND:
                $io->writeLine('The following modules could not be found:');
                $io->writeLine(' (use "puli module --clean" to remove)');
                $io->writeLine('');

                return;
            case ModuleState::NOT_LOADABLE:
                $io->writeLine('The following modules could not be loaded:');
                $io->writeLine('');

                return;
        }
    }
770930
def print_details(srv):
    
    name = srv.service_type
    box = "=" * 79
    print("{0}\n|{1:^77}|\n{0}\n".format(box, name))
    for action in srv.iter_actions():
        print(action.name)
        print("~" * len(action.name))
        print("\n  Input")
        for arg in action.in_args:
            print("    ", arg)
        print("\n  Output")
        for arg in action.out_args:
            print("    ", arg)

        print("\n\n")
836254
def _get_state(self):
        

        result = yield from self._execute("showvminfo", [self._vmname, "--machinereadable"])
        for info in result.splitlines():
            if '=' in info:
                name, value = info.split('=', 1)
                if name == "VMState":
                    return value.strip('"')
        return "unknown"
62106
def cprint(color, prefix, message):
        
        message = message or ""
        prefix = prefix or ""
        print((Console.theme[color] +
               prefix +
               message +
               Console.theme['ENDC']))
436314
def print_status(self, roles=None, state_filter="running"):
    
    if not roles:
      for instance in self._get_instances(self._get_cluster_group_name(),
                                          state_filter):
        self._print_instance("", instance)
    else:
      for role in roles:
        for instance in self._get_instances(self._group_name_for_role(role),
                                            state_filter):
          self._print_instance(role, instance)