Ejemplo n.º 1
0
    def wait(self, timeout=None):
        """Wait for the browser to exit."""
        self.process_handler.wait(timeout=timeout)

        if sys.platform != 'win32':
            for name in self.names:
                for pid in get_pids(name, self.process_handler.pid):
                    self.process_handler.pid = pid
                    self.process_handler.wait(timeout=timeout)
Ejemplo n.º 2
0
    def wait(self, timeout=None):
        """Wait for the browser to exit."""
        self.process_handler.wait(timeout=timeout)

        if sys.platform != 'win32':
            for name in self.names:
                for pid in get_pids(name, self.process_handler.pid):
                    self.process_handler.pid = pid
                    self.process_handler.wait(timeout=timeout)
Ejemplo n.º 3
0
 def updatePidList(self):
     """Updates the list of PIDs we're interested in"""
     try:
         self.pidList = [self.primaryPid]
         childPids = mozpid.get_pids(self.childProcess)
         for pid in childPids:
             os.stat('/proc/%s' % pid)
             self.pidList.append(pid)
     except:
         print "WARNING: problem updating child PID's"
Ejemplo n.º 4
0
 def updatePidList(self):
     """Updates the list of PIDs we're interested in"""
     try:
         self.pidList = [self.primaryPid]
         childPids = mozpid.get_pids(self.childProcess)
         for pid in childPids:
             os.stat('/proc/%s' % pid)
             self.pidList.append(pid)
     except:
         print "WARNING: problem updating child PID's"
Ejemplo n.º 5
0
    def TerminateAllProcesses(self, timeout, *process_names):
        """Helper function to terminate all processes with the given process name

        Args:
            process_names: String or strings containing the process name, i.e. "firefox"
        """
        results = []
        for process_name in process_names:
            for pid in mozpid.get_pids(process_name):
                ret = self._TerminateProcess(pid, timeout)
                if ret:
                    results.append("%s (%s): %s" % (process_name, pid, ret))
        return ",".join(results)
Ejemplo n.º 6
0
 def stop(self, kill_signal=signal.SIGTERM):
     """Kill the browser"""
     if sys.platform != 'win32':
         self.process_handler.kill()
         for name in self.names:
             for pid in get_pids(name, self.process_handler.pid):
                 self.process_handler.pid = pid
                 self.process_handler.kill()
     else:
         try:
             self.process_handler.kill(group=True)
         except Exception, e:
             raise Exception('Cannot kill process, '+type(e).__name__+' '+e.message)
Ejemplo n.º 7
0
    def TerminateAllProcesses(self, timeout, *process_names):
        """Helper function to terminate all processes with the given process name

        Args:
            process_names: String or strings containing the process name, i.e. "firefox"
        """
        results = []
        for process_name in process_names:
            for pid in mozpid.get_pids(process_name):
                ret = self._TerminateProcess(pid, timeout)
                if ret:
                    results.append("%s (%s): %s" % (process_name, pid, ret))
        return ",".join(results)
Ejemplo n.º 8
0
    def __init__(self, process, counters=None):
        """Args:
             counters: A list of counters to monitor. Any counters whose name
             does not match a key in 'counterDict' will be ignored.
        """

        CounterManager.__init__(self)

        # the last process is the useful one
        self.pid = mozpid.get_pids(process)[-1]

        self._loadCounters()
        self.registerCounters(counters)
Ejemplo n.º 9
0
def check_for_process(processName):
    """
        Use to determine if process of the given name is still running.

        Returns:
        detected -- True if process is detected to exist, False otherwise
        output -- if process exists, stdout of the process, [] otherwise
    """
    name = os.path.basename(processName)
    process = get_pids(name)

    if process:
        return True, process
    return False, []
Ejemplo n.º 10
0
    def __init__(self, process, counters=None,
                 childProcess="plugin-container"):
        """Args:
             counters: A list of counters to monitor. Any counters whose name
             does not match a key in 'counterDict' will be ignored.
        """

        CounterManager.__init__(self)
        self.childProcess = childProcess
        self.pidList = []
        self.primaryPid = mozpid.get_pids(process)[-1]
        os.stat('/proc/%s' % self.primaryPid)

        self._loadCounters()
        self.registerCounters(counters)
Ejemplo n.º 11
0
 def stop(self):
     """Kill the app"""
     if self.process_handler is None:
         return
     
     if sys.platform != 'win32':
         self.process_handler.kill()
         for name in self.names:
             for pid in get_pids(name, self.process_handler.pid):
                 self.process_handler.pid = pid
                 self.process_handler.kill()
     else:
         try:
             self.process_handler.kill(group=True)
         except Exception, e:
             raise Exception('Cannot kill process, '+type(e).__name__+' '+e.message)
Ejemplo n.º 12
0
    def ProcessesWithNames(self, *process_names):
        """Returns a list of processes running with the given name(s):
        [(pid, name), (...), ...]
        Useful to check whether a Browser process is still running

        Args:
            process_names: String or strings containing process names, i.e. "firefox"

        Returns:
            An array with a list of processes in the list which are running
        """
        processes_with_names = []
        for process_name in process_names:
            pids = mozpid.get_pids(process_name)
            processes_with_names.extend([(pid, process_name) for pid in pids])

        return processes_with_names
Ejemplo n.º 13
0
    def ProcessesWithNames(self, *process_names):
        """Returns a list of processes running with the given name(s):
        [(pid, name), (...), ...]
        Useful to check whether a Browser process is still running

        Args:
            process_names: String or strings containing process names, i.e. "firefox"

        Returns:
            An array with a list of processes in the list which are running
        """
        processes_with_names = []
        for process_name in process_names:
            pids = mozpid.get_pids(process_name)
            processes_with_names.extend([(pid, process_name) for pid in pids])

        return processes_with_names
    def __init__(self,
                 process,
                 counters=None,
                 childProcess="plugin-container"):
        """Args:
             counters: A list of counters to monitor. Any counters whose name
             does not match a key in 'counterDict' will be ignored.
        """

        CounterManager.__init__(self)
        self.childProcess = childProcess
        self.pidList = []
        self.primaryPid = mozpid.get_pids(process)[-1]
        os.stat('/proc/%s' % self.primaryPid)

        self._loadCounters()
        self.registerCounters(counters)
Ejemplo n.º 15
0
    def stop(self):
        """Kill the app"""
        if self.process_handler is None:
            return

        if sys.platform != 'win32':
            self.process_handler.kill()
            for name in self.names:
                for pid in get_pids(name, self.process_handler.pid):
                    self.process_handler.pid = pid
                    self.process_handler.kill()
        else:
            try:
                self.process_handler.kill(group=True)
            except Exception, e:
                raise Exception('Cannot kill process, ' + type(e).__name__ +
                                ' ' + e.message)