def cmnd( self, interactive=False, # Can also be called non-interactively argsList=[], # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome cmndArgsSpecDict = self.cmndArgsSpec() if not self.cmndArgsValidate( effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome): return cmndOutcome ####+END: moduleDescription = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Description:* | ]] ** [[elisp:(org-cycle)][| ]] [Xref] :: *[Related/Xrefs:]* <<Xref-Here->> -- External Documents [[elisp:(org-cycle)][| ]] ** [[elisp:(org-cycle)][| ]] Model and Terminology :Overview: This module is part of BISOS and its primary documentation is in http://www.by-star.net/PLPC/180047 ** [End-Of-Description] """ moduleUsage = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Usage:* | ]] ** How-Tos: ** [End-Of-Usage] """ moduleStatus = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Status:* | ]] ** [[elisp:(org-cycle)][| ]] [Info] :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]] ** TODO [[elisp:(org-cycle)][| ]] Current :: Just getting started [[elisp:(org-cycle)][| ]] ** [End-Of-Status] """ cmndArgsSpec = { "0&-1": ['moduleDescription', 'moduleUsage', 'moduleStatus'] } cmndArgsValid = cmndArgsSpec["0&-1"] for each in effectiveArgsList: if each in cmndArgsValid: print(each) if interactive: #print( str( __doc__ ) ) # This is the Summary: from the top doc-string #version(interactive=True) exec("""print({})""".format(each)) return (format(str(__doc__) + moduleDescription))
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: #G = icm.IcmGlobalContext() #g_runArgs = G.icmRunArgsGet() # # Python Packages # pkgsList = canon_pythonPkgsSpec() for pkgName in pkgsList: # Not all packages ahve __version__ so this is not reliable #exec("import {pyModule}".format(pyModule=each)) #exec("print {pyModule}.__version__".format(pyModule=each)) installedVer = pythonPkg_versionGet(pkgName) installedLoc = pythonPkg_locationGet(pkgName) icm.ANN_write( "Python:: pkgName={pkgName} -- expectedVer={expectedVer} -- installedVer={installedVer} -- installedLoc={installedLoc}" .format( pkgName=pkgName, expectedVer=pkgsList[pkgName], installedVer=installedVer, installedLoc=installedLoc, )) # # Linux Packages # pkgsList = canon_linuxPkgsSpec() for pkgName in pkgsList: installedVer = linuxPkg_versionGet(pkgName) icm.ANN_write( "Linux:: pkgName={pkgName} -- expectedVer={expectedVer} -- installedVer={installedVer}" .format( pkgName=pkgName, expectedVer=pkgsList[pkgName], installedVer=installedVer, )) return cmndOutcome.set( opError=icm.OpError.Success, opResults=None, )
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() def menuItem(): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='little') def execLineEx(cmndStr): icm.ex_gExecMenuItem(execLine=cmndStr) logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() selectedPipPkg = "unisos.marme" icm.cmndExampleMenuChapter('*General Dev and Testing CMNDs*') cmndName = "unitTest" cmndArgs = "" cps = cpsInit() # cps['icmsPkgName'] = icmsPkgName menuItem() icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='full') icm.cmndExampleMenuChapter('*Input and Output Examples CMNDs*') cmndName = "outStreamsExamples" cmndArgs = "" cps = collections.OrderedDict() # cps['icmsPkgName'] = icmsPkgName icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='little') icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='full') icm.cmndExampleMenuChapter('*Other Than ICM Execution Line Examples*') execLineEx("""ls -l""") return (cmndOutcome)
def cmnd( self, interactive=False, # Can also be called non-interactively argsList=None, # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: moduleDescription = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Description:* | ]] ** [[elisp:(org-cycle)][| ]] [Xref] :: *[Related/Xrefs:]* <<Xref-Here->> -- External Documents [[elisp:(org-cycle)][| ]] ** [[elisp:(org-cycle)][| ]] Model and Terminology :Overview: *** See BISOS Documentation for ICM's model and terminology ** [End-Of-Description] """ moduleUsage = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Usage:* | ]] ** How-Tos: *** TODO Edit icmInfo to identify author, etc *** TODO Select ICM type in g_icmChars *** TODO Enhance g_argsExtraSpecify for your parameters *** TODO Add your Commands *** TODO Enhance Examples Cmnd ** [End-Of-Usage] """ moduleStatus = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Status:* | ]] ** [[elisp:(org-cycle)][| ]] [Info] :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]] ** TODO [[elisp:(org-cycle)][| ]] Current :: Just getting started [[elisp:(org-cycle)][| ]] ** [End-Of-Status] """ ####+BEGIN: bx:dblock:global:file-insert-cond :cond "./blee.el" :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/moduleOverview.py" cmndArgsSpec = { "0&-1": ['moduleDescription', 'moduleUsage', 'moduleStatus'] } cmndArgsValid = cmndArgsSpec["0&-1"] icm.unusedSuppressForEval(moduleDescription, moduleUsage, moduleStatus) for each in effectiveArgsList: if each in cmndArgsValid: if interactive: exec("""print({})""".format(each)) return (format(str(__doc__) + moduleDescription))
def cmnd(self, interactive=False, # Can also be called non-interactively argsList=[], # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate(callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome cmndArgsSpecDict = self.cmndArgsSpec() if not self.cmndArgsValidate(effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome): return cmndOutcome ####+END: moduleDescription=""" * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Description:* | ]] ** [[elisp:(org-cycle)][| ]] [Xref] :: *[Related/Xrefs:]* <<Xref-Here->> -- External Documents [[elisp:(org-cycle)][| ]] ** [[elisp:(org-cycle)][| ]] Model and Terminology :Overview: This module is part of BISOS and its primary documentation is in http://www.by-star.net/PLPC/180047 ** [End-Of-Description] """ moduleUsage=""" * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Usage:* | ]] ** How-Tos: ** [End-Of-Usage] """ moduleStatus=""" * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Status:* | ]] ** [[elisp:(org-cycle)][| ]] [Info] :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]] ** TODO [[elisp:(org-cycle)][| ]] Current :: Just getting started [[elisp:(org-cycle)][| ]] ** [End-Of-Status] """ ####+BEGIN: bx:dblock:global:file-insert-cond :cond "./blee.el" :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/moduleOverview.py" icm.unusedSuppressForEval(moduleUsage, moduleStatus) actions = self.cmndArgsGet("0&2", cmndArgsSpecDict, effectiveArgsList) if actions[0] == "all": cmndArgsSpec = cmndArgsSpecDict.argPositionFind("0&2") argChoices = cmndArgsSpec.argChoicesGet() argChoices.pop(0) actions = argChoices for each in actions: print each if interactive: #print( str( __doc__ ) ) # This is the Summary: from the top doc-string #version(interactive=True) exec("""print({})""".format(each)) return(format(str(__doc__)+moduleDescription))
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: # # cmndArgs are in the form of name=value to become additional vagrant env vars # cmnd = """\ echo "There are many different ways of running a bash command."; echo "Just running shRun.bash(cmnd) leaves it to -v 20 to enable stdout, stderr verbosity"; echo "Just running shRun.bash(cmnd) leaves it to --callTrackings monitor+ for input verbosity"; echo "Next we are adding a sleep to have a delay between cmnd echo and output"; sleep 5; echo "VAGRANT_VAGRANTFILE={vagrantFile} vagrant up"\ """.format(vagrantFile="someFileName") result = shRun.bash(cmnd) print("=========== Obtained Result: ==============") print(result.ok) print(result.stdout) print(result.stderr) cmnd = """\ echo "You can also specify your verbosity parameters directly."; echo "For example: shRun.bash(cmnd, hide=False, warn=True, echo=True)"; echo "These explicit specifications will not be overwritten with command line options";\ """ result = shRun.bash(cmnd, hide=False, warn=True, echo=True) cmnd = """\ dateTag=$(date) echo "Current time is: ${dateTag}" function funcName { echo "Inside of $0" return } funcName """ result = shRun.bash(cmnd) return cmndOutcome.set( opError=icm.OpError.Success, opResults=None, )
def cmnd( self, interactive=False, # Can also be called non-interactively argsList=None, # or Args-Input ): G = icm.IcmGlobalContext() cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: moduleDescription = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Description:* | ]] ** [[elisp:(org-cycle)][| ]] [Xref] :: *[Related/Xrefs:]* <<Xref-Here->> -- External Documents [[elisp:(org-cycle)][| ]] ** [[elisp:(org-cycle)][| ]] Model and Terminology :Overview: *** bxpRootXxFile -- /etc/bystarRoot, ~/.bystarRoot, /bystar *** bxpRoot -- Base For This Module *** bpb -- ByStar Platform Base, Location Of Relevant Parts (Bisos, blee, bsip *** bpd -- ByStar Platform Directory (Object), An instance of Class BxpBaseDir ** [End-Of-Description] """ moduleUsage = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Usage:* | ]] ** How-Tos: ** [End-Of-Usage] """ moduleStatus = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Status:* | ]] ** [[elisp:(org-cycle)][| ]] [Info] :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]] ** TODO [[elisp:(org-cycle)][| ]] Current :: Just getting started [[elisp:(org-cycle)][| ]] ** [End-Of-Status] """ ####+BEGIN: bx:dblock:global:file-insert-cond :cond "./blee.el" :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/moduleOverview.py" cmndArgsSpec = { "0&-1": ['moduleDescription', 'moduleUsage', 'moduleStatus'] } cmndArgsValid = cmndArgsSpec["0&-1"] icm.unusedSuppressForEval(moduleDescription, moduleUsage, moduleStatus) for each in effectiveArgsList: if each in cmndArgsValid: if interactive: exec("""print({})""".format(each)) return (format(str(__doc__) + moduleDescription))
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: first_aInst = pattern.sameInstance( ClsA, 'arg1', ) second_aInst = pattern.sameInstance( ClsA, 'arg1', ) first_other_aInst = pattern.sameInstance( ClsA, 'argA', ) third_aInst = pattern.sameInstance( ClsA, 'arg1', ) second_other_aInst = pattern.sameInstance( ClsA, 'argA', ) first_otherKw_aInst = pattern.sameInstance(ClsA, 'argA', kwArgOne='kwA') second_otherKw_aInst = pattern.sameInstance(ClsA, 'argA', kwArgOne='kwA') print( f"{first_aInst}\n{second_aInst}\n{first_other_aInst}\n{third_aInst}\n{second_other_aInst}\n{first_otherKw_aInst}\n{second_otherKw_aInst}" ) print(f"{third_aInst.oneArg} -- {third_aInst.kwArgOne}") print(f"{second_other_aInst.oneArg} -- {second_other_aInst.kwArgOne}") print( f"{first_otherKw_aInst.oneArg} -- {first_otherKw_aInst.kwArgOne}") #singeltonExA = pattern.sameInstance(SingleA) singeltonExA = pattern.singleton(SingleA) singeltonExB = pattern.singleton(SingleA) singeltonExA.param = 'a-editVal' print(f"{singeltonExB.param}") return cmndOutcome
def cmnd( self, interactive=False, # Can also be called non-interactively bpoId=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'bpoId': bpoId, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome bpoId = callParamsDict['bpoId'] ####+END: palsProfile = repoProfile.PalsRepo_Profile(bpoId) bpoFpsBaseInst = palsProfile.fps_baseMake() baseDomain = bpoFpsBaseInst.fps_getParam('baseDomain').parValueGet() bystarType = bpoFpsBaseInst.fps_getParam('bystarType').parValueGet() correspondingEntity = bpoFpsBaseInst.fps_getParam( 'correspondingEntity').parValueGet() icm.unusedSuppressForEval(bystarType, ) icm.unusedSuppressForEval(correspondingEntity, ) def get_bystarDomFormTld_plone(): """ *** First, we try to resolve *baseDomain*. If that works, baseDomain it is. Otherwise, we get the live target ipAddr. """ # liveParamsInst = pattern.sameInstance(baseLiveTargets.PalsBase_LiveParams, bpoId) # liveParamsFpInst = liveParamsInst.fps_baseMake() return ( "www.{baseDomain}".format(baseDomain=baseDomain) #liveParamsFpInst.fps_getParam('palsPlatformIpAddr').parValueGet() ) bystarDomFormTld_plone = get_bystarDomFormTld_plone() print(f"""\ cp_acctPrefix="" cp_acctNu="{bpoId}" bpoIdPasswdDecrypted="NOTYET" bystarDomFormTld_plone="{bystarDomFormTld_plone}" cp_acctMainBaseDomain="{baseDomain}" cp_acctUid="NOTYET" """) return cmndOutcome.set( opError=icm.OpError.Success, # type: ignore opResults=None, )
def cmnd( self, interactive=False, # Can also be called non-interactively bpoId=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'bpoId': bpoId, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome bpoId = callParamsDict['bpoId'] ####+END: def cpsInit(): return collections.OrderedDict() #def menuItem(verbosity): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity=verbosity) # 'little' or 'none' def extMenuItem(verbosity): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, icmName=icmExName, verbosity=verbosity) # 'little' or 'none' oneBpo = "pmi_ByD-100001" if bpoId: oneBpo = bpoId logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() bpo.examples_bpo_basicAccess(oneBpo) baseLiveTargets.examples_baseLiveTargets().cmnd(bpoId=oneBpo, ) icm.cmndExampleMenuChapter('*Related ICMs*') icmExName = "palsRepoLiveParams.py" cmndName = "examples" cmndArgs = "" cps = cpsInit() cps['bpoId'] = oneBpo extMenuItem(verbosity='none') return (cmndOutcome)
def cmnd( self, interactive=False, # Can also be called non-interactively sessionType=None, # or Cmnd-Input nuOfDisplays=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'sessionType': sessionType, 'nuOfDisplays': nuOfDisplays, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome sessionType = callParamsDict['sessionType'] nuOfDisplays = callParamsDict['nuOfDisplays'] ####+END: if not nuOfDisplays: outcome = nuOfDisplaysGet().cmnd() if outcome.isProblematic(): return (icm.EH_badOutcome(outcome)) nuOfDisplays = outcome.result cwd = os.getcwd() if sessionType == "narratedSession": audiosystemStr = """Monitor of Built-in Audio Analog Stereo""" microphoneStr = """None""" elif sessionType == "liveSession": audiosystemStr = """None""" microphoneStr = """Yeti Stereo Microphone Analog Stereo""" else: icm.EH_usageError("Bad sessionType -- {}".format(sessionType)) displaysStr = screenstudioRcTemplate(nuOfDisplays, ) if displaysStr: resStr = displayStr.format( audiosystemStr=audiosystemStr, microphoneStr=microphoneStr, outputvideofolderStr=cwd, ) else: resStr = "" # NOTYET, Is This An Error? if interactive: print(resStr) return cmndOutcome.set(opError=icm.OpError.Success, opResults=resStr)
def cmnd( self, interactive=False, # Can also be called non-interactively argsList=None, # or Args-Input ): G = icm.IcmGlobalContext() cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: moduleDescription = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Description:* | ]] ** [[elisp:(org-cycle)][| ]] [Xref] :: *[Related/Xrefs:]* <<Xref-Here->> -- External Documents [[elisp:(org-cycle)][| ]] ** [[elisp:(org-cycle)][| ]] Model and Terminology :Overview: This module is part of BISOS and its primary documentation is in http://www.by-star.net/PLPC/180047 ** [End-Of-Description] """ moduleUsage = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Usage:* | ]] ** How-Tos: ** [End-Of-Usage] """ moduleStatus = """ * [[elisp:(org-show-subtree)][|=]] [[elisp:(org-cycle)][| *Status:* | ]] ** [[elisp:(org-cycle)][| ]] [Info] :: *[Current-Info:]* Status/Maintenance -- General TODO List [[elisp:(org-cycle)][| ]] ** TODO [[elisp:(org-cycle)][| ]] Current :: Just getting started [[elisp:(org-cycle)][| ]] ** [End-Of-Status] """ ####+BEGIN: bx:dblock:global:file-insert-cond :cond "./blee.el" :file "/libre/ByStar/InitialTemplates/update/sw/icm/py/moduleOverview.py" cmndArgsSpec = { "0&-1": ['moduleDescription', 'moduleUsage', 'moduleStatus'] } cmndArgsValid = cmndArgsSpec["0&-1"] icm.unusedSuppressForEval(moduleDescription, moduleUsage, moduleStatus) for each in effectiveArgsList: if each in cmndArgsValid: if interactive: exec("""print({})""".format(each)) return (format(str(__doc__) + moduleDescription))
def cmnd(self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate(callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() def menuItem(verbosity): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity=verbosity) # 'little' or 'none' def execLineEx(cmndStr): icm.ex_gExecMenuItem(execLine=cmndStr) ##### IMPORTANT PARAMS SPECIFICATIONS BEGIN svcSpecUrl="http://localhost:8080/swagger.json" svcSpecFile="../svcSpec/deploySvc-api.json" perfSap="http://localhost:8080" headersFileName = "../bearerToken.headers" includeOpsListInExamples = False ##### IMPORTANT PARAMS SPECIFICATIONS END icmsPkgInfoBaseDir = mmwsIcmPkgThis.pkgBase_baseDir() logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() icm.cmndExampleMenuChapter('*Scenarios Selection*') # ../unisos/mmwsIcm-base/opScn-1.py opScn1="{pkgBaseDir}/opScn-1.py".format(pkgBaseDir=icmsPkgInfoBaseDir) execLineEx("""ln -s {pkgBaseDir}/opScenarios.py opScenarios.py""".format(pkgBaseDir=icmsPkgInfoBaseDir)) execLineEx("""ln -s {pkgBaseDir}/opScnrioExpect.py opScnrioExpect.py""".format(pkgBaseDir=icmsPkgInfoBaseDir)) ro.examples_remoteOperations( roListLoadFiles=[ opScn1, ], roExpectListLoadFiles=[opScn1,], ) return(cmndOutcome)
def cmnd( self, interactive=False, # Can also be called non-interactively userName=None, # or Cmnd-Input role=None, # or Cmnd-Input acGroups=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'userName': userName, 'role': role, 'acGroups': acGroups, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome userName = callParamsDict['userName'] role = callParamsDict['role'] acGroups = callParamsDict['acGroups'] ####+END: outBearerToken = BearerToken() outUserInfo = BearerTokenUserInfo() if userName: outUserInfo.setUserName(userName) if role: outUserInfo.setRole(role) if acGroups: outUserInfo.setResGroupIds(acGroups) outBearerToken.setUserInfo(outUserInfo) bearerTokenStr = outBearerToken.encodeAsJsonStr() icm.LOG_here(bearerTokenStr) bearerTokenDict = outBearerToken.selfAsDict() encoded = jwt.encode(bearerTokenDict, 'secret', algorithm='HS256') if interactive: print(encoded) else: icm.LOG_here(encoded) return cmndOutcome.set( opError=icm.OpError.Success, opResults=encoded, )
def cmnd( self, interactive=False, # Can also be called non-interactively rsrc=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'rsrc': rsrc, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome rsrc = callParamsDict['rsrc'] ####+END: rsrcPath = os.path.normpath(rsrc) rsrcParts = rsrcPath.split(os.sep) rsrcBase = rsrcParts[0] system = rsrcParts[1] user = rsrcParts[2] outcome = cryptKeyring.clearPasswdGet().cmnd( interactive=False, rsrc=rsrc, ).log() if outcome.isProblematic(): return (icm.EH_badOutcome(outcome)) accessKey = user secretKey = outcome.results outcome = getToken().cmnd( interactive=False, accessKey=accessKey, secretKey=secretKey, ).log() token = outcome.results if interactive: print(json.dumps(token, indent=4)) return cmndOutcome.set( opError=icm.OpError.Success, opResults=token, )
def cmnd( self, interactive=False, # Can also be called non-interactively sessionType=None, # or Cmnd-Input nuOfDisplays=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'sessionType': sessionType, 'nuOfDisplays': nuOfDisplays, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome sessionType = callParamsDict['sessionType'] nuOfDisplays = callParamsDict['nuOfDisplays'] ####+END: if not nuOfDisplays: outcome = nuOfDisplaysGet().cmnd() if outcome.isProblematic(): return (icm.EH_badOutcome(outcome)) nuOfDisplays = outcome.results outcome = screenstudioRcStdout().cmnd( interactive=False, sessionType=sessionType, nuOfDisplays=nuOfDisplays, ) if outcome.isProblematic(): return (icm.EH_badOutcome(outcome)) screenstudioRcStr = outcome.results screenstudioRcPath = screenstudioRcFileNameGet(sessionType, nuOfDisplays) with open(screenstudioRcPath, "w") as thisFile: thisFile.write(screenstudioRcStr + '\n') if interactive: icm.ANN_here( "screenstudioRcPath={val}".format(val=screenstudioRcPath)) return cmndOutcome.set( opError=icm.OpError.Success, opResults=screenstudioRcPath, )
def cmnd( self, interactive=False, # Can also be called non-interactively svcSpec=None, # or Cmnd-Input perfSap=None, # or Cmnd-Input headers=None, # or Cmnd-Input argsList=[], # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = { 'svcSpec': svcSpec, 'perfSap': perfSap, 'headers': headers, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome svcSpec = callParamsDict['svcSpec'] perfSap = callParamsDict['perfSap'] headers = callParamsDict['headers'] cmndArgsSpecDict = self.cmndArgsSpec() if not self.cmndArgsValidate( effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome): return cmndOutcome ####+END: icm.TM_here("svcSpec={svcSpec} -- perfSap={perfSap}".format( svcSpec=svcSpec, perfSap=perfSap)) try: loadedSvcSpec, origin_url = loadSvcSpec(svcSpec, perfSap) except Exception as e: icm.EH_problem_usageError( "wsInvokerIcm.svcOpsList Failed -- svcSpec={svcSpec}".format( svcSpec=svcSpec, )) icm.EH_critical_exception(e) return pp = pprint.PrettyPrinter(indent=4) icm.TM_here("{}".format(pp.pformat(loadedSvcSpec))) processSvcSpec(loadedSvcSpec, origin_url, perfSap, headers, svcSpec)
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() def menuItem(): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='little') def execLineEx(cmndStr): icm.ex_gExecMenuItem(execLine=cmndStr) logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() icm.cmndExampleMenuChapter('*General Dev and Testing CMNDs*') cmndName = "argsAndParamsProc" cmndArgs = "list argOne twoArg arg3" cps = cpsInit() menuItem() icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='full') icm.cmndExampleMenuChapter('*Other Than ICM Execution Line Examples*') execLineEx("""ls -l""") # icmMainProxy.mainsInfo() return (cmndOutcome)
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() def menuItem(verbosity): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity=verbosity) # 'little' or 'none' def execLineEx(cmndStr): icm.ex_gExecMenuItem(execLine=cmndStr) ##### IMPORTANT PARAMS SPECIFICATIONS BEGIN svcSpecUrl = "http://localhost:8080/swagger.json" svcSpecFile = "./swagger.json" perfSap = "http://localhost:8080" headersFileName = "./bearerToken.headers" includeOpsListInExamples = False ##### IMPORTANT PARAMS SPECIFICATIONS END logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() bearerToken.examples_tokenGenerator("NAME", "ROLES", "GROUPS") return (cmndOutcome)
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() #def menuItem(): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity='little') def execLineEx(cmndStr): icm.ex_gExecMenuItem(execLine=cmndStr) logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() ####+BEGIN: bx:icm:python:cmnd:subSection :title "Dev And Testing" """ ** [[elisp:(beginning-of-buffer)][Top]] ================ [[elisp:(blee:ppmm:org-mode-toggle)][Nat]] [[elisp:(delete-other-windows)][(1)]] *Dev And Testing* [[elisp:(org-cycle)][| ]] [[elisp:(org-show-subtree)][|=]] """ ####+END: # # ICMs PKG Information # configBaseDir = bxCurrentsThis.pkgBase_configDir() print(configBaseDir) bxCurrentsConfig.examples_pkgInfoParsFull( configBaseDir=configBaseDir, )
def cmnd( self, interactive=False, # Can also be called non-interactively argsList=[], # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: myName = self.myName() thisOutcome = icm.OpOutcome(invokerName=myName) print(f"ICM-INFO: {G.icmInfo()}") # NOTYET, Why doesn't this work for eachArg in effectiveArgsList: icm.ANN_here("{}".format(eachArg)) print((icm.__file__)) print("sys.path={sys.path}") import importlib importlib.import_module('unisos.icm') print("foundModuleAndOrigin={}".format( (importlib.util.find_spec('unisos.icm')))) # import imp # print((imp.find_module('unisos/icm'))) @ucf.runOnceOnly def echo(str): print(str) echo("first") echo("second") # Should not run return thisOutcome
def cmnd( self, interactive=False, # Can also be called non-interactively bxoId=None, # or Cmnd-Input sr=None, # or Cmnd-Input controlProfile=None, # or Cmnd-Input inMailAcct=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'bxoId': bxoId, 'sr': sr, 'controlProfile': controlProfile, 'inMailAcct': inMailAcct, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome bxoId = callParamsDict['bxoId'] sr = callParamsDict['sr'] controlProfile = callParamsDict['controlProfile'] inMailAcct = callParamsDict['inMailAcct'] ####+END: """ ** TODO Make inMailAcct come from args not params """ offlineimaprcPath = withInMailDomGetOfflineimaprcPath( controlProfile, inMailAcct, bxoId, sr, ) outcome = icm.subProc_bash( """offlineimap -c {offlineimaprcPath}""".format( offlineimaprcPath=offlineimaprcPath)).log() if outcome.isProblematic(): return (icm.EH_badOutcome(outcome)) return cmndOutcome.set( opError=icm.OpError.Success, opResults=None, )
def cmnd( self, interactive=False, # Can also be called non-interactively rsrc=None, # or Cmnd-Input system=None, # or Cmnd-Input user=None, # or Cmnd-Input passwdPolicy=None, # or Cmnd-Input cryptoPolicy=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'rsrc': rsrc, 'system': system, 'user': user, 'passwdPolicy': passwdPolicy, 'cryptoPolicy': cryptoPolicy, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome rsrc = callParamsDict['rsrc'] system = callParamsDict['system'] user = callParamsDict['user'] passwdPolicy = callParamsDict['passwdPolicy'] cryptoPolicy = callParamsDict['cryptoPolicy'] ####+END: opError = icm.OpError.Success cryptoKeyring = CryptoKeyring( system=system, user=user, ) opError = cryptoKeyring.passwdSet() #cryptoKeyring.save() return cmndOutcome.set( opError=opError, opResults=None, )
def cmnd( self, interactive=False, # Can also be called non-interactively argsList=[], # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome cmndArgsSpecDict = self.cmndArgsSpec() if not self.cmndArgsValidate( effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome): return cmndOutcome ####+END: myName = self.myName() thisOutcome = icm.OpOutcome(invokerName=myName) print(G.icmInfo) for eachArg in effectiveArgsList: icm.ANN_here("{}".format(eachArg)) print((icm.__file__)) print(sys.path) import imp print((imp.find_module('unisos/icm'))) @ucf.runOnceOnly def echo(str): print(str) echo("first") echo("second") # Should not run return thisOutcome
def cmnd(self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate(callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() #def menuItem(verbosity): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity=verbosity) # 'little' or 'none' def extMenuItem(verbosity): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, icmName=icmExName, verbosity=verbosity) # 'little' or 'none' logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() # bpo.examples_bpo_basicAccess(oneBpo) cntnrCurParamsBaseDir = curFps.baseDirObtain() # pattern.sameInstance(Cntnr_CurParams, cntnrCurParamsBaseDir,) fp.examples_fpBase( cntnrCurParamsBaseDir, 'PalsRepo_LiveParams_FPs' ) curFps.examples_curFps().cmnd() icm.cmndExampleMenuChapter('*Related ICMs*') icmExName = "palsBaseLiveTargets.py" ; cmndName = "examples" ; cmndArgs = "" ; cps=cpsInit() ; extMenuItem(verbosity='none') return(cmndOutcome)
def cmnd( self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: roExpectationsList = Ro_OpExpectationsList().opExpectationsListGet() @icm.subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True) def roExpectationsListProc(roExpectationsList): """Process List of Remote Operations Expectations""" @icm.subjectToTracking(fnLoc=True, fnEntry=True, fnExit=True) def roExpectationProc(thisRoExpecation): """Process One Remote Operation""" thisRo = thisRoExpecation.roOp for thisPreInvokeCallable in thisRoExpecation.preInvokeCallables: thisPreInvokeCallable(thisRoExpecation) invokedOp = wsInvokerIcm.ro_opInvokeCapture(thisRo) opReport(invokedOp) for thisPostInvokeCallable in thisRoExpecation.postInvokeCallables: thisPostInvokeCallable(thisRoExpecation) return invokedOp for thisRoExpecation in roExpectationsList: invokedOp = roExpectationProc(thisRoExpecation) return invokedOp roExpectationsListProc(roExpectationsList) return (cmndOutcome)
def cmnd(self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate(callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: def cpsInit(): return collections.OrderedDict() def menuItem(verbosity, **kwargs): icm.ex_gCmndMenuItem(cmndName, cps, cmndArgs, verbosity=verbosity, **kwargs) # def execLineEx(cmndStr): icm.ex_gExecMenuItem(execLine=cmndStr) logControler = icm.LOG_Control() logControler.loggerSetLevel(20) icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName()) icm.G_commonBriefExamples() bleep.examples_icmBasic() ####+BEGIN: bx:icm:python:cmnd:subSection :title "Create (Update) Vagrant File -- With Defaults" """ ** [[elisp:(beginning-of-buffer)][Top]] ============== [[elisp:(blee:ppmm:org-mode-toggle)][Nat]] [[elisp:(delete-other-windows)][(1)]] *Create (Update) Vagrant File -- With Defaults* [[elisp:(org-cycle)][| ]] [[elisp:(org-show-subtree)][|=]] """ ####+END: icm.cmndExampleMenuChapter('*Simple Example Of shRun*') cmndName = "shRunSimple" ; cmndArgs = "" cps=cpsInit() ; menuItem(verbosity='none', comment="# run cmnds -- dont echo cmnds and don't show stdout/err") cmndName = "shRunSimple" ; cmndArgs = "" cps=cpsInit() ; menuItem(verbosity='full', comment="# full verbosity") cmndName = "shRunSimple" ; cmndArgs = "" cps=cpsInit() ; menuItem(verbosity='little', comment="# show stdout/err but dont echo cmnds") cmndName = "shRunSimple" ; cmndArgs = "" cps=cpsInit() ; cps['callTrackings'] = 'monitor+' ; menuItem(verbosity='little', comment="# echo cmnds and show stdout/err") return(cmndOutcome)
def cmnd(self, interactive=False, # Can also be called non-interactively ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = {} if not icm.cmndCallParamsValidate(callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: outcome = icm.subProc_bash( """inMailRetrieve.py -v 20 -i offlineimapRun""" ).log() if outcome.isProblematic(): return(icm.EH_badOutcome(outcome)) return cmndOutcome
def cmnd( self, interactive=False, # Can also be called non-interactively argsList=None, # or Args-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome effectiveArgsList = G.icmRunArgsGet().cmndArgs else: effectiveArgsList = argsList callParamsDict = {} if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome ####+END: icmsBase = effectiveArgsList[0] G_myFullName = sys.argv[0] G_myName = os.path.basename(G_myFullName) icmInBase = icmsBase + "/" + G_myName + "/icmIn" print "{icmInBase}".format(icmInBase=icmInBase) icm.icmParamsToFileParamsUpdate( parRoot="{icmInBase}/paramsFp".format(icmInBase=icmInBase), icmParams=G.icmParamDictGet(), ) icm.icmParamsToFileParamsUpdate( parRoot="{icmInBase}/commonParamsFp".format(icmInBase=icmInBase), icmParams=icm.commonIcmParamsPrep(), ) icm.cmndMainsMethodsToFileParamsUpdate( parRoot="{icmInBase}/cmndMainsFp".format(icmInBase=icmInBase), ) icm.cmndLibsMethodsToFileParamsUpdate( parRoot="{icmInBase}/cmndLibsFp".format(icmInBase=icmInBase), ) return
def cmnd( self, interactive=False, # Can also be called non-interactively panelBase=None, # or Cmnd-Input ): cmndOutcome = self.getOpOutcome() if interactive: if not self.cmndLineValidate(outcome=cmndOutcome): return cmndOutcome callParamsDict = { 'panelBase': panelBase, } if not icm.cmndCallParamsValidate( callParamsDict, interactive, outcome=cmndOutcome): return cmndOutcome panelBase = callParamsDict['panelBase'] ####+END: panelBasePath = panelBasePathObtain(panelBase) icmName = G.icmMyName() icmPrefix, icmExtension = os.path.splitext(icmName) panelFileName = "{}-Panel.org".format(icmPrefix) panelFileFullPath = os.path.join( panelBasePath, panelFileName, ) if os.path.isfile(panelFileFullPath): outcome = icm.subProc_bash("""\ emacsclient -n --eval '(find-file \"{panelFileFullPath}\")' """.format( panelFileFullPath=panelFileFullPath)).log() if outcome.isProblematic(): return (icm.EH_badOutcome(outcome)) else: icm.EH_problem("Missing File -- Run Update First") icm.ANN_note("ls -l {}".format(panelFileFullPath)) return cmndOutcome.set( opError=icm.OpError.Success, opResults=None, )