-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinternal_release.py
136 lines (117 loc) · 4.49 KB
/
internal_release.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#! /usr/local/bin/python
__author__="Paul Sorensen"
import sys
import fnmatch
import os
import shutil
import fileinput
if __name__ == "__main__":
repositories = [
'ua',
'ala',
'ihlc',
'rbml',
'sandbox'
]
if len(sys.argv) != 2:
print "Argument required. Please specify which repository for which you are releasing ("+ ", ".join(repositories)+")."
sys.exit(1)
elif sys.argv[1] not in repositories:
print "Invalid argument ("+ ", ".join(repositories)+")."
sys.exit(1)
if os.path.exists('.bzr'):
print "Bazaar directory exists. Please use bzr export first."
sys.exit(1)
else:
if sys.argv[1] == 'ua':
dirs = [
'_dev',
'packages/collections/templates/ala',
'themes/aall',
'themes/ala',
'themes/avsap',
'themes/ihlc',
]
elif sys.argv[1] == 'ala':
dirs = [
'_dev',
'packages/collections/templates/illinois',
'packages/digitallibrary/templates/illinois',
'themes/avsap',
'themes/ihlc',
'themes/illinois',
'themes/sousa'
]
elif sys.argv[1] == 'ihlc':
dirs = [
'_dev',
'packages/collections/templates/ala',
'packages/collections/templates/illinois',
'packages/digitallibrary/templates/illinois',
'themes/aall',
'themes/ala',
'themes/avsap',
'themes/illinois',
'themes/sousa'
]
elif sys.argv[1] == 'rbml':
dirs = [
'_dev',
'packages/collections/templates/ala',
'packages/collections/templates/illinois',
'packages/digitallibrary/templates/illinois',
'themes/aall',
'themes/ala',
'themes/avsap',
'themes/ihlc',
'themes/illinois',
'themes/sousa'
]
elif sys.argv[1] == 'sandbox':
dirs = [
'_dev',
'packages/collections/templates/ala',
'packages/collections/templates/illinois',
'packages/digitallibrary/templates/illinois',
'themes/aall',
'themes/ala',
'themes/avsap',
'themes/ihlc',
'themes/sousa'
]
include_comment_str = "// ini_set('include_path', '.:' . get_include_path());"
include_str = "ini_set('include_path', '/home3/chrispro/php:' . get_include_path());"
for line in fileinput.input("includes.inc.php",inplace=1):
if include_comment_str in line:
line=line.replace(include_comment_str, include_str)
print line,
login_form_str = "<form action=\"<?php echo(encode($_SERVER['REQUEST_URI'], ENCODE_HTML)); ?>\" accept-charset=\"UTF-8\" method=\"post\">"
reset_guest_str = " <div style='margin-bottom:2em'>Login using 'guest' as both the login and the password. If you cannot login, click <a href='resetguest.php' style='font-weight:bold'>here</a> to reset the guest password and try again.</div>"
for line in fileinput.input("themes/default/footer.inc.php",inplace=1):
if login_form_str in line:
line=line.replace(login_form_str, login_form_str+reset_guest_str)
print line,
shutil.move("_dev/resources/resetguest.php", "resetguest.php")
else:
sys.exit(1)
print "\nRemoving extraneous directories..."
for d in dirs:
if os.path.exists(d):
shutil.rmtree(d)
else:
print "\tPath '" + d + "' does not exist."
if os.path.isfile('packages/core/install/install.php'):
os.rename('packages/core/install/install.php', 'packages/core/install/install.php_')
print "\nRemoving blank config file..."
if os.path.isfile('config.inc.php'):
os.remove('config.inc.php')
if os.path.isfile('configblank.inc.php'):
os.remove('configblank.inc.php')
# find files with ".old" in name and remove those
print "\nSearching for files with '.old' in name..."
for (path, dirs, files) in os.walk(os.getcwd()):
for f in files:
if fnmatch.fnmatch(f, '*.old*'):
print "\tDeleting file:" + path + "/" + f
os.remove(path + "/" + f)
print "\nDone!\n"