-
Notifications
You must be signed in to change notification settings - Fork 5
/
create-archive.py
66 lines (47 loc) · 1.54 KB
/
create-archive.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
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
import sys,os,subprocess,re
from time import strftime
devnull = open(os.devnull, 'wb')
def execute(cmd, silent=False):
if silent:
stdout = devnull
else:
stdout = None
return subprocess.call(cmd.split(), stdout=stdout)
def execute_out(cmd, silent=False):
p = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
out, err = p.communicate()
return out
def find_url():
stdout = execute_out("git remote -v")
stdout = stdout.split('\n')
for line in stdout:
if "origin" in line:
tmp = line.split(' ')
tmp = tmp[0].split('\t')
remote = tmp[1]
return remote
print "ERROR: could not find remote server."
sys.exit(1)
pulpino_url = find_url()
print "Using remote PULPino url %s" % (pulpino_url)
# make sure we use a clean directory
execute("rm -rf ./tmp")
os.mkdir("./tmp");
os.chdir("./tmp");
if execute("git clone %s" % (pulpino_url)) != 0:
print "ERROR: could not clone fresh PULPino"
sys.exit(1)
os.chdir("./pulpino");
if execute("./update-ips.py") != 0:
print "ERROR: could not update IPs"
sys.exit(1)
# now remove the git folders, no point in keeping them for a zip file
matches = []
for root, dirnames, filenames in os.walk('.'):
for dirname in dirnames:
if dirname == ".git":
print "delete folders %s/%s" % (root, dirname)
execute("rm -rf %s/%s" % (root, dirname))
datestr = strftime("%Y-%m-%d_%H:%M:%S")
execute("tar -czvf ./../../pulpino-%s.tar.gz ./" % (datestr))