def getInterfaceIPAddress(interface=None): """ ... :param interface: :type interface: str :return: :rtype: str """ # _cmd_ = "ifconfig" # _cmd_ = "ifconfig {}".format(interface) # common.trace(value=_cmd_) return \ pexpect.run \ ( common.getShellCommand\ ( "ifconfig {iface} | grep 'inet addr' | cut -d: -f2 | cut -d' ' -f1".format\ ( iface=\ Default.NETWORK_ETHERNET_INTERFACE if common.isNull(interface) else interface ) ) ) \ .decode().strip(os.linesep)
def expectSendPassword(spawn, password, pattern=None): """ ... :param spawn: :type spawn: SpawnBase :param password: :type password: str :param pattern: :type pattern: str :return: :rtype: """ # jpyzCommon.trace(descriptor="len(password)", value=len(password)) if jpyzCommon.isNull(pattern): spawn.waitnoecho() else: index = spawn.expect([pattern, pexpect.EOF, pexpect.TIMEOUT]) bytes = spawn.sendline(password) # index = spawn.expect([pexpect.EOF, pexpect.TIMEOUT]) # return index # jpyzCommon.trace(descriptor="bytes", value=bytes) # return not spawn.waitnoecho(timeout=5) return bytes
def getWindowsRootPath_00(drive=None): return \ "{}{}".format\ ( Default.WINDOWS_ROOT_DRIVE_LETTER if common.isNull(drive) else drive , Constant.COLON )
def getPrompt(self): """ ... :return: :rtype: str """ _prompt = self.prompt return _prompt if common.isNull(_prompt) else _prompt[0]
def doPrompt(self): """ ... :return: :rtype: bool """ # return self._prompt return self.p or not common.isNull(self.prompt)
def _getPlatformPath(platformPathFunctionMap, system, default): return \ platformPathFunctionMap.get \ ( platform.system() if common.isNullOrEmpty(system) else system , default if inspect.isfunction(default) else lambda value: value if common.isNull(value) else str(value) )()
def _getNamespaceArgs(arg): """ ... :param arg: :type arg: list :return: :rtype: tuple """ parser, namespace = _parseArgs(arg[1:], _ArgNamespace()) args = _getArgs(namespace.args) if common.isNull(args): parser.print_help() parser.exit() else: args = namespace.getArgs(args) return args, namespace
def _getNamespaceArgs_00(arg): """ ... :param arg: :type arg: list :return: :rtype: tuple """ parser, namespace = _parseArgs(arg[1:], _ArgNamespace()) args = _getArgs(namespace.args) if common.isNull(args): parser.print_help() parser.exit() else: args = [(*argt, namespace.removeOnly()) for argt in args] return args, namespace