コード例 #1
0
ファイル: impressiveSup.py プロジェクト: bisos-pip/lcnt
def bxVideoRecorderStop(curPage=None, ):
    ####+END:

    icm.ANN_here("Recoring Stopped -- page={} -- Enter".format(curPage))

    screenstudioWebClient.recordingStop().cmnd(
        interactive=False,
        argsList=[screenstudioWebClient.serviceUrlDefault(None)])

    icm.ANN_here("Recoring Stopped -- page={} -- Exit".format(curPage))

    recordingsBaseDir = os.path.abspath("./video")

    recordedFile = ucf.FN_latestInDir(recordingsBaseDir)

    dirsPart, nonDirsPart = os.path.split(recordedFile)
    nonDirsPartList = nonDirsPart.split("-")
    if nonDirsPartList[0] != "capture":
        # It was not screenstudio generated and should be ignored
        icm.EH_problem_info("Missing Captured Video --{}".format(recordedFile))
        return

    frameName = beamerDisposition.withSlideNumberGetFrameName(str(curPage))

    canonFileName = "master-{}.mp4".format(frameName)
    canonFilePath = os.path.join(recordingsBaseDir, canonFileName)

    if os.path.isfile(canonFilePath):
        dateTag = ucf.TIME_nowTag()
        canonFileName = "master-{}-{}.mp4".format(frameName, dateTag)
        canonFilePath = os.path.join(recordingsBaseDir, canonFileName)

    os.rename(recordedFile, canonFilePath)
コード例 #2
0
ファイル: marmeMsgLib.py プロジェクト: bisos-pip/marme
def fromNonDeliveryReportGetFailedMsg(
    nonDeliveryReportMsg,
    tempFailedRecipients,
    permFailedRecipients,
):
    """ 
** returns the extracted failed message from the non-delivery-report. Or None.
"""

    if not (tempFailedRecipients or permFailedRecipients):
        # This is NOT a nonDeliveryReport
        return None

    #
    # Get the failed message as an attachement
    #
    for part in nonDeliveryReportMsg.walk():
        if part.get_content_type() == 'message/rfc822':
            failedMsgList = part.get_payload()
            if failedMsgList:
                #for failedMsg in failedMsgList:
                nuOfFailedMsgs = len(failedMsgList)
                if nuOfFailedMsgs != 1:
                    icm.EH_problem_info("More Then One -- Expected One")
                    return None
                else:
                    return failedMsgList[0]

    #
    # So,the failed message was not included and is part of the body.
    #

    #scre = re.compile(b'mail to the following recipients could not be delivered')
    scre = re.compile(
        b'-- The header and top 20 lines of the message follows --')

    msg = nonDeliveryReportMsg
    failedMsgStr = ""
    found = False
    for line in msg.get_payload(decode=True).splitlines():
        if scre.search(line):
            found = "gotIt"
            continue
        if found == "gotIt":  # This consumes an empty line
            found = True
            continue
        if found == True:
            failedMsgStr = failedMsgStr + line + '\n'

    if found:
        return email.message_from_string(failedMsgStr)
    else:
        return None
コード例 #3
0
def canon_linuxPkgInstall(
    pkgName,
    pkgVersion,
):
    """
** Install a given Linux pkg based on its canonical name and version.
"""
    distroName = platform.linux_distribution()[0]

    if distroName == "Ubuntu":
        return linuxPkgInstall_aptGet(pkgName, pkgVersion)
    elif distroName == "Redhat":
        return linuxPkgInstall_yum(pkgName, pkgVersion)
    elif distroName == "CentOS Linux":
        return linuxPkgInstall_yum(pkgName, pkgVersion)
    else:
        icm.EH_problem_info(
            "Unsupported Distribution == {}".format(distroName))
        return
コード例 #4
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
            inMbox=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,
            'controlProfile': controlProfile,
            'inMailAcct': inMailAcct,
            'inMbox': inMbox,
        }
        if not icm.cmndCallParamsValidate(
                callParamsDict, interactive, outcome=cmndOutcome):
            return cmndOutcome
        bxoId = callParamsDict['bxoId']
        sr = callParamsDict['sr']
        controlProfile = callParamsDict['controlProfile']
        inMailAcct = callParamsDict['inMailAcct']
        inMbox = callParamsDict['inMbox']

        cmndArgsSpecDict = self.cmndArgsSpec()
        if not self.cmndArgsValidate(
                effectiveArgsList, cmndArgsSpecDict, outcome=cmndOutcome):
            return cmndOutcome
####+END:
#cmndArgsSpec = {0: ['msgDisect', 'coRecepientNdr']}

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

        inMailDir = marmeAcctsLib.getPathForAcctMbox(
            controlProfile,
            inMailAcct,
            inMbox,
            bxoId=bxoId,
            sr=sr,
        )

        icm.LOG_here(inMailDir)

        mbox = mailbox.Maildir(
            inMailDir,
            factory=None,  # important!! default does not work
        )

        for msgProc in cmndArgs:

            #icm.ANN_here("thisArg={thisArg}".format(thisArg=msgProc))

            #for msg in mbox:
            for key in mbox.iterkeys():
                try:
                    msg = mbox[key]
                except email.errors.MessageParseError:
                    icm.EH_problem_info(msg)
                    continue  # The message is malformed. Just leave it.

                try:
                    eval(msgProc + '(bxoId, sr, inMailDir, mbox, key, msg)')
                except Exception as e:
                    icm.EH_critical_exception(e)
                    icm.EH_problem_info(
                        "Invalid Action: {msgProc}".format(msgProc=msgProc))
                    raise  # NOTYET, in production, the raise should be commented out

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