コード例 #1
0
    def find_task(self, tid):
        tasks = Proc().tasks

        if re.match('[0-9]+$', tid):
            return tasks[tid]
        else:
            candidates = []
            for i in tasks.values():
                if tid in str(i.cmdline):
                    candidates.append(i)
            if len(candidates) == 1:
                return candidates[0]

        return None
コード例 #2
0
    def find_task(self, tid):
        tasks = Proc().tasks

        if re.match('[0-9]+$', tid):
            return tasks[tid]
        else:
            candidates = []
            for i in tasks.values():
                if tid in str(i.cmdline):
                    candidates.append(i)
            if len(candidates) == 1:
                return candidates[0]

        return None
コード例 #3
0
    def execute(self, args):
        # ignore arguments
        tasks = Proc().tasks
        if args.d:
            tasks = Proc().dead_tasks

        max_key_len = max(3, *[len(i) for i in Proc().content().keys()])
        max_user_len = max(
            3, *[
                len(i.principal.id) for i in Proc().content().values()
                if getattr(i, 'principal', None)
            ])

        self.write("%s    %s%s TIME CMD\n" %
                   ("TID".rjust(max_key_len), "PTID    ".rjust(max_key_len)
                    if args.l else '', "USER   ".ljust(max_user_len)))

        for tid, task in tasks.items():
            ptid = task.ptid
            self.write("%s %s   %s %s %s\n" %
                       (tid.rjust(max_key_len),
                        (ptid + ' ').rjust(max_key_len) if args.l else '',
                        (task.principal.id
                         if task.principal else '-').ljust(max_user_len),
                        datetime.timedelta(0, int(task.uptime)), task.cmdline))
コード例 #4
0
    def execute(self, args):
        # ignore arguments
        tasks = Proc().tasks
        if args.d:
            tasks = Proc().dead_tasks

        max_key_len = max(3, *[len(i) for i in Proc().content().keys()])
        max_user_len = max(3, *[len(i.principal.id) for i in Proc().content().values() if getattr(i, 'principal', None)])

        self.write("%s    %s%s TIME CMD\n" % ("TID".rjust(max_key_len),
                                           "PTID    ".rjust(max_key_len) if args.l else '',
                                           "USER   ".ljust(max_user_len)))

        for tid, task in tasks.items():
            ptid = task.ptid
            self.write("%s %s   %s %s %s\n" %
                       (tid.rjust(max_key_len),
                        (ptid + ' ').rjust(max_key_len) if args.l else '',
                        (task.principal.id if task.principal else '-').ljust(max_user_len),
                        datetime.timedelta(0, int(task.uptime)),
                        task.cmdline))
コード例 #5
0
ファイル: base.py プロジェクト: AsherBond/opennode-management
    def register(self, d, args, command_line, ptid=None):
        subj = yield defer.maybeDeferred(self.subject_from_raw, args)

        # XXX: for some reason, when I let subject to be a generator instance, I get an empty
        # generator in the ComputeTasks container, while it magically works when I save it as a tuple
        # under item.subject
        if type(subj) is proxy.PersistentProxy:
            subj = subj.remove_persistent_proxy()
        assert type(subj) is tuple, "subject of '%s' must be a tuple, got %s" % (self.name, type(subj))

        self.pid = Proc.register(d, subj, command_line, ptid, write_buffer=self.write_buffer,
                                 principal=self.protocol.principal)
        defer.returnValue(self.pid)
コード例 #6
0
    def register(self, d, args, command_line, ptid=None):
        subj = yield defer.maybeDeferred(self.subject_from_raw, args)

        # XXX: for some reason, when I let subject to be a generator instance, I get an empty
        # generator in the ComputeTasks container, while it magically works when I save it as a tuple
        # under item.subject
        if type(subj) is proxy.PersistentProxy:
            subj = subj.remove_persistent_proxy()
        assert type(
            subj) is tuple, "subject of '%s' must be a tuple, got %s" % (
                self.name, type(subj))

        self.pid = Proc.register(d,
                                 subj,
                                 command_line,
                                 ptid,
                                 write_buffer=self.write_buffer,
                                 principal=self.protocol.principal)
        defer.returnValue(self.pid)
コード例 #7
0
def find_daemon_in_proc(daemontype):
    for pid, process in Proc().tasks.iteritems():
        if type(process.subject) is daemontype:
            return process.subject
コード例 #8
0
ファイル: base.py プロジェクト: AsherBond/opennode-management
 def unregister(self):
     Proc.unregister(self.pid)
コード例 #9
0
 def unregister(self):
     Proc.unregister(self.pid)