forked from python-zk/zc-zookeeper-static
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_source_files.py
57 lines (49 loc) · 1.91 KB
/
get_source_files.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
import shutil
import sys
def main():
here = os.getcwd()
[tarball] = sys.argv[1:]
use_patch = '3.4.4' in tarball
os.system('rm -rf zookeeper-sources')
os.mkdir('zookeeper-sources')
os.chdir('zookeeper-sources')
os.system('tar xzf ' + tarball)
[srcdir] = os.listdir('.')
if os.path.exists(os.path.join(here, 'src')):
shutil.rmtree(os.path.join(here, 'src'))
os.mkdir(os.path.join(here, 'src'))
os.chdir(os.path.join(srcdir, 'src'))
os.system("tar czf %s c" % os.path.join(here, 'c.tgz'))
shutil.copy(os.path.join('c', 'LICENSE'), here)
os.chdir(os.path.join('contrib', 'zkpython'))
shutil.copy('README', os.path.join(here, 'ORIGINAL-README'))
os.chdir(os.path.join('src'))
if use_patch:
shutil.copy(os.path.join(here, 'zookeeper_patched_344.c'),
os.path.join('c', 'zookeeper.c'))
shutil.copytree('test', os.path.join(here, 'src', 'zookeepertests'))
open(os.path.join(here, 'src', 'zookeepertests', '__init__.py'),
'w').close()
connection_test = open(
os.path.join(here, 'src', 'zookeepertests', 'connection_test.py')
).read()
f = open(
os.path.join(here, 'src', 'zookeepertests', 'connection_test.py'),
'w')
if ('handles = [ zookeeper.init(self.host) for i in xrange(63) ]'
in connection_test):
connection_test = connection_test.replace(
'handles = [ zookeeper.init(self.host) for i in xrange(63) ]',
'handles = [ zookeeper.init(self.host) for i in xrange(9) ]')
else:
connection_test = connection_test.replace('testmanyhandles',
'disabledtestmanyhandles')
f.write(connection_test)
f.close()
os.chdir(os.path.join('c'))
shutil.copy('pyzk_docstrings.h', here)
shutil.copy('zookeeper.c', here)
os.chdir(here)
if __name__ == '__main__':
main()