Ejemplo n.º 1
0
def linuxPkg_versionGet(pkgName, ):
    """
** Return version as string if Python pkgName is installed
** Return None if Python pkgName is not installed
"""
    dpkgQueryOpts = """dpkg-query --show --showformat='${db:Status-Status}\n'"""
    outcome = icm.subProc_bash("""{dpkgQueryOpts} {pkgName}""".format(
        dpkgQueryOpts=dpkgQueryOpts, pkgName=pkgName)).log()
    if outcome.isProblematic():
        icm.EH_badOutcome(outcome)
        return None

    resultStr = outcome.stdout.strip()
    if resultStr == "":
        return None

    dpkgQueryOpts = """dpkg-query --show --showformat='${Version}\n'"""
    outcome = icm.subProc_bash("""{dpkgQueryOpts} {pkgName}""".format(
        dpkgQueryOpts=dpkgQueryOpts, pkgName=pkgName)).log()
    if outcome.isProblematic():
        icm.EH_badOutcome(outcome)
        return None

    resultStr = outcome.stdout.strip()
    if resultStr == "":
        return None
    else:
        return resultStr
Ejemplo n.º 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:

        outcome = icm.subProc_bash("""\
wget http://petstore.swagger.io/v2/swagger.json"""
        ).log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))

        outcome = icm.subProc_bash("""\
{myName} -i headersCreate > {headersFileName}"""
            .format(
                myName=G.icmMyName(),
                headersFileName="./bearerToken.headers",
            )        
        ).log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))

        return cmndOutcome.set(
            opError=icm.OpError.Success,
            opResults=None,
        )
Ejemplo n.º 3
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            panelBase=None,  # or Cmnd-Input
            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 = {
            'panelBase': panelBase,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        panelBase = callParamsDict['panelBase']
        ####+END:
        for eachArg in effectiveArgsList:
            outcome = icm.subProc_bash("""\
{eachArg} -i bleepPlayUpdated""".format(eachArg=eachArg)).log()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))
Ejemplo n.º 4
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:
        """
** TODO UnUsed.
        """

        #offlineimaprcPath = withInMailDomGetOfflineimaprcPath(controlProfile, inMailAcct)

        outcome = icm.subProc_bash("""screenstudio""").log()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        return cmndOutcome.set(
            opError=icm.OpError.Success,
            opResults=None,
        )
Ejemplo n.º 5
0
    def cmnd(self,
            interactive=False,        # Can also be called non-interactively
            inMailAcct=None,      # or IIF Parameter            
    ):
        """ """
        myName=self.myName()
        G = icm.IcmGlobalContext()        
        thisOutcome = icm.OpOutcome(invokerName=myName)
        if interactive:
            if not self.cmndLineValidate(outcome=thisOutcome):
                return(thisOutcome)

        if not inMailAcct:
            if not interactive:
                return icm.eh_problem_usageError(
                    thisOutcome,
                    "Missing Non-Interactive Arg (inMailAcct)",
                )
            inMailAcct = G.usageParams.inMailAcct

        outcome = icm.subProc_bash("""echo Preparing the package""").log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))
        
        return thisOutcome.set(
            opError=icm.OpError.Success,
            opResults=None,
        )
Ejemplo n.º 6
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,
        )
Ejemplo n.º 7
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            bxoId=None,  # or Cmnd-Input
            sr=None,  # or Cmnd-Input
            inMailAcct=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,
            'inMailAcct': inMailAcct,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        bxoId = callParamsDict['bxoId']
        sr = callParamsDict['sr']
        inMailAcct = callParamsDict['inMailAcct']

        cmndArgsSpecDict = self.cmndArgsSpec()
        if not self.cmndArgsValidate(
                effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome):
            return cmndOutcome
####+END:
        cmndArgs = self.cmndArgsGet("0&-1", cmndArgsSpecDict,
                                    effectiveArgsList)
        joinedArgs = ucf.str_joinedArgs(cmndArgs)

        defaultMailDom = marmeAcctsLib.enabledInMailAcctObtain(
            bxoId=bxoId,
            sr=sr,
        )
        configFile = withInMailDomGetNotmuchConfigPath(
            defaultMailDom,
            bxoId=bxoId,
            sr=sr,
        )

        outcome = icm.subProc_bash(
            """notmuch --config={configFile} {joinedArgs}""".format(
                configFile=configFile,
                joinedArgs=joinedArgs,
            )).out()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        if interactive:
            pass

        return outcome.set(opError=icm.OpError.Success,
                           #opResults=outcome.stdout
                           )
Ejemplo n.º 8
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()
        argsList = G.icmRunArgsGet().cmndArgs

        G_myFullName = sys.argv[0]

        for eachArg in argsList:
            outcome = icm.subProc_bash(
                """{icmName} -v 20 -i {command}""".format(
                    icmName=G_myFullName,
                    command=eachArg,
                )).log()
            if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

            # eval("""{command}().cmnd(interactive=False,)""".format(
            #     command=eachArg,
            # ))

        return cmndOutcome
Ejemplo n.º 9
0
    def update(self):
        pkgsList = self.pkgsListObtain()
        activateFile = os.path.join(self.virtualenvBaseDir, "bin/activate")
        for each in pkgsList:
            outcome = icm.subProc_bash("""\
source {activateFile}; \
pip install --no-cache-dir {each}; \
""".format(activateFile=activateFile, each=each)).out()
            if outcome.isProblematic(): return icm.EH_badOutcome(outcome)
Ejemplo n.º 10
0
        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
Ejemplo n.º 11
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
Ejemplo n.º 12
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
Ejemplo n.º 13
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
Ejemplo n.º 14
0
    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,
        )
Ejemplo n.º 15
0
def pythonPkg_locationGet(pkgName, ):
    """
** Return location as string if Python pkgName is installed
** Return None if Python pkgName is not installed
"""
    outcome = icm.subProc_bash(
        """pip show {pkg} | egrep '^Location' | cut -d ':' -f 2""".format(
            pkg=pkgName)).log()
    if outcome.isProblematic():
        icm.EH_badOutcome(outcome)
        return None

    resultStr = outcome.stdout.strip()
    if resultStr == "":
        return None
    else:
        return resultStr
Ejemplo n.º 16
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(
            """inMailRetrieve.py -v 20 -i offlineimapRun"""
        ).log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))

        return cmndOutcome
Ejemplo n.º 17
0
    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,
        )
Ejemplo n.º 18
0
    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

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

        action = effectiveArgsList[0]
        effectiveArgsList.pop(0)

        print(action)

        for each in effectiveArgsList:
            print(each)

        outcome = icm.subProc_bash("""\
echo action={action} {argsList}""".format(
            action=action, argsList=" ".join(effectiveArgsList))).log()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

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

        ####+BEGIN: bx:icm:python:method :methodName "cmndArgsSpec" :methodType "anyOrNone" :retType "bool" :deco "default" :argsList ""
        """
Ejemplo n.º 19
0
    def cmnd(
            self,
            interactive=False,  # Can also be called non-interactively
            periodicity=None,  # or Cmnd-Input
    ):
        cmndOutcome = self.getOpOutcome()
        if interactive:
            if not self.cmndLineValidate(outcome=cmndOutcome):
                return cmndOutcome

        callParamsDict = {
            'periodicity': periodicity,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        periodicity = callParamsDict['periodicity']
        ####+END:
        G = icm.IcmGlobalContext()
        argsList = G.icmRunArgsGet().cmndArgs

        G_myFullName = sys.argv[0]

        while True:
            for eachArg in argsList:
                outcome = icm.subProc_bash(
                    """{icmName} -v 20 -i {command}""".format(
                        icmName=G_myFullName,
                        command=eachArg,
                    )).log()
                if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

            icm.ANN_note(
                "sleeping for: {periodicity}".format(periodicity=periodicity))

            try:
                time.sleep(int(periodicity))
            except KeyboardInterrupt:
                print('\n\nKeyboard exception received. Exiting.')
                exit()

            icm.ANN_note("End of sleeping")
Ejemplo n.º 20
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()

        outcome = icm.subProc_bash(
            """inMailDsnProc.py -v 20  -i maildirApplyToMsg dsnTestSendToCoRecipients"""
        ).log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))
        
        return cmndOutcome
Ejemplo n.º 21
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()

        outcome = icm.subProc_bash(
            """inMailUserAgent.py -v 20 -i runNotmuch new"""
        ).log()
        if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))
        

        return cmndOutcome
Ejemplo n.º 22
0
    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
                           )
Ejemplo n.º 23
0
    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,
        )

        icmPlayerInfoBaseDir = os.path.join(panelBasePath, "var", icmName,
                                            "icmIn")
        icm.unusedSuppress(icmPlayerInfoBaseDir)

        icmInputsExpose().cmnd(
            interactive=False,
            argsList=[os.path.join(
                panelBasePath,
                "./var",
            )])

        outcome = beginPanelStdout().cmnd(interactive=False, )
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        beginPanelStr = outcome.results

        if os.path.isfile(panelFileFullPath):
            shutil.copyfile(panelFileFullPath,
                            "{}-keep".format(panelFileFullPath))
        else:
            with open(panelFileFullPath, "w") as thisFile:
                thisFile.write(beginPanelStr + '\n')

        icm.ANN_note("ls -l {}".format(panelFileFullPath))

        outcome = icm.subProc_bash("""\
bx-dblock -i dblockUpdateFiles {panelFileFullPath}""".format(
            panelFileFullPath=panelFileFullPath)).log()
        if outcome.isProblematic(): return (icm.EH_badOutcome(outcome))

        return cmndOutcome.set(
            opError=icm.OpError.Success,
            opResults=None,
        )
Ejemplo n.º 24
0
    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:

        def withPbdNameGetRootForPlatform(pbdName):
            rootDirName = None
            
            bxPlatformConfigBase = bxPlatformThis.pkgBase_configDir()
            
            if pbdName == "bisosRoot":
                rootDirName = bxPlatformConfig.rootDir_bisos_fpObtain(bxPlatformConfigBase)
                
            elif pbdName == "deRunRoot":
                rootDirName = bxPlatformConfig.rootDir_bxo_fpObtain(bxPlatformConfigBase)
                
            elif pbdName == "bxoRoot":
                rootDirName = bxPlatformConfig.rootDir_deRun_fpObtain(bxPlatformConfigBase)
            else:
                icm.EH_problem_usageError("")

            return rootDirName

        bisosUserName = "******" #bisosUserName_obtain()
        bisosGroupName = "NOTYET" #bisosGroupName_obtain()

        pbdNamesList = self.cmndArgsGet("0&-1", cmndArgsSpecDict, effectiveArgsList)

        if pbdNamesList[0] == "all":
            cmndArgsSpec = cmndArgsSpecDict.argPositionFind("0&-1")
            argChoices = cmndArgsSpec.argChoicesGet()
            argChoices.pop(0)
            pbdNamesList = argChoices

        for each in pbdNamesList:
            rootDir = withPbdNameGetRootForPlatform(each)
            # icm.ANN_here("{} -- {}".format(each, rootDir))
            try: 
                os.makedirs(rootDir)
            except OSError:
                if not os.path.isdir(rootDir):
                    raise

            # Python 3
            #shutil.chown(rootDir, bisosUserName, bisosGroupName)
            uid = pwd.getpwnam(bisosUserName).pw_uid
            gid = grp.getgrnam(bisosGroupName).gr_gid
            os.chown(rootDir, uid, gid)

            os.chmod(rootDir, 0o775)            

            outcome = icm.subProc_bash("""\
ls -ld  {rootDir}"""
                                       .format(rootDir=rootDir)
            ).log()
            if outcome.isProblematic(): return(icm.EH_badOutcome(outcome))
            

        #icm.ANN_here("{}".format(bisosUserName))

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