sshot.py 文件源码

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

项目:scripts 作者: mbfraga 项目源码 文件源码
def sshot(opts=[], upload=False):
    """Call sshot and upload screenshot. Returns the image name.

    Keyword arguments:
    opts -- options to send to sshot (default [])
    upload -- boolean to decide whether to upload screenshot or not.
              (default False)
    """
    my_env = os.environ.copy()
    date=datetime.now()
    imgname = "sshot-" + date.strftime('%Y-%m-%d_%H:%M:%S') + ".png"
    command = []
    if upload:
        my_env['SSHOT_UPLOAD'] = 'true'
    else:
        my_env['SSHOT_UPLOAD'] = 'false'
    my_env['IMGNAME'] = imgname

    command = ['sshot']
    command.extend(opts)
    proc = Popen(command, stdin=PIPE, stdout=PIPE, env=my_env)
    exit_code = proc.wait()
    if exit_code == 0:
        return(imgname)
    else:
        return(False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号