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)
评论列表
文章目录