コード例 #1
0
def verify_petstoreSvcCommonRo(opExpectation):
    roOp = opExpectation.roOp
    opResults = roOp.roResults
    if opResults.httpResultCode < 400:
        icm.ANN_write("* ==:: SUCCESS")
    else:
        icm.ANN_write("* ==:: FAILED")
コード例 #2
0
    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,
        )
コード例 #3
0
    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("""\
xrandr -q | grep ' connected' | wc -l\
""").log()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        nuOfScreens = outcome.stdout.strip('\n')

        if interactive:
            icm.ANN_write("{}".format(nuOfScreens))

        return cmndOutcome.set(
            opError=icm.OpError.Success,
            opResults=nuOfScreens,
        )
コード例 #4
0
ファイル: serviceObject.py プロジェクト: bisos-pip/common
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            bxoId=None,  # or Cmnd-Input
            sr=None,  # or Cmnd-Input
    ):
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome

        callParamsDict = {
            'bxoId': bxoId,
            'sr': sr,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        bxoId = callParamsDict['bxoId']
        sr = callParamsDict['sr']

        ####+END:
        retVal = srFullPathBaseDir_obtain(
            bxoId=bxoId,
            srRelPath=sr,
        )

        if interactive:
            icm.ANN_write("{}".format(retVal))

        return cmndOutcome.set(
            opError=icm.notAsFailure(retVal),
            opResults=retVal,
        )
コード例 #5
0
ファイル: icmExamples.py プロジェクト: unisos-pip/icmExamples
    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:
        configBaseDir = bxPlatformThis.pkgBase_configDir()

        platformConfigFpBase = bxPlatformConfig.configPkgInfoFpBaseDir_obtain(configBaseDir)
        bisosUserName = bxPlatformConfig.bisosUserName_fpObtain(configBaseDir)
        bisosGroupName = bxPlatformConfig.bisosGroupName_fpObtain(configBaseDir)
        platformControlBaseDir = bxPlatformConfig.platformControlBaseDir_fpObtain(configBaseDir)

        icm.ANN_write(configBaseDir)
        icm.ANN_here(platformConfigFpBase)
        icm.ANN_here(bisosUserName)
        icm.ANN_here(bisosGroupName)
        icm.ANN_here(platformControlBaseDir)

        return cmndOutcome.set(
            opError=icm.OpError.Success,
            opResults=None,
        )

####+BEGIN: bx:icm:python:method :methodName "cmndDocStr" :methodType "anyOrNone" :retType "bool" :deco "default" :argsList ""
        """
コード例 #6
0
def pythonPkg_install_pip(
    pkgName,
    pkgVersion,
):
    """
** Install a given Python pkg based on its canonical name and version.
If version is specified,  the package is installed or updated to that version.
If version is None, 
    if package is already installed no action is taken
    if package is not installed, the latest is installed
"""
    installedVersion = pythonPkg_versionGet(pkgName)
    if pkgVersion:
        if installedVersion == pkgVersion:
            icm.ANN_write(
                "Python:: {pkgName} ver={ver} (as expected) is already installed -- skipped"
                .format(pkgName=pkgName, ver=installedVersion))
            return
        else:
            outcome = icm.subProc_bash(
                """echo pip install {pkgName}=={pkgVersion}""".format(
                    pkgName=pkgName, pkgVersion=pkgVersion)).log()
            if outcome.isProblematic(): return icm.EH_badOutcome(outcome)
            resultStr = outcome.stdout.strip()
            icm.ANN_write(resultStr)
            return

    installedVersion = pythonPkg_versionGet(pkgName)
    if installedVersion:
        icm.ANN_write(
            "Python:: {pkgName} ver={ver} (as any) is already installed -- skipped"
            .format(pkgName=pkgName, ver=installedVersion))
        return
    else:
        outcome = icm.subProc_bash(
            """echo pip install {pkgName}""".format(pkgName=pkgName)).log()
        if outcome.isProblematic(): return icm.EH_badOutcome(outcome)
        resultStr = outcome.stdout.strip()
        icm.ANN_write(resultStr)
        return
コード例 #7
0
def opReport(
    op,
):
####+END:
    pp = pprint.PrettyPrinter(indent=4)

    icm.ANN_write("""* ->:: @{perfSap}@{resource}@{opName}""".format(
        perfSap=op.perfSap,
        resource=op.resource,
        opName=op.opName,
    ))

    params = op.roParams    

    icm.ANN_write("""** ->:: svcSpec={svcSpec}""".format(
        svcSpec=op.svcSpec,
    ))

    newLine = "\n";
    if params.headerParams == None: newLine = "";
        
    icm.ANN_write("** ->:: Header Params: {newLine}{headerParams}".format(
        newLine=newLine, headerParams=pp.pformat(params.headerParams)))

    newLine = "\n";
    if params.urlParams == None: newLine = "";
        
    icm.ANN_write("** ->:: Url Params: {newLine}{urlParams}".format(
        newLine=newLine, urlParams=pp.pformat(params.urlParams)))

    newLine = "\n";
    if params.bodyParams == None: newLine = "";
        
    icm.ANN_write("** ->:: Body Params: {newLine}{bodyParams}".format(
        newLine=newLine, bodyParams=pp.pformat(params.bodyParams)))

    
    results = op.roResults

    if results.opResults:
        resultsFormat="json"
    else:
        resultsFormat="empty"
        
    icm.ANN_write("""* <-:: httpStatus={httpResultCode} -- httpText={httpResultText} -- resultsFormat={resultsFormat}""".format(
        httpResultCode=results.httpResultCode,
        httpResultText=results.httpResultText,
        resultsFormat=resultsFormat,
    ))

    newLine = "\n";
    if results.opResults == None: newLine = "";
        
    icm.ANN_write("** <-:: Operation Result: {newLine}{result}".format(
        newLine=newLine, result=pp.pformat(results.opResults)))
コード例 #8
0
def linuxPkgInstall_yum(
    pkgName,
    pkgVersion,
):
    """
** Install a given linux pkg with yum based on its canonical name and version.
"""

    outcome = icm.subProc_bash(
        """sudo yum install {pkgName}""".format(pkgName=pkgName)).log()
    if outcome.isProblematic(): return icm.EH_badOutcome(outcome)
    resultStr = outcome.stdout.strip()
    icm.ANN_write(resultStr)
    return
コード例 #9
0
def linuxPkgInstall_aptGet(
    pkgName,
    pkgVersion,
):
    """
** Install a given linux pkg with apt-get based on its canonical name and version.
"""
    installedVersion = linuxPkg_versionGet(pkgName)
    if pkgVersion:
        if installedVersion == pkgVersion:
            icm.ANN_write(
                "Linux::  {pkgName} ver={ver} (as expected) is already installed -- skipped"
                .format(pkgName=pkgName, ver=installedVersion))
            return
        else:
            outcome = icm.subProc_bash(
                """echo NOTYET pip install {pkgName}=={pkgVersion}""".format(
                    pkgName=pkgName, pkgVersion=pkgVersion)).log()
            if outcome.isProblematic(): return icm.EH_badOutcome(outcome)
            resultStr = outcome.stdout.strip()
            icm.ANN_write(resultStr)
            return

    installedVersion = linuxPkg_versionGet(pkgName)
    if installedVersion:
        icm.ANN_write(
            "Linux::  {pkgName} ver={ver} (as any) is already installed -- skipped"
            .format(pkgName=pkgName, ver=installedVersion))
        return
    else:
        outcome = icm.subProc_bash("""sudo apt-get install {pkgName}""".format(
            pkgName=pkgName)).log()
        if outcome.isProblematic(): return icm.EH_badOutcome(outcome)
        resultStr = outcome.stdout.strip()
        icm.ANN_write(resultStr)
        return
コード例 #10
0
    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:

        def inFilesListForOne(mainLatexFile):
            thisPrefix, thisExtension = os.path.splitext(mainLatexFile)

            thisOutcome = icm.OpOutcome(invokerName=G.icmMyFullName())

            thisOutcome = icm.subProc_bash(
                """xelatex -recorder {mainLatexFile}""".format(
                    mainLatexFile=mainLatexFile),
                stdin=None,
                outcome=thisOutcome,
            )  #.out()

            if thisOutcome.isProblematic():
                return (icm.EH_badOutcome(thisOutcome))

            thisOutcome = icm.subProc_bash(
                """egrep '(^INPUT )([a-z|A-Z]|\.)' {thisPrefix}.fls  | sort | uniq | egrep -v 'aux$' | cut -d ' ' -f 2"""
                .format(thisPrefix=thisPrefix),
                stdin=None,
                outcome=thisOutcome,
            )  #.out()

            if thisOutcome.isProblematic():
                return (icm.EH_badOutcome(thisOutcome))

            inFilesList = list()
            for each in thisOutcome.stdout.splitlines():
                thisPrefix, thisExtension = os.path.splitext(each)
                if thisExtension in [
                        ".vrb",
                        ".out",
                        ".bbl",
                        ".nav",
                        ".cut",
                        ".toc",
                        ".lof",
                ]:
                    continue
                else:
                    inFilesList.append(each)

            return inFilesList

        aggregatedInFilesSet = set()

        for each in effectiveArgsList:
            inFilesList = inFilesListForOne(each)
            aggregatedInFilesSet = aggregatedInFilesSet.union(set(inFilesList))

        if interactive:
            icm.ANN_write(" ".join(aggregatedInFilesSet))

        return cmndOutcome.set(
            opError=icm.OpError.Success,
            opResults=aggregatedInFilesSet,
        )
コード例 #11
0
ファイル: serviceObject.py プロジェクト: bisos-pip/common
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            bxoId=None,  # or Cmnd-Input
            sr=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 = {
            'bxoId': bxoId,
            'sr': sr,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        bxoId = callParamsDict['bxoId']
        sr = callParamsDict['sr']

        cmndArgsSpecDict = self.cmndArgsSpec()
        if not self.cmndArgsValidate(
                effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome):
            return cmndOutcome
####+END:

        cmndArgs = self.cmndArgsGet("0&2", cmndArgsSpecDict, effectiveArgsList)

        if len(cmndArgs):
            if cmndArgs[0] == "all":
                cmndArgsSpec = cmndArgsSpecDict.argPositionFind("0&2")
                argChoices = cmndArgsSpec.argChoicesGet()
                argChoices.pop(0)
                cmndArgs = argChoices

        retVal = bxoSr_runBaseObtain_root(
            bxoId=bxoId,
            sr=sr,
        )

        if interactive:
            icm.ANN_write("{}".format(retVal))
            for each in cmndArgs:
                if each == "var":
                    icm.ANN_write("{each}".format(
                        each=bxoSr_runBaseObtain_var(bxoId, sr)))
                elif each == "tmp":
                    icm.ANN_write("{each}".format(
                        each=bxoSr_runBaseObtain_tmp(bxoId, sr)))
                elif each == "log":
                    icm.ANN_write("{each}".format(
                        each=bxoSr_runBaseObtain_log(bxoId, sr)))
                else:
                    icm.EH_problem_usageError("")

        return cmndOutcome.set(
            opError=icm.notAsFailure(retVal),
            opResults=retVal,
        )
コード例 #12
0
ファイル: inMailRetrieve.py プロジェクト: bisos-pip/marme
    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)

        logControler = icm.LOG_Control()
        logControler.loggerSetLevel(20)

        icm.icmExampleMyName(G.icmMyName(), G.icmMyFullName())

        icm.G_commonBriefExamples()

        bleep.examples_icmBasic()

        controlProfile = marmeAcctsLib.enabledControlProfileObtain(
            curGet_bxoId(), curGet_sr())
        defaultMailDom = marmeAcctsLib.enabledInMailAcctObtain(
            curGet_bxoId(), curGet_sr())

        ####+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:
        #icm.cmndExampleMenuChapter('*General Dev and Testing IIFs*')

        icm.cmndExampleMenuChapter('*Config File Creation Facility IIFs*')

        cmndName = "offlineimaprcUpdate"
        cmndArgs = ""
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        menuItem(verbosity='none')
        menuItem(verbosity='full')

        cmndName = "offlineimaprcStdout"
        cmndArgs = ""
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        menuItem(verbosity='none')
        menuItem(verbosity='full')

        configFile = withInMailDomGetOfflineimaprcPath(
            controlProfile,
            defaultMailDom,
            curGet_bxoId(),
            curGet_sr(),
        )

        icm.ANN_write("""ls -l {}""".format(configFile))
        icm.ANN_write("""cat  {} """.format(configFile))

        icm.cmndExampleMenuChapter(
            '*Operation Facility IIFs -- (offlineimapRun)*')

        cmndName = "offlineimapRun"
        cmndArgs = ""
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        menuItem(verbosity='none')
        menuItem(verbosity='full')

        marmeAcctsLib.examples_controlProfileManage()

        #marmeAcctsLib.examples_marmeAcctsLibControls()
        marmeAcctsLib.examples_enabledInMailAcctConfig()

        marmeAcctsLib.examples_inMailAcctAccessPars()
コード例 #13
0
ファイル: wsInvokerIcm.py プロジェクト: bisos-pip/mmwsIcm
def opInvoke(headers, op, *args, **kwargs):
    ####+END:
    """ NOTYET, Important, opInvoke should be layered on  top of opInvokeCapture """

    pp = pprint.PrettyPrinter(indent=4)

    headerLines = list()
    if headers:
        with open(headers, 'rb') as file:
            headerLines = file.readlines()

    # else:
    #     print("Has No Headers")

    headerLinesAsDict = dict()
    for each in headerLines:
        headerLineAsList = each.split(":")
        headerLineAsListLen = len(headerLineAsList)

        if headerLineAsListLen == 2:
            headerLineTag = headerLineAsList[0]
            headerLineValue = headerLineAsList[1]
        else:
            icm.EH_problem_usageError(
                "Expected 2: {}".format(headerLineAsListLen))
            continue

        headerLinesAsDict[headerLineTag] = headerLineValue.lstrip(' ').rstrip()

    requestOptions = dict()

    if headerLinesAsDict:
        requestOptions["headers"] = headerLinesAsDict

    def bodyArgToDict(
        bodyAny,
        bodyFile,
        bodyStr,
        bodyFunc,
    ):
        """ Returns None if all Args were None, and returns "" if one of the args was "", Otherwize a dict or {}."""
        def bodyStrAsDict(bodyStr):
            return ast.literal_eval(bodyStr)

        def bodyFileAsDict(bodyFile):
            with open(bodyFile, 'r') as myfile:
                data = myfile.read().replace('\n', '')
            return ast.literal_eval(data)

        def bodyFuncAsDict(bodyFunc):
            resDict = eval(bodyFunc)
            # NOTYET, verify that we have a dict
            return resDict

        if bodyAny != None:
            icm.TM_here("bodyAny={}".format(pp.pformat(bodyAny)))

            if bodyAny == "":
                return ""

            # Be it file, function or string
            if os.path.isfile(bodyAny):
                return bodyFileAsDict(bodyAny)
            elif bodyAny == "NOTYET-valid func":
                return bodyFuncAsDict(bodyAny)
            else:
                # We then take bodyAny to be a string
                return bodyStrAsDict(bodyAny)

        elif bodyFile != None:
            icm.TM_here("bodyFile={}".format(pp.pformat(bodyFile)))

            if bodyFile == "":
                return ""

            if os.path.isfile(bodyAny):
                return bodyFileAsDict(bodyFile)
            else:
                return {}

        elif bodyFunc != None:
            icm.TM_here("bodyFunc={}".format(pp.pformat(bodyFunc)))

            if bodyFunc == "":
                return ""

            if bodyFunc == "NOTYET-valid func":
                return bodyFuncAsDict(bodyFunc)
            else:
                return {}

        elif bodyStr != None:
            icm.TM_here("bodyStr={}".format(pp.pformat(bodyStr)))

            if bodyStr == "":
                return ""

            bodyValue = bodyStrAsDict(bodyStr)
            return bodyValue

        else:
            # So they were all None, meaning that no form of "body" was specified.
            return None

    # icm.TM_here("Args: {}".format(args))
    # for key in kwargs:
    #      icm.TM_here("another keyword arg: %s: %s" % (key, kwargs[key]))

    bodyAny = kwargs.pop('body', None)
    bodyFile = kwargs.pop('bodyFile', None)
    bodyStr = kwargs.pop('bodyStr', None)
    bodyFunc = kwargs.pop('bodyFunc', None)

    bodyValue = bodyArgToDict(bodyAny, bodyFile, bodyStr, bodyFunc)

    icm.TM_here(pp.pformat(requestOptions))

    if bodyValue == None:
        request = construct_request(op, requestOptions, **kwargs)
    elif bodyValue == "":
        # Causes An Exception That Describes Expected Dictionary
        request = construct_request(op, requestOptions, body=None, **kwargs)
    else:
        request = construct_request(op,
                                    requestOptions,
                                    body=bodyValue,
                                    **kwargs)

    icm.LOG_here("request={request}".format(request=pp.pformat(request)))

    c = RequestsClient()

    future = c.request(request)

    try:
        result = future.result()
    except Exception as e:
        #icm.EH_critical_exception(e)
        result = None

    if result:
        icm.LOG_here("responseHeaders: {headers}".format(
            headers=pp.pformat(result._delegate.headers)))

        icm.ANN_write("Operation Status: {result}".format(result=result))

        icm.ANN_write("Operation Result: {result}".format(
            result=pp.pformat(result.json())))
コード例 #14
0
ファイル: bxPipPkgs.py プロジェクト: bisos-pip/common
 def show(self):
     icm.ANN_write("{}".format(self.__str__()))
コード例 #15
0
ファイル: bxPipPkgs.py プロジェクト: bisos-pip/common
 def list(self):
     pkgsList = self.pkgsListObtain()
     for each in pkgsList:
         icm.ANN_write(each)
     return pkgsList
コード例 #16
0
ファイル: inMailNotmuch.py プロジェクト: bisos-pip/marme
    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)

        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()

        defaultMailDom = marmeAcctsLib.enabledInMailAcctObtain(
            bxoId=curGet_bxoId(),
            sr=curGet_sr(),
        )

        ####+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:
        #icm.cmndExampleMenuChapter('*General Dev and Testing IIFs*')

        icm.cmndExampleMenuChapter('*Config File Creation Facilities*')

        icm.cmndExampleMenuSection(
            '*Automated Config File Creation Facilities*')

        cmndName = "notmuchConfigUpdate"
        cmndArgs = ""
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        menuItem(verbosity='none')
        menuItem(verbosity='full')

        cmndName = "notmuchConfigStdout"
        cmndArgs = ""
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        menuItem(verbosity='none')
        menuItem(verbosity='full')

        configFile = withInMailDomGetNotmuchConfigPath(
            defaultMailDom,
            bxoId=curGet_bxoId(),
            sr=curGet_sr(),
        )

        icm.ANN_write("""ls -l {}""".format(configFile))
        icm.ANN_write("""cat  {} """.format(configFile))

        icm.cmndExampleMenuSection(
            '*Interactive Config File Creation Facilities*')

        cmndName = "runNotmuch"
        cmndArgs = "setup"
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='basic',
                             comment='# Creates/Edits notmuch-config',
                             icmWrapper=None,
                             icmName=None)

        icm.cmndExampleMenuSection('*Show/List Config Parameter Settings*')

        cmndName = "runNotmuch"
        cmndArgs = "config list"
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='basic',
                             comment='# Shows Key aspects of notmuch-config',
                             icmWrapper=None,
                             icmName=None)

        icm.cmndExampleMenuChapter('*Run notmuch -- new, Search*')

        cmndName = "runNotmuch"
        cmndArgs = "new"
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='basic',
                             comment='# Refresh the index',
                             icmWrapper=None,
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search --format=text --output=files "from:"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='basic',
                             comment='# Search Based on from',
                             icmWrapper=None,
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search --format=text --output=files "from:"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='none',
                             comment='# Search Based on from',
                             icmWrapper='echo',
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search "from:"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='basic',
                             comment='# Search Based on from',
                             icmWrapper=None,
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search "from:"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='none',
                             comment='# Search Based on from',
                             icmWrapper='echo',
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search --format=text --output=files "from:" | grep Inbox | xargs egrep "^Subject:"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='basic',
                             comment='# Search Based on from',
                             icmWrapper=None,
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search --format=text --output=files "from:" | grep Inbox | xargs egrep "^Subject:"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='none',
                             comment='# Search Based on from',
                             icmWrapper="echo",
                             icmName=None)

        cmndName = "runNotmuch"
        cmndArgs = '''-- search --output=files "to: example.com"'''
        cps = cpsInit()
        cmndParsCurBxoSr(cps)
        icm.ex_gCmndMenuItem(cmndName,
                             cps,
                             cmndArgs,
                             verbosity='none',
                             comment='# Search Based on from',
                             icmWrapper="echo",
                             icmName=None)

        marmeAcctsLib.examples_controlProfileManage()

        marmeAcctsLib.examples_enabledInMailAcctConfig()

        marmeAcctsLib.examples_inMailAcctAccessPars()
コード例 #17
0
ファイル: inMailNotmuch.py プロジェクト: bisos-pip/marme
    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:

        templateFile = os.path.join(
            marmeAcctsLib.inputsBaseDirGet(),
            "inputs",
            "notmuch/_notmuch-config.template",
        )

        outcome = icm.subProc_bash("""\
cat {templateFile} | \
        sed \
            -e "s@%mailDirPath%@{mailDirPath}@g" \
            -e "s@%firstName%@{firstName}@g" \
            -e "s@%lastName%@{lastName}@g" 
""".format(
            templateFile=templateFile,
            # ../var/inMail/example/maildir/Inbox
            mailDirPath=marmeAcctsLib.getPathForAcctMaildir(
                controlProfile,
                inMailAcct,
                bxoId=bxoId,
                sr=sr,
            ),
            firstName="FirstName",
            lastName="LastName",
        )).log()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        if interactive:
            icm.ANN_write(outcome.stdout)

        return outcome.set(opError=icm.OpError.Success,
                           #opResults=outcome.stdout
                           )
コード例 #18
0
def sleep1Sec(opExpectation):
    icm.ANN_write("* XX:: Sleeping For 1 Second")
    time.sleep(1)