alert.py 文件源码

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

项目:Sentences-analysis 作者: sungminoh 项目源码 文件源码
def main():
    parser = argparse.ArgumentParser(description='email notification')
    parser.add_argument('--email', '-e', help='email address', required=True)
    parser.add_argument('--process', '-p', help='process', required=True)
    parser.add_argument('--title', '-t', help='email content', default='Your process is done')
    parser.add_argument('--content', '-c', help='email content')
    args = parser.parse_args()

    host = platform.node()
    process = args.process
    email = args.email
    title = args.title
    content = args.content if args.content else '{} is done'.format(process)

    print commands.getoutput('ps -ef | grep %s' % process).split('\n')
    while any([True if x.find('python %s' % process) >= 0 else False
               for x in commands.getoutput('ps -ef | grep %s' % process).split('\n')]):
        print 'sleep ...'
        sleep(300)
    send_email(title, host, email, content)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号