代码拉取完成,页面将自动刷新
import json
import os
import shutil
import time
config = {}
logt = time.time()
def log(text):
localtime = time.asctime(time.localtime(time.time()))
with open("log" + str(logt) + ".txt", 'a') as file_object:
s="["+localtime+"] "+text+"\n"
print(s)
file_object.write(s)
def copyFile(source, target):
try:
shutil.copyfile(source, target)
log("Success: %s" % source)
except IOError as e:
log("Error: Unable to copy file. %s" % e)
except:
log("Error: Unknown Error while copying %s" % source)
def strContain(source, targets):
for target in targets:
if target in source:
return True
return False
def main():
log("Start...")
try:
with open("config.json") as config_json:
config = json.load(config_json)
except:
log("Error: config.json Not Found!")
log("Exit...")
exit()
if not os.path.isdir(config['target']):
os.mkdir(os.path.join(os.getcwd(), config['target']))
for p in config['path']:
if os.path.isdir(p):
for root, dirs, files in os.walk(p):
if not root == os.path.join(os.getcwd(), config['target']):
for f in files:
if strContain(f, config['symbols']):
copyFile(os.path.join(root, f), os.path.join(
os.getcwd(), os.path.join(config['target'], f)))
else:
log("Error: %s not a folder or driver." % p)
log("Done...")
main()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。