forked from eastein/Maker-Network
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·55 lines (46 loc) · 2.07 KB
/
configure
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
#!/usr/bin/env python
import optparse
import json
import os, os.path
import sys
if __name__ == '__main__' :
os.chdir(os.path.abspath(os.path.dirname(__file__)))
parser = optparse.OptionParser()
parser.add_option('-v', '--virtualenv', dest='virtualenv', help='path to the virtualenv to use', default=os.environ.get('VIRTUAL_ENV', None))
parser.add_option('-d', '--working-dir', dest='working_dir', help='directory to store sockets and logs in.', default=os.path.abspath(os.path.dirname(__file__)))
parser.add_option('-c', '--code-dir', dest='code_dir', help='directory to store the code (git checkout) in. generally will be this directory. no real installation is done.', default=os.path.abspath(os.path.dirname(__file__)))
parser.add_option('-f', action='store_true', dest='force', default=False, help='needed if not the first run of configure that succeeds; force overwrite of configuration.')
parser.add_option('--mx', dest='mx', help="sent email via mail exchange.")
parser.add_option('--admin-email', dest='admin_email', help="email address to send system status messages to.")
parser.add_option('--from-email', dest='from_email', help="send email from this address.")
opts, args = parser.parse_args()
if not opts.virtualenv :
print '-v argument is required.'
sys.exit(1)
out_opts = {
'virtualenv' : opts.virtualenv,
'working_dir' : opts.working_dir,
'code_dir' : opts.code_dir,
'mx' : opts.mx,
'admin_email' : opts.admin_email,
'from_email' : opts.from_email,
}
def printout(d) :
for k,v in d.items() :
print k.ljust(20, '.') + v
if os.path.exists('configure.json') and not opts.force :
print 'existing config, use -f to force overwrite:'
printout(json.load(open('configure.json')))
print 'not configured.'
sys.exit(0)
assert os.path.exists(out_opts['virtualenv'])
assert os.path.exists(out_opts['working_dir'])
assert os.path.exists(out_opts['code_dir'])
assert out_opts['mx']
assert out_opts['admin_email']
assert out_opts['from_email']
print 'writing config:'
printout(out_opts)
fh = open('configure.json', 'w')
json.dump(out_opts, fh)
fh.close()