2 Star 2 Fork 0

wangwei1237 / wangwei1237

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
timeout_1.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
wangwei1237 提交于 2021-05-13 12:49 . :Update: update hexo-asset-image
# -*- coding: utf-8 -*-
"""
JUST FOR TEST.
"""
import os
import sys
import json
import uuid
import base64
import shutil
import signal
import requests
import subprocess
def sigintHandler(signum, frame):
raise KeyboardInterrupt
exit()
def run_cmd(cmd, cwd):
res = {}
str_res = ''
signal.signal(signal.SIGTERM, sigintHandler)
try:
res = subprocess.run(
cmd,
cwd=cwd,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
encoding="utf-8",
timeout=600
)
print(res)
print(res.returncode)
print(res)
if 0 == res.returncode:
str_res = str(res.stdout)
else:
str_res = str(res.stderr)
except KeyboardInterrupt:
print('receive ctrl+c or SIGINT signal')
except:
print('exit')
return str_res
if __name__ == '__main__':
currentDir, _ = os.path.split(os.path.abspath(__file__))
run_cmd("sh timeout.sh", currentDir)
HTML
1
https://gitee.com/wangwei1237/wangwei1237.git
git@gitee.com:wangwei1237/wangwei1237.git
wangwei1237
wangwei1237
wangwei1237
master

搜索帮助