mService.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:mWorkerService 作者: smices 项目源码 文件源码
def status():
    """
    Fetch service status
    :return:
    """
    if master_pid("c") is True:
        print colored(" SERVICE IS RUNNING... ", "white", "on_blue")
        h = PrettyTable([u"??ID", u"????"])
        h.align[u"??ID"] = "l"
        h.align[u"????"] = "l"
        h.padding_width = 1
        pid_list = processors_list("r")
        for pid in pid_list:
            try:
                if psutil.Process(pid).is_running():
                    h.add_row([pid, colored("RUNNING...",attrs=["bold"])])
                else:
                    h.add_row([colored(pid, "magenta", "on_yellow", attrs=["bold"]),
                               colored("STOPED", "magenta", "on_yellow", attrs=["bold"])])
            except psutil.NoSuchProcess:
                h.add_row([colored(pid, "yellow", attrs=["bold", "blink"]),
                           colored("LOSTED", "red", attrs=["bold", "blink"])])
        print h
    else:
        cmsg("SERVICE IS STOPED!", "e")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号