-
Notifications
You must be signed in to change notification settings - Fork 0
/
clear.py
33 lines (28 loc) · 1 KB
/
clear.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# encoding:utf-8
# 文件功能:清除指定文件或所有
import utils
def notice_server(address, user, password, file):
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
url = 'http://' + address + '/tag/remove'
data = {
'username': user,
'password': password,
'tagId': file
}
return utils.get(url, data, headers)
def run(args):
files = args.file.split(',')
for file in files:
flag = utils.rmdir(args.path + "/" + file)
utils.edit_list(file, None)
if flag:
# 通知服务器
try:
result = notice_server(args.serverAddress, args.tagOwner, args.tagPassword, file)
if not utils.parser_result(result):
utils.log('err_notice_server', file, 'error')
except:
utils.log('err_notice_connect', file, 'error')
utils.log('info_clear', file)
else:
utils.log('err_clear', file, 'error')