- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync_dir_data.py
More file actions
Latest commit
99 lines (86 loc) · 2.46 KB
/
Copy pathsync_dir_data.py
File metadata and controls
99 lines (86 loc) · 2.46 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
#-*- coding:utf-8 -*-
importos
importshutil
importlinecache
s_dir= [
"classRuleSync",
"dataSync",
"dynamicSync",
"schoolMailSync",
"openRegistrationData",
"schoolNewsSync",
"syncCardAndDevice"
]
#s_dir = ["classRuleSync"]
p_dir= [
"tuxing_7133",
"tuxing_7090",
"tuxing_7091",
"tuxing_7092",
"tuxing_7093",
"tuxing_7094",
"tuxing_7095",
"tuxing_7096",
"tuxing_7097",
"tuxing_7098"
]
s_url='/datassd/tuxing_s'
d_url='/datassd/tuxing'
#num_a = 0
#num_b = 5
#num_b = int(raw_input('You want number:'))
# 原有文件数量
a1=int(os.popen('find %s/ -name *.json -type f|wc -l'%s_url).read().strip())
# mkdir dir
defMkdir():
# os.makedirs('%s/deleteLog'%d_url)
# os.makedirs('%s/syncLog'%d_url)
# os.makedirs('%s/yncCardAndDeviceLog'%d_url)
forains_dir:
forbinp_dir:
os.makedirs('%s/%s/%s/'%(d_url,b,a))
print"-->mkdir directory template ok"
# clear file
defClear():
forainp_dir:
forbins_dir:
cmd="rm -rf %s/%s/%s/* "% (d_url,a,b)
os.system('%s'%cmd)
print'-->clear directory ok'
#shutil.rmtree(d_url)
# mv/copy file
defMvfile():
num_a=0
num_b=int(raw_input('You want number:'))
print'start move file...'
fors_dins_dir:
withopen('/datassd/data.txt','w') asf:
a=os.popen('find %s/%s/ -name *.json -type f'%(s_url,s_d)).read()
f.write(a)
f.close()
data_n=1
whiledata_n>0:
fortomcat_dirinp_dir:
cache=linecache.getlines('/datassd/data.txt')[num_a:num_b]
forlineincache:
printline.replace("\n","")
shutil.move(line.replace("\n",""),'%s/%s/%s/'%(d_url,tomcat_dir,s_d))
#shutil.copy(line.replace("\n",""),'%s/%s/%s/'%(d_url,tomcat_dir,s_d))
os.system('sed -i "1,%sd" /datassd/data.txt'%num_b)
linecache.clearcache()
data_n=os.path.getsize('/datassd/data.txt')
# check file
defCheck():
a2=int(os.popen('find %s/ -name *.json -type f|wc -l'%s_url).read().strip())
b2=int(os.popen('find %s/ -name *.json -type f|wc -l'%d_url).read().strip())
ifa2==0anda1==b2:
print'-->%s 剩余: %s,原有: %s 已迁移: %s'%(s_url,a2,a1,a1)
print'-->%s 现有文件: %s'%(d_url,b2)
print'-->迁移完成'
else:
print'-->原数据未迁移完'
#Mkdir()
Clear()
Mvfile()
Check()