def getVsConfigPathFromCmdline(commandline): r'@types: str->str' # get '-cfg' parameter value args = cmdlineutils.splitArgs(commandline)[1:] options = cmdlineutils.Options() cfgOption = cmdlineutils.Option('cfg', hasArg=True) options.addOption(cfgOption) commandLine = cmdlineutils.parseCommandLine(options, args) if commandLine.hasOption('cfg'): return commandLine.getOptionValue('cfg') else: logger.warn("Config file path is not specified as parameter")
def parseNsOptionFromCommandline(commandline): '''Parses CMS host:port the current server is registered with @types: str -> str or None @tito: {r'"E:\Business Objects\BusinessObjects Enterprise 12.0\win32_x86\crcache.exe" -loggingPath "E:/Business Objects/BusinessObjects Enterprise 12.0/logging/" -cache -nops -documentType CrystalEnterprise.Report -fg -restart -name host123.CrystalReportsCacheServer -pidfile "F:\Business Objects\BusinessObjects Enterprise 12.0\serverpids\host123_host123.CrystalReportsCacheServer.pid" -ns host123.d.p.rp:6400' : NsOption('host123.d.p.rp', 6400) } ''' args = cmdlineutils.splitArgs(commandline)[1:] options = cmdlineutils.Options() nsOption = cmdlineutils.Option('ns', hasArg=True) options.addOption(nsOption) try: commandLine = cmdlineutils.parseCommandLine(options, args) if commandLine.hasOption("ns"): nsOption = commandLine.getOptionValue("ns") m = re.match(r'(.*):(\d+)', nsOption) if m: return NsOption(m.group(1).strip(), int(m.group(2).strip())) else: logger.debug('Failed to match ns option: %s' % nsOption) except: logger.debugException('Failed to parse commandline: %s' % (commandline))