• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python options.split_namespec函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中supervisor.options.split_namespec函数的典型用法代码示例。如果您正苦于以下问题:Python split_namespec函数的具体用法?Python split_namespec怎么用?Python split_namespec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了split_namespec函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: do_clear

    def do_clear(self, arg):
        if not self.ctl.upcheck():
            return

        names = arg.split()

        if not names:
            self.ctl.output("Error: clear requires a process name")
            self.help_clear()
            return

        supervisor = self.ctl.get_supervisor()

        if "all" in names:
            results = supervisor.clearAllProcessLogs()
            for result in results:
                result = self._clearresult(result)
                self.ctl.output(result)
        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                try:
                    result = supervisor.clearProcessLogs(name)
                except xmlrpclib.Fault, e:
                    error = self._clearresult(
                        {"status": e.faultCode, "name": process_name, "group": group_name, "description": e.faultString}
                    )
                    self.ctl.output(error)
                else:
                    name = make_namespec(group_name, process_name)
                    self.ctl.output("%s: cleared" % name)
开发者ID:JeancarloBarrios,项目名称:adtp,代码行数:31,代码来源:supervisorctl.py


示例2: status

    def status(self, names):
        '''
            status <name>\t\tGet status for a single process
            status <gname>:*\tGet status for all processes in a group
            status <name> <name>\tGet status for multiple named processes
            status\t\t\tGet all process status info
        '''
        self.reread()
        all_infos = self.supervisor.getAllProcessInfo()

        if "all" in names:
            matching_infos = all_infos
        else:
            matching_infos = []

            for name in names:
                bad_name = True
                group_name, process_name = split_namespec(name)

                for info in all_infos:
                    matched = info['group'] == group_name
                    if process_name is not None:
                        matched = matched and info['name'] == process_name

                    if matched:
                        bad_name = False
                        matching_infos.append(info)

                if bad_name:
                    if process_name is None:
                        msg = "%s: ERROR (no such group)" % group_name
                    else:
                        msg = "%s: ERROR (no such process)" % name
                    self.logger.info(msg)
        return matching_infos
开发者ID:bernytt,项目名称:cmz,代码行数:35,代码来源:supervisor_rpc_api.py


示例3: do_clear

    def do_clear(self, arg):
        if not self.ctl.upcheck():
            return

        names = arg.split()

        if not names:
            self.ctl.output('Error: clear requires a process name')
            self.help_clear()
            return

        supervisor = self.ctl.get_supervisor()

        if 'all' in names:
            results = supervisor.clearAllProcessLogs()
            for result in results:
                result = self._clearresult(result)
                self.ctl.output(result)
        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                try:
                    supervisor.clearProcessLogs(name)
                except xmlrpclib.Fault as e:
                    error = self._clearresult({'status': e.faultCode,
                                               'name': process_name,
                                               'group': group_name,
                                               'description': e.faultString})
                    self.ctl.output(error)
                else:
                    name = make_namespec(group_name, process_name)
                    self.ctl.output('%s: cleared' % name)
开发者ID:pataquets,项目名称:supervisor,代码行数:32,代码来源:supervisorctl.py


示例4: sendProcessSignal

    def sendProcessSignal(self, name, signal = signal.SIGHUP):
        """ Send an arbitrary UNIX signal to the process named by name

        @param string name The name of the process to signal (or 'group:name')
        @param int signal the integer UNIX signal to send. SIGHUP by default.
        @return boolean result
        """

        self._update('sendProcessSignal')

        group, process = self._getGroupAndProcess(name)

        if process is None:
            group_name, process_name = split_namespec(name)
            return self.sendGroupSignal(group_name, signal = signal)

        if process.get_state() not in RUNNING_STATES:
           raise RPCError(Faults.NOT_RUNNING)

        msg = process.signal(signal)

        if not msg is None:
            raise RPCError(Faults.FAILED, msg)

        cb = lambda: True
        cb.delay = 0
        cb.rpcinterface = self

        return cb
开发者ID:Weebly,项目名称:supervisor,代码行数:29,代码来源:rpcinterface.py


示例5: do_status

    def do_status(self, arg):
        if not self.ctl.upcheck():
            return

        supervisor = self.ctl.get_supervisor()
        all_infos = supervisor.getAllProcessInfo()

        names = arg.split()
        if not names or "all" in names:
            matching_infos = all_infos
        else:
            matching_infos = []

            for name in names:
                bad_name = True
                group_name, process_name = split_namespec(name)

                for info in all_infos:
                    matched = info['group'] == group_name
                    if process_name is not None:
                        matched = matched and info['name'] == process_name

                    if matched:
                        bad_name = False
                        matching_infos.append(info)

                if bad_name:
                    if process_name is None:
                        msg = "%s: ERROR (no such group)" % group_name
                    else:
                        msg = "%s: ERROR (no such process)" % name
                    self.ctl.output(msg)
        self._show_statuses(matching_infos)
开发者ID:pataquets,项目名称:supervisor,代码行数:33,代码来源:supervisorctl.py


示例6: do_kill

    def do_kill(self, arg):
        if not self.ctl.upcheck():
            return

        args = arg.strip().split()
        if not args:
            self.ctl.output("Error: kill requires a signal and process name")
            self.help_kill()
            return

        signal = args[0]
        names = args[1:]

        if not names:
            self.ctl.output("Error: kill requires a process name")
            self.help_start()
            return

        for name in names:
            group_name, process_name = split_namespec(name)
            if process_name is None:
                results = self.laforge.killProcessGroup(group_name, signal)
                for result in results:
                    result = self._killresult(result)
                    self.ctl.output(result)
            else:
                try:
                    result = self.laforge.killProcess(name, signal)
                except xmlrpclib.Fault, e:
                    error = self._killresult({'status':e.faultCode,
                                               'name':name,
                                               'description':e.faultString})
                    self.ctl.output(error)
                else:
                    self.ctl.output('%s: signal sent' % name)
开发者ID:pombredanne,项目名称:mr.laforge,代码行数:35,代码来源:controllerplugin.py


示例7: signalProcess

    def signalProcess(self, name, signal):
        """ Send an arbitrary UNIX signal to the process named by name

        @param string name    Name of the process to signal (or 'group:name')
        @param string signal  Signal to send, as name ('HUP') or number ('1')
        @return boolean
        """

        self._update('signalProcess')

        group, process = self._getGroupAndProcess(name)

        if process is None:
            group_name, process_name = split_namespec(name)
            return self.signalProcessGroup(group_name, signal=signal)

        try:
            sig = signal_number(signal)
        except ValueError:
            raise RPCError(Faults.BAD_SIGNAL, signal)

        if process.get_state() not in RUNNING_STATES:
            raise RPCError(Faults.NOT_RUNNING)

        msg = process.signal(sig)

        if not msg is None:
            raise RPCError(Faults.FAILED, msg)

        return True
开发者ID:alexsilva,项目名称:supervisor,代码行数:30,代码来源:rpcinterface.py


示例8: handle_request

    def handle_request(self, request):
        if request.command != 'GET':
            request.error (400) # bad request
            return

        path, params, query, fragment = request.split_uri()

        if '%' in path:
            path = http_server.unquote(path)

        # strip off all leading slashes
        while path and path[0] == '/':
            path = path[1:]

        path, process_name_and_channel = path.split('/', 1)

        try:
            process_name, channel = process_name_and_channel.split('/', 1)
        except ValueError:
            # no channel specified, default channel to stdout
            process_name = process_name_and_channel
            channel = 'stdout'

        from supervisor.options import split_namespec
        group_name, process_name = split_namespec(process_name)

        group = self.supervisord.process_groups.get(group_name)
        if group is None:
            request.error(404) # not found
            return

        process = group.processes.get(process_name)
        if process is None:
            request.error(404) # not found
            return

        logfile = getattr(process.config, '%s_logfile' % channel, None)

        if logfile is None or not os.path.exists(logfile):
            # XXX problematic: processes that don't start won't have a log
            # file and we probably don't want to go into fatal state if we try
            # to read the log of a process that did not start.
            request.error(410) # gone
            return

        mtime = os.stat(logfile)[stat.ST_MTIME]
        request['Last-Modified'] = http_date.build_http_date(mtime)
        request['Content-Type'] = 'text/plain'
        # the lack of a Content-Length header makes the outputter
        # send a 'Transfer-Encoding: chunked' response

        request.push(tail_f_producer(request, logfile, 1024))

        request.done()
开发者ID:wowgeeker,项目名称:supervisor,代码行数:54,代码来源:http.py


示例9: force_process_state

 def force_process_state(self, namespec, state):
     """ Publishes a fake process event showing a state for the process. """
     application_name, process_name = split_namespec(namespec)
     # create payload from event
     payload = {'processname': process_name,
         'groupname': application_name,
         'state': state,
         'now': int(time.time()),
         'pid': 0,
         'expected': False}
     self.logger.debug('payload={}'.format(payload))
     self.publisher.send_process_event(payload)
开发者ID:julien6387,项目名称:supervisors,代码行数:12,代码来源:listener.py


示例10: stopProcess

    def stopProcess(self, name, wait=True):
        """ Stop a process named by name

        @param string name  The name of the process to stop (or 'group:name')
        @param boolean wait        Wait for the process to be fully stopped
        @return boolean result     Always return True unless error
        """
        self._update('stopProcess')

        group, process = self._getGroupAndProcess(name)

        if process is None:
            group_name, process_name = split_namespec(name)
            return self.stopProcessGroup(group_name, wait)

        if process.get_state() not in RUNNING_STATES:
            raise RPCError(Faults.NOT_RUNNING)

        msg = process.stop()
        if msg is not None:
            raise RPCError(Faults.FAILED, msg)

        # We'll try to reap any killed child. FWIW, reap calls waitpid, and
        # then, if waitpid returns a pid, calls finish() on the process with
        # that pid, which drains any I/O from the process' dispatchers and
        # changes the process' state.  I chose to call reap without once=True
        # because we don't really care if we reap more than one child.  Even if
        # we only reap one child. we may not even be reaping the child that we
        # just stopped (this is all async, and process.stop() may not work, and
        # we'll need to wait for SIGKILL during process.transition() as the
        # result of normal select looping).

        self.supervisord.reap()

        if wait and process.get_state() not in STOPPED_STATES:

            def onwait():
                # process will eventually enter a stopped state by
                # virtue of the supervisord.reap() method being called
                # during normal operations
                self.supervisord.options.logger.info(
                    'waiting for %s to stop' % process.config.name
                    )
                if process.get_state() not in STOPPED_STATES:
                    return NOT_DONE_YET
                return True

            onwait.delay = 0
            onwait.rpcinterface = self
            return onwait # deferred

        return True
开发者ID:Girgitt,项目名称:supervisor,代码行数:52,代码来源:rpcinterface.py


示例11: do_signal

    def do_signal(self, arg):
        if not self.ctl.upcheck():
            return

        args = arg.split()
        if len(args) < 2:
            self.ctl.output(
                'Error: signal requires a signal name and a process name')
            self.help_signal()
            return

        sig = args[0]
        names = args[1:]
        supervisor = self.ctl.get_supervisor()

        if 'all' in names:
            results = supervisor.signalAllProcesses(sig)
            for result in results:
                result = self._signalresult(result)
                self.ctl.output(result)

        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                if process_name is None:
                    try:
                        results = supervisor.signalProcessGroup(
                            group_name, sig
                            )
                        for result in results:
                            result = self._signalresult(result)
                            self.ctl.output(result)
                    except xmlrpclib.Fault as e:
                        if e.faultCode == xmlrpc.Faults.BAD_NAME:
                            error = "%s: ERROR (no such group)" % group_name
                            self.ctl.output(error)
                        else:
                            raise
                else:
                    try:
                        supervisor.signalProcess(name, sig)
                    except xmlrpclib.Fault as e:
                        error = self._signalresult({'status': e.faultCode,
                                                    'name': process_name,
                                                    'group': group_name,
                                                    'description':e.faultString})
                        self.ctl.output(error)
                    else:
                        name = make_namespec(group_name, process_name)
                        self.ctl.output('%s: signalled' % name)
开发者ID:pataquets,项目名称:supervisor,代码行数:50,代码来源:supervisorctl.py


示例12: start

    def start(self, names):
        '''
            start <name>\t\tStart a process
            start <gname>:*\t\tStart all processes in a group
            start <name> <name>\tStart multiple processes or groups
            start all\t\tStart all processes
        '''
        self.reread()

        if not names:
            self.logger.info("Error: start requires a process name")
            return []

        results = []
        if 'all' in names:
            results = self.supervisor.startAllProcesses()
            for result in results:
                result = self._startresult(result)
                self.logger.info(result)

        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                if process_name is None:
                    try:
                        _results = self.supervisor.startProcessGroup(group_name)
                        results.extend(_results)
                        for result in _results:
                            result = self._startresult(result)
                            self.logger.info(result)
                    except xmlrpclib.Fault, e:
                        if e.faultCode == xmlrpc.Faults.BAD_NAME:
                            error = "%s: ERROR (no such group)" % group_name
                            self.logger.info(error)
                        else:
                            raise
                else:
                    try:
                        result = self.supervisor.startProcess(name)
                        results.append(result)
                    except xmlrpclib.Fault, e:
                        error = self._startresult({'status': e.faultCode,
                                                   'name': process_name,
                                                   'group': group_name,
                                                   'description': e.faultString})
                        self.logger.info(error)
                    else:
                        name = make_namespec(group_name, process_name)
开发者ID:bernytt,项目名称:cmz,代码行数:48,代码来源:supervisor_rpc_api.py


示例13: stopProcess

    def stopProcess(self, name, wait=True):
        """ Stop a process named by name

        :param name: The name of the process to stop (or 'group:name')
        :type name: string
        :param wait: Wait for the process to be fully stopped
        :type wait: boolean
        :return: Always return True unless error
        :rtype: boolean
        """
        self._update('stopProcess')

        group, process = self._getGroupAndProcess(name)

        if process is None:
            group_name, process_name = split_namespec(name)
            return self.stopProcessGroup(group_name, wait)

        stopped = []
        called  = []

        def killit():
            if not called:
                if process.get_state() not in RUNNING_STATES:
                    raise RPCError(Faults.NOT_RUNNING)
                # use a mutable for lexical scoping; see startProcess
                called.append(1)

            if not stopped:
                msg = process.stop()
                if msg is not None:
                    raise RPCError(Faults.FAILED, msg)
                stopped.append(1)

                if wait:
                    return NOT_DONE_YET
                else:
                    return True

            if process.get_state() not in (ProcessStates.STOPPED,
                                           ProcessStates.EXITED):
                return NOT_DONE_YET
            else:
                return True

        killit.delay = 0.2
        killit.rpcinterface = self
        return killit # deferred
开发者ID:EvaSDK,项目名称:supervisor,代码行数:48,代码来源:rpcinterface.py


示例14: _getGroupAndProcess

    def _getGroupAndProcess(self, name):
        # get process to start from name
        group_name, process_name = split_namespec(name)

        group = self.supervisord.process_groups.get(group_name)
        if group is None:
            raise RPCError(Faults.BAD_NAME, name)

        if process_name is None:
            return group, None

        process = group.processes.get(process_name)
        if process is None:
            raise RPCError(Faults.BAD_NAME, name)

        return group, process
开发者ID:Camelsky,项目名称:supervisor,代码行数:16,代码来源:rpcinterface.py


示例15: do_stop

    def do_stop(self, arg):
        if not self.ctl.upcheck():
            return

        names = arg.split()
        supervisor = self.ctl.get_supervisor()

        if not names:
            self.ctl.output("Error: stop requires a process name")
            self.help_stop()
            return

        if "all" in names:
            results = supervisor.stopAllProcesses()
            for result in results:
                result = self._stopresult(result)
                self.ctl.output(result)

        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                if process_name is None:
                    try:
                        results = supervisor.stopProcessGroup(group_name)
                        for result in results:
                            result = self._stopresult(result)
                            self.ctl.output(result)
                    except xmlrpclib.Fault, e:
                        if e.faultCode == xmlrpc.Faults.BAD_NAME:
                            error = "%s: ERROR (no such group)" % group_name
                            self.ctl.output(error)
                        else:
                            raise
                else:
                    try:
                        result = supervisor.stopProcess(name)
                    except xmlrpclib.Fault, e:
                        error = self._stopresult(
                            {
                                "status": e.faultCode,
                                "name": process_name,
                                "group": group_name,
                                "description": e.faultString,
                            }
                        )
                        self.ctl.output(error)
                    else:
开发者ID:JeancarloBarrios,项目名称:adtp,代码行数:47,代码来源:supervisorctl.py


示例16: do_stop

    def do_stop(self, arg, exitOnError=True):
        if not self.ctl.upcheck():
            return

        names = arg.split()
        supervisor = self.ctl.get_supervisor()

        if not names:
            self.handle_error('Error: stop requires a process name')
            self.help_stop()
            return

        if 'all' in names:
            results = supervisor.stopAllProcesses()
            for result in results:
                result = self._stopresult(result)
                self.ctl.output(result)

        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                if process_name is None:
                    try:
                        results = supervisor.stopProcessGroup(group_name)
                        for result in results:
                            result = self._stopresult(result)
                            self.ctl.output(result)
                    except xmlrpclib.Fault as e:
                        if e.faultCode == xmlrpc.Faults.BAD_NAME:
                            error = "%s: ERROR (no such group)" % group_name
                            logOnly = not exitOnError
                            self.handle_error(message=error,
                                              logOnly=logOnly)
                        else:
                            self.handle_error(unhandled=True)
                else:
                    try:
                        supervisor.stopProcess(name)
                    except xmlrpclib.Fault as e:
                        error = self._stopresult({'status': e.faultCode,
                                                  'name': process_name,
                                                  'group': group_name,
                                                  'description':e.faultString})
                        self.ctl.error_output(error)
                    else:
                        name = make_namespec(group_name, process_name)
                        self.ctl.output('%s: stopped' % name)
开发者ID:indeedeng,项目名称:supervisor,代码行数:47,代码来源:supervisorctl.py


示例17: do_start

    def do_start(self, arg):
        if not self.ctl.upcheck():
            return

        names = arg.split()
        supervisor = self.ctl.get_supervisor()

        if not names:
            self.ctl.output("Error: start requires a process name")
            self.help_start()
            return

        if 'all' in names:
            results = supervisor.startAllProcesses()
            for result in results:
                result = self._startresult(result)
                self.ctl.output(result)

        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                if process_name is None:
                    try:
                        results = supervisor.startProcessGroup(group_name)
                        for result in results:
                            result = self._startresult(result)
                            self.ctl.output(result)
                    except xmlrpclib.Fault as e:
                        if e.faultCode == xmlrpc.Faults.BAD_NAME:
                            error = "%s: ERROR (no such group)" % group_name
                            self.ctl.output(error)
                        else:
                            raise
                else:
                    try:
                        result = supervisor.startProcess(name)
                    except xmlrpclib.Fault as e:
                        error = self._startresult({'status': e.faultCode,
                                                   'name': process_name,
                                                   'group': group_name,
                                                   'description': e.faultString})
                        self.ctl.output(error)
                    else:
                        name = make_namespec(group_name, process_name)
                        self.ctl.output('%s: started' % name)
开发者ID:pataquets,项目名称:supervisor,代码行数:45,代码来源:supervisorctl.py


示例18: stop

    def stop(self, names):
        '''
            self.logger.info("stop <name>\t\tStop a process")
            self.logger.info("stop <gname>:*\t\tStop all processes in a group")
            self.logger.info("stop <name> <name>\tStop multiple processes or groups")
            self.logger.info("stop all\t\tStop all processes")
        '''
        self.reread()

        results = []

        if 'all' in names:
            results = self.supervisor.stopAllProcesses()
            for result in results:
                self.logger.info(result)

        else:
            for name in names:
                group_name, process_name = split_namespec(name)
                if process_name is None:
                    try:
                        _results = self.supervisor.stopProcessGroup(group_name)
                        results.extend(_results)
                        for result in _results:
                            self.logger.info(result)
                    except xmlrpclib.Fault, e:
                        if e.faultCode == xmlrpc.Faults.BAD_NAME:
                            error = "%s: ERROR (no such group)" % group_name
                            self.logger.info(error)
                        else:
                            raise
                else:
                    try:
                        result = self.supervisor.stopProcess(name)
                        results.append(result)
                    except xmlrpclib.Fault, e:
                        error = {
                            'status': e.faultCode,
                            'name': process_name,
                            'group': group_name,
                            'description': e.faultString}
                        results.append(error)
                        self.logger.info(error)
                    else:
开发者ID:bernytt,项目名称:cmz,代码行数:44,代码来源:supervisor_rpc_api.py


示例19: startProcess

    def startProcess(self, name, wait=True):
        """ Start a process

        @param string name Process name (or 'group:name', or 'group:*')
        @param boolean wait Wait for process to be fully started
        @return boolean result     Always true unless error

        """
        self._update('startProcess')
        group, process = self._getGroupAndProcess(name)
        if process is None:
            group_name, process_name = split_namespec(name)
            return self.startProcessGroup(group_name, wait)

        # test filespec, don't bother trying to spawn if we know it will
        # eventually fail
        try:
            filename, argv = process.get_execv_args()
        except NotFound, why:
            raise RPCError(Faults.NO_FILE, why.args[0])
开发者ID:Camelsky,项目名称:supervisor,代码行数:20,代码来源:rpcinterface.py


示例20: killProcess

    def killProcess(self, name, signal):
        """ Send signal to a process

        @param string signal Signal identifier
        @param string name Process name (or 'group:name', or 'group:*')
        @return boolean result     Always true unless error

        """
        self._update('killProcess')
        group, process = self._getGroupAndProcess(name)
        if process is None:
            group_name, process_name = split_namespec(name)
            return self.killProcessGroup(signal, group_name)

        sig = self._getSignalFromString(signal)

        if sig is None:
            raise RPCError(Faults.BAD_ARGUMENTS, signal)

        killed = []
        called  = []
        kill = self.supervisord.options.kill

        def killit():
            if not called:
                if process.get_state() not in RUNNING_STATES:
                    raise RPCError(Faults.NOT_RUNNING)
                # use a mutable for lexical scoping; see startProcess
                called.append(1)

            if not killed:
                kill(process.pid, sig)
                killed.append(1)

            return True

        killit.delay = 0.2
        killit.rpcinterface = self
        return killit # deferred
开发者ID:fschulze,项目名称:mr.laforge,代码行数:39,代码来源:rpcinterface.py



注:本文中的supervisor.options.split_namespec函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python options.ClientOptions类代码示例发布时间:2022-05-27
下一篇:
Python options.signame函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap