コード例 #1
0
ファイル: monitor.py プロジェクト: Lightjohn/lutris
    def __init__(self, include_processes, exclude_processes,
                 exclusion_process):
        """Creates a process monitor

        All arguments accept process names like the ones in EXCLUDED_PROCESSES

        Args:
            exclude_processes (str or list): list of processes that shouldn't be monitored
            include_processes (str or list): list of process that should be forced to be monitored
            exclusion_process (str): If given, ignore all process before this one
        """

        # process names from /proc only contain 15 characters
        self.include_processes = [
            x[0:15] for x in self.parse_process_list(include_processes)
        ]
        self.exclude_processes = [
            x[0:15] for x in EXCLUDED_PROCESSES +
            self.parse_process_list(exclude_processes)
        ]
        self.exclusion_process = exclusion_process
        self.old_pids = system.get_all_pids()
        # Keep a copy of the monitored processes to allow comparisons
        self.monitored_processes = defaultdict(list)
        self.children = []
コード例 #2
0
    def __init__(self,
                 command,
                 runner=None,
                 env={},
                 rootpid=None,
                 term=None,
                 watch=True,
                 cwd=None,
                 include_processes=[],
                 exclude_processes=[],
                 log_buffer=None):
        """Thread init"""
        threading.Thread.__init__(self)
        self.ready_state = True
        self.env = env
        self.original_env = {}
        self.command = command
        self.runner = runner
        self.game_process = None
        self.return_code = None
        self.rootpid = rootpid or os.getpid()
        self.terminal = term
        self.watch = watch
        self.is_running = True
        self.stdout = ''
        self.attached_threads = []
        self.cycles_without_children = 0
        self.startup_time = time.time()
        self.monitoring_started = False
        self.daemon = True
        self.error = None
        if isinstance(include_processes, str):
            include_processes = shlex.split(include_processes)
        if isinstance(exclude_processes, str):
            exclude_processes = shlex.split(exclude_processes)
        # process names from /proc only contain 15 characters
        self.include_processes = [x[0:15] for x in include_processes]
        self.exclude_processes = [
            x[0:15] for x in (EXCLUDED_PROCESSES + exclude_processes)
        ]
        self.log_buffer = log_buffer
        self.stdout_monitor = None

        # Keep a copy of the monitored processes to allow comparisons
        self.monitored_processes = defaultdict(list)

        # Keep a copy of previously running processes
        self.old_pids = system.get_all_pids()

        self.cwd = self.set_cwd(cwd)
        self.env_string = ''
        for (k, v) in self.env.items():
            self.env_string += '%s="%s" ' % (k, v)

        self.command_string = ' '.join(
            ['"%s"' % token for token in self.command])
コード例 #3
0
ファイル: thread.py プロジェクト: notjuliee/lutris
    def __init__(self,
                 command,
                 runner=None,
                 env={},
                 rootpid=None,
                 term=None,
                 watch=True,
                 cwd=None,
                 include_processes=[],
                 log_buffer=None):
        """Thread init"""
        threading.Thread.__init__(self)
        self.env = env
        self.original_env = {}
        self.command = command
        self.runner = runner
        self.game_process = None
        self.return_code = None
        self.rootpid = rootpid or os.getpid()
        self.terminal = term
        self.watch = watch
        self.is_running = True
        self.stdout = ''
        self.attached_threads = []
        self.cycles_without_children = 0
        self.startup_time = time.time()
        self.monitoring_started = False
        self.daemon = True
        self.error = None
        self.include_processes = include_processes
        self.log_buffer = log_buffer
        self.stdout_monitor = None

        # Keep a copy of previously running processes
        self.old_pids = system.get_all_pids()

        if cwd:
            self.cwd = cwd
        elif self.runner:
            self.cwd = runner.working_dir
        else:
            self.cwd = '/tmp'
        self.cwd = os.path.expanduser(self.cwd)

        self.env_string = ''
        for (k, v) in self.env.items():
            self.env_string += '%s="%s" ' % (k, v)

        self.command_string = ' '.join(
            ['"%s"' % token for token in self.command])
コード例 #4
0
ファイル: thread.py プロジェクト: Ryochan7/lutris
    def __init__(self, command, runner=None, env={}, rootpid=None, term=None,
                 watch=True, cwd=None, include_processes=[], exclude_processes=[], log_buffer=None):
        """Thread init"""
        threading.Thread.__init__(self)
        self.ready_state = True
        self.env = env
        self.original_env = {}
        self.command = command
        self.runner = runner
        self.game_process = None
        self.return_code = None
        self.rootpid = rootpid or os.getpid()
        self.terminal = term
        self.watch = watch
        self.is_running = True
        self.stdout = ''
        self.attached_threads = []
        self.cycles_without_children = 0
        self.startup_time = time.time()
        self.monitoring_started = False
        self.daemon = True
        self.error = None
        if isinstance(include_processes, str):
            include_processes = shlex.split(include_processes)
        if isinstance(exclude_processes, str):
            exclude_processes = shlex.split(exclude_processes)
        # process names from /proc only contain 15 characters
        self.include_processes = [x[0:15] for x in include_processes]
        self.exclude_processes = [x[0:15] for x in (EXCLUDED_PROCESSES + exclude_processes)]
        self.log_buffer = log_buffer
        self.stdout_monitor = None
        self.monitored_processes = defaultdict(list)  # Keep a copy of the monitored processes to allow comparisons

        # Keep a copy of previously running processes
        self.old_pids = system.get_all_pids()

        self.cwd = self.set_cwd(cwd)
        self.env_string = ''
        for (k, v) in self.env.items():
            self.env_string += '%s="%s" ' % (k, v)

        self.command_string = ' '.join(
            ['"%s"' % token for token in self.command]
        )
コード例 #5
0
ファイル: thread.py プロジェクト: RobLoach/lutris
    def __init__(self, command, runner=None, env={}, rootpid=None, term=None,
                 watch=True, cwd=None, include_processes=[]):
        """Thread init"""
        threading.Thread.__init__(self)
        self.env = env
        self.original_env = {}
        self.command = command
        self.runner = runner
        self.game_process = None
        self.return_code = None
        self.rootpid = rootpid or os.getpid()
        self.terminal = term
        self.watch = watch
        self.is_running = True
        self.stdout = ''
        self.attached_threads = []
        self.cycles_without_children = 0
        self.max_cycles_without_children = 15
        self.startup_time = time.time()
        self.monitoring_started = False
        self.daemon = True
        self.error = None
        self.include_processes = include_processes

        # Keep a copy of previously running processes
        self.old_pids = system.get_all_pids()

        if cwd:
            self.cwd = cwd
        elif self.runner:
            self.cwd = runner.working_dir
        else:
            self.cwd = '/tmp'
        self.cwd = os.path.expanduser(self.cwd)

        self.env_string = ''
        for (k, v) in self.env.items():
            self.env_string += '%s="%s" ' % (k, v)

        self.command_string = ' '.join(
            ['"%s"' % token for token in self.command]
        )