程序优化
This commit is contained in:
1 parent
2093ff5526
commit
10640a63c2
8 files changed
+260
-44
No files matched your search
+26
-4
@@ -1,4 +1,4 @@
|
||||
import redis,sys,os,re,oss2
|
||||
import redis,sys,os,re,oss2,shutil,time
|
||||
import platform
|
||||
import xml.etree.ElementTree as ET
|
||||
from PIL import ImageGrab
|
||||
@@ -223,7 +223,29 @@ def uploadControlPointsOss(pid):
|
||||
#截屏保存
|
||||
def saveScreenImg(pid):
|
||||
#获取当前的日志
|
||||
if not os.path.exists(os.path.join("D:/screen/",time.strftime("%y-%m-%d", time.localtime()))):
|
||||
os.makedirs(os.path.join("D:/screen/",time.strftime("%Y-%m-%d", time.localtime())))
|
||||
if not os.path.exists(os.path.join(config.workdir,"screen", time.strftime("%y%m%d" time.localtime()))):
|
||||
os.makedirs(os.path.join(config.workdir,"screen", time.strftime("%y%m%d" time.localtime())))
|
||||
screenshot = ImageGrab .grab()
|
||||
screenshot.save(os.path.join("D:/screen/",time.strftime("%Y-%-%d'time .localtime()"),str(pid)+".png"))
|
||||
screenshot.save(os.path.join(config.workdir,"screen", time.strftime("%y%m%d" time.localtime())),str(pid)+".png")
|
||||
#移动到e盘
|
||||
if not os.path.exists(os.path.join(config.sharedir,"screen", time.strftime("%y%m%d" time.localtime()))):
|
||||
os.makedirs(os.path.join(config.sharedir,"screen", time.strftime("%y%m%d" time.localtime())))
|
||||
shutil.copytree(os.path.join(config.workdir,"screen", time.strftime("%y%m%d" time.localtime())), os.path.join(config.sharedir,"screen", time.strftime("%y%m%d" time.localtime())))
|
||||
|
||||
|
||||
#文件夹的移动和删除
|
||||
def removeFolder(pid):
|
||||
#判断是否存在finished文件夹,没有则创建
|
||||
if not os.path.exists(os.path.join(config.workdir, 'finished')):
|
||||
os.makedirs(os.path.join(config.workdir, 'finished'))
|
||||
#移动文件夹到指定路径,如果已经存在了就删除再移动
|
||||
if os.path.exists(os.path.join(config.workdir, 'finished', pid)):
|
||||
shutil.rmtree(os.path.join(config.workdir, 'finished', pid), ignore_errors=True)
|
||||
shutil.move(os.path.join(config.workdir, pid), os.path.join(config.workdir, 'finished'))
|
||||
#遍历finished 里的文件夹,超过三天的就都删除
|
||||
for file in os.listdir(os.path.join(config.workdir, 'finished')):
|
||||
if os.path.isdir(os.path.join(config.workdir, 'finished', file)):
|
||||
file_time = os.path.getmtime(os.path.join(config.workdir, 'finished', file))
|
||||
now_time = time.time()
|
||||
if (now_time - file_time) > 259200:
|
||||
shutil.rmtree(os.path.join(config.workdir, 'finished', file), ignore_errors=True)
|
||||
Reference in new issue
Block a user