-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloneAny.py
More file actions
44 lines (42 loc) · 993 Bytes
/
cloneAny.py
File metadata and controls
44 lines (42 loc) · 993 Bytes
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
import sys, envoy, re, time
n2s = {}
p2n = {}
n2v = {}
f = open ('RepoSize.csv')
for l in f:
ar = l .rstrip () .split(';')
vcs = ar [1]
s = int (ar [0])
n = ar [5]
if re.search ("/\.$", n):
p = re. sub('/', '_', n)
p = 'bitbucket.org_' + p
print p + ':' + n + ':'
else:
p = 'bitbucket.org_' + re. sub('/', '_', n)
p2n [ p ] = n
n2s [ n ] = s
n2v [ n ] = vcs
start = time .time()
now = start
nused = 0
fname = 'todo'
if len (sys .argv) > 1:
fname = sys.argv[1]
f = open (fname)
toCopy = []
for l in f:
p = l .rstrip ()
print p + ':'
n = p2n [ p ]
s = n2s [ n ]
vcs = n2v [ n ]
tmo = str (s/1000000 + 100)
cmdl = 'timeout ' + tmo + ' hg clone -U https://bitbucket.org/' + n + ' ' + p
if vcs == 'git':
cmdl = 'timeout ' + tmo + ' git clone --mirror https://bitbucket.org/' + n + ' ' + p
r = envoy .run (cmdl)
nused += s
ttt = time .time()
print str (r.status_code) + ';' + str (nused) + ';' + str (ttt) + ';' + cmdl
sys.stdout.flush()