Exemple #1
0
def kill_other_running_instances():
    """Ensure that only this instance is running."""
    log.debug("Killing other running instances of the application.")
    pid, exe_dir = os.getpid(), Path(sys.executable).resolve().parent
    for proc in Process.GetProcessesByName(app.name):
        if Path(proc.MainModule.FileName).resolve().parent != exe_dir:
            continue
        if proc.Id != os.getpid():
            proc.Kill()
Exemple #2
0
    def getProcessHanddle(name):
        '''
        Get window handler from the name of process. Process also has
        Handle property which gives the handle of window.
        '''
        p = Process.GetProcessesByName(name)

        if len(p) == 0:
            raise RuntimeError("Error: We cann't detect BlueStack.")
        return p[0].MainWindowHandle
    def wait_until_application_has_stopped(self, name, timeout):  # pylint:disable=no-self-use
        """Waits until no process with the given name exists.

        `name` is the name of the process

        `timeout` is the maximum time to wait as a Robot time string.

        Example:
        | Wait Until Application Has Stopped | calc | # waits until calc.exe process does not exist |
        """
        timeout = timestr_to_secs(timeout)
        Wait.until_true(
            lambda: not Process.GetProcessesByName(name), timeout,
            "Application '{}' did not exit within {}".format(
                name, secs_to_timestr(timeout)))
Exemple #4
0
 def cleanupOldAssemblies(self):
     revitInstances = list(Process.GetProcessesByName('Revit'))
     revitVersionStr = self.getRevitVersionStr()
     if len(revitInstances) > 1:
         reportv(
             'Multiple Revit instance are running...Skipping DLL Cleanup')
     elif len(revitInstances) == 1 and not self.isReloadingScripts():
         reportv('Cleaning up old DLL files...')
         files = os.listdir(self.userTempFolder)
         for f in files:
             if f.startswith(self.settings.pyRevitAssemblyName +
                             revitVersionStr):
                 try:
                     os.remove(op.join(self.userTempFolder, f))
                     reportv('Existing .Dll Removed: {0}'.format(f))
                 except:
                     reportv('Error deleting .DLL file: {0}'.format(f))
Exemple #5
0
def get_revit_instance_count():
    return len(list(Process.GetProcessesByName(HOST_APP.proc_name)))
Exemple #6
0
def avLookup():
    summary = printHeader("ANTIVIRUS CHECK")
    table = {
        'mcshield' :  "McAfee AV",
        'FrameworkService' :  "McAfee AV",
        'naPrdMgr' :  "McAfee AV",
        'windefend' :  "Windows Defender AV",
        'MSASCui' :  "Windows Defender AV",
        'msmpeng' :  "Windows Defender AV",
        'msmpsvc' :  "Windows Defender AV",
        'WRSA' :  "WebRoot AV",
        'savservice' :  "Sophos AV",
        'TMCCSF' :  "Trend Micro AV",
        'ntrtscan': "TrendMicro OfficeScan",
        "symantec antivirus" :  "Symantec AV",
        'ccSvcHst' :  "Symantec Endpoint Protection",
        'TaniumClient' :  "Tanium",
        'mbae' :  "MalwareBytes Anti-Exploit",
        'parity' :  "Bit9 application whitelisting",
        'cb' :  "Carbon Black behavioral analysis",
        "bds-vision" :  "BDS Vision behavioral analysis",
        'Triumfant' :  "Triumfant behavioral analysis",
        'CSFalcon' :  "CrowdStrike Falcon EDR",
        'ossec' :  "OSSEC intrusion detection",
        'TmPfw' :  "Trend Micro firewall",
        'dgagent' :  "Verdasys Digital Guardian DLP",
        'kvoop' :  "Forcepoint and others",
        'xagt' :  "FireEye Endpoint Agent",
        'bdservicehost': 'BitDefender AV',
        'bdagent': 'BitDefender AV',
        'fsav32': 'F-Secure AV',
        'ashServ': "Avast! AV",
        'AVENGINE': "Panda AV",
        'avgemc': "AVG AV",
        'tmntsrv': "TrendMicro AV",
        'nacapsvc': "Norton AV",
        'avp': "Kaspersky AV"
    }

    states = {
        "262144": "Up to date/Disabled",
        "262160": "Out of date/Disabled",
        "266240": "Up to date/Enabled",
        "266256": "Out of date/Enabled",
        "393216": "Up to date/Disabled",
        "393232": "Out of date/Disabled",
        "393488": "Out of date/Disabled",
        "397312": "Up to date/Enabled",
        "397328": "Out of date/Enabled",
        "397584": "Out of date/Enabled",
        "397568": "Up to date/Enabled",
        "393472": "Up to date/Disabled"
    }

    results = {}
    for av, name in table.items():
        proc = Process.GetProcessesByName(av)
        if proc:
            summary += "{0:<15}: {1}\n".format("AVProduct", name)
            summary += "{0:<15}: {1}\n".format("ProcessName", proc[0].ProcessName)
            summary += "{0:<15}: {1}\n\n".format("PID", proc[0].Id)


    scope = ManagementScope(r"\\%s\root\securitycenter2" % Env.MachineName)
    query = "Select * from antivirusproduct"
    search = ManagementObjectSearcher(scope, WqlObjectQuery(query), None)
    for result in search.Get():
        summary += "{0:<22}: {1}\n".format("Display Name", result.GetPropertyValue("displayName"))
        summary += "{0:<22}: {1}\n".format("Signed Product EXE:", result.GetPropertyValue("pathToSignedProductExe"))
        summary += "{0:<22}: {1}\n".format("Signed Reporting EXE:", result.GetPropertyValue("pathToSignedReportingExe"))
        summary += "{0:<22}: {1}\n".format("Product State", states.get(result.GetPropertyValue("productState").ToString()) or result.GetPropertyValue("productState") )
        summary += "{0:<22}: {1}\n\n".format("Update Time", result.GetPropertyValue("timestamp"))

    return summary
    def InitializeProcess(self):
        # Set the plugin specific settings.
        self.SingleFramesOnly = False
        self.PluginType = PluginType.Simple
        version = self.GetFloatPluginInfoEntry("Version")

        # Set the process specific settings.
        self.ProcessPriority = ProcessPriorityClass.BelowNormal
        self.UseProcessTree = True
        self.PopupHandling = True
        self.StdoutHandling = True
        self.SetEnvironmentVariable("KMP_DUPLICATE_LIB_OK", "TRUE")

        # Initialize start and end frame
        self.FramesStartTime = 0
        self.FramesEndTime = 0

        self.Framecount = 0
        self.DelayedFailure = False
        self.FailureMessage = ""
        self.HandleProgress = True

        self.FailWithoutFinishedMessage = False
        self.FailOnExistingAEProcess = False
        self.RenderSuccess = False

        self.LocalRendering = False
        self.NetworkFilePath = ""
        self.LocalFilePath = ""

        self.MultiMachine = False
        self.MultiMachineStartFrame = -1
        self.MultiMachineEndFrame = -1

        self.TempSceneFilename = ""

        self.PrintCudaWarningOnce = False

        # The Optical Flares License popup uses a wxWindowClassNR control for the "OK" button, so we need to check for that class too.
        self.PopupButtonClasses = ("Button", "wxWindowClassNR", "TButton")

        # Set the stdout handlers.
        self.AddStdoutHandlerCallback(
            "aerender version (.*)").HandleCallback += self.HandleRenderVersion

        self.AddStdoutHandlerCallback(
            ".*GL_VERS: 32Prog Error: 1280.*|.*Create Buffer Error: 1280.*"
        ).HandleCallback += self.HandleNonFatalError
        self.AddStdoutHandlerCallback(
            ".*error: internal verification failure, sorry.*"
        ).HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback("INFO:This project contains .*"
                                      ).HandleCallback += self.HandleStdoutInfo
        self.AddStdoutHandlerCallback(
            "This project contains a reference to a missing effect.*"
        ).HandleCallback += self.HandleStdoutInfo
        self.AddStdoutHandlerCallback(
            ".*Unable to obtain a license.*"
        ).HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            "unexpected failure during application startup"
        ).HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            "Invalid Serial Number").HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            ".*Error:.*").HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            "aerender ERROR.*").HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            ".*AEsend failed to send apple event.*"
        ).HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            ".*There is an error in background rendering so switching to foreground rendering.*"
        ).HandleCallback += self.HandleStdoutError
        self.AddStdoutHandlerCallback(
            "INFO:(The following layer dependencies are missing)"
        ).HandleCallback += self.HandleMissingLayerDependencies
        self.AddStdoutHandlerCallback(
            "a layer has missing dependencies.*"
        ).HandleCallback += self.HandleMissingLayerDependencies
        self.AddStdoutHandlerCallback(
            ".*Finished composition.*"
        ).HandleCallback += self.HandleRenderSuccess  #English
        self.AddStdoutHandlerCallback(
            ".*fin de la composition.*"
        ).HandleCallback += self.HandleRenderSuccess  #French
        self.AddStdoutHandlerCallback(
            ".*Komposition.*beendet.*"
        ).HandleCallback += self.HandleRenderSuccess  #German
        self.AddStdoutHandlerCallback(
            ".*After Effects successfully launched.*"
        ).HandleCallback += self.HandleRenderSuccess  #To handle cases where 'Finished composition' never appears.
        self.AddStdoutHandlerCallback(
            "WARNING:(After Effects [Ww]arn[ui]ng: .*)"
        ).HandleCallback += self.HandleStdoutWarning  #English/#German
        self.AddStdoutHandlerCallback(
            ".*NVAPI error.*").HandleCallback += self.HandleCudaError

        #This code is left undeleted because the new progress update is untested in versions prior to 13, so the code remains to ensure old versions don't change behaviour unexpectedly.
        if version >= 13:
            # These stdout handlers watch for timecode-based progress.
            self.AddStdoutHandlerCallback(
                "PROGRESS:\s+ Start: (\d+[:;]\d+[:;]\d+[:;]\d+).*"
            ).HandleCallback += self.HandleProgressTimecodeStart
            self.AddStdoutHandlerCallback(
                "PROGRESS:\s+ End: (\d+[:;]\d+[:;]\d+[:;]\d+).*"
            ).HandleCallback += self.HandleProgressTimecodeEnd
            self.AddStdoutHandlerCallback(
                "PROGRESS:.*(\d+[:;]\d+[:;]\d+[:;]\d+).*"
            ).HandleCallback += self.HandleStdoutTimecodeProgress

            # These stdout handlers watch for frame-based progress.
            self.AddStdoutHandlerCallback(
                "PROGRESS:\s+ Start: (\d+)[^:;]*"
            ).HandleCallback += self.HandleProgressFrameStart
            self.AddStdoutHandlerCallback(
                "PROGRESS:\s+ End: (\d+)[^:;]*"
            ).HandleCallback += self.HandleProgressFrameEnd
            self.AddStdoutHandlerCallback(
                "PROGRESS:\s+ (\d+)[^:;]*"
            ).HandleCallback += self.HandleStdoutFrameProgress
        else:
            self.AddStdoutHandlerCallback(
                "PROGRESS:\\s+([0-9]+[:;]*[0-9]*[:;]*[0-9]*[:;]*[0-9]*).*"
            ).HandleCallback += self.HandleStdoutProgressLegacy

        # Trapcode licensing issues.
        self.AddStdoutHandlerCallback(
            ".*is using the same serial number.*"
        ).HandleCallback += self.HandleStdoutError

        # Format issue handling
        if version < 15:
            # Certain old versions of After Effects would output this message when they encountered
            # a bug that caused them to forget what format they were supposed to output
            # to and just output single frame AVI files.
            # Around version 15, it started outputting this message for other--non-error--reasons.
            # We don't know exactly which version this happened since we can't install versions older than 15 anymore.
            # We at least know that in version 15 and later we don't want to fail the render if we see this message.
            self.AddStdoutHandlerCallback(
                ".*Adding specified comp to Render Queue.*"
            ).HandleCallback += self.HandleStdoutFormat

        # Set the popup ignorers.
        self.AddPopupIgnorer("Motion Sketch")
        self.AddPopupIgnorer("The Smoother")
        self.AddPopupIgnorer("Time Controls")
        self.AddPopupIgnorer("Brush Tips")
        self.AddPopupIgnorer("The Wiggler")
        self.AddPopupIgnorer("Tracker Controls")

        # Generic After Effects I have died pop-up dialog.
        # This generic pop-up dialog occurs for many reasons including the machine running out of RAM.
        # Adobe advise purge caches, increase RAM / memory allocation, decrease multi-machine / multi-processing.
        self.AddPopupHandler(".*After Effects.*", "OK;Yes")

        # Handle Adobe CS4 Color Finesse LE - Serial Number Dialog Registration Window.
        self.AddPopupHandler(".*On-line Registration.*", "No")

        # Handle Optical Flares License popup (the "OK" button is actually called "panel").
        self.AddPopupHandler(".*Optical Flares License.*", "panel")

        # "Tablet Version Mismatch", Message "Please reinstall the tablet software.
        self.AddPopupHandler("Tablet Version Mismatch", "OK")

        # Handle QuickTime popup dialog.
        # "QuickTime does not support the current Display Setting.  Please change it and restart this application."
        self.AddPopupHandler("Unsupported Display", "OK")
        self.AddPopupHandler("Nicht.*", "OK")

        # Handle Debug Event pop-up dialog. Typically occurs after a generic "After Effects" title pop-up dilaog which is handled separately.
        self.AddPopupHandler("After Effects Debug Event", "Continue")

        # Handle generic old After Effects app crash.
        self.AddPopupHandler(".*AfterFX.exe.*", "OK")
        self.AddPopupHandler(".*Application Error.*", "OK")
        self.AddPopupHandler(".*Microsoft Visual.*", "OK")

        self.FailWithoutFinishedMessage = self.GetBooleanConfigEntryWithDefault(
            "FailWithoutFinishedMessage", False)
        self.LogInfo("Fail Without Finished Message set to: %s" %
                     self.FailWithoutFinishedMessage)

        # Read in the Fail On Existing AE Process setting, which can be overridden in the plugin info file.
        if self.GetBooleanPluginInfoEntryWithDefault(
                "OverrideFailOnExistingAEProcess", False):
            self.FailOnExistingAEProcess = self.GetBooleanPluginInfoEntryWithDefault(
                "FailOnExistingAEProcess", True)
            self.LogInfo(
                "Fail on Existing After Effects process: %s (from plugin info override)"
                % self.FailOnExistingAEProcess)
        else:
            self.FailOnExistingAEProcess = self.GetBooleanConfigEntryWithDefault(
                "FailOnExistingAEProcess", False)
            self.LogInfo("Fail on Existing After Effects process: %s" %
                         self.FailOnExistingAEProcess)

        if self.FailOnExistingAEProcess:
            self.LogInfo(
                "Scanning for Existing After Effects GUI process which can sometimes cause 3rd party AE plugins to malfunction during network rendering"
            )
            processName = "After Effects"
            if ProcessUtils.IsProcessRunning(processName):
                self.LogWarning("Found Existing %s process" % processName)
                process = Process.GetProcessesByName(processName)[0]
                self.FailRender(
                    "FailOnExistingAEProcess is enabled, and a process %s with pid %d exists - shut down this copy of After Effects to enable network rendering on this machine"
                    % (processName, process.Id))
            else:
                self.LogInfo(
                    "No instances of After Effects currently running were found"
                )