Revision 1570
Added by Aaron Marcuse-Kubitza over 12 years ago
map | ||
---|---|---|
47 | 47 |
raise SystemExit('Usage: '+opts.env_usage(env_names, True)+' ' |
48 | 48 |
+sys.argv[0]+' [map_path...] [<input] [>output]') |
49 | 49 |
|
50 |
# Get db config from env vars |
|
51 |
db_config_names = ['engine', 'host', 'user', 'password', 'database'] |
|
52 |
def get_db_config(prefix): |
|
53 |
return opts.get_env_vars(db_config_names, prefix, env_names) |
|
54 |
in_db_config = get_db_config('in') |
|
55 |
out_db_config = get_db_config('out') |
|
56 |
in_is_db = 'engine' in in_db_config |
|
57 |
out_is_db = 'engine' in out_db_config |
|
50 |
## Get config from env vars |
|
58 | 51 |
|
59 |
# Get other config from env vars |
|
60 |
end = util.cast(int, opts.get_env_var('n', None, env_names)) |
|
61 |
start = util.cast(int, opts.get_env_var('start', '0', env_names)) |
|
62 |
if end != None: end += start |
|
52 |
# Modes |
|
63 | 53 |
test = opts.env_flag('test', False, env_names) |
64 | 54 |
commit = opts.env_flag('commit', False, env_names) and not test |
65 | 55 |
# never commit in test mode |
66 | 56 |
redo = opts.env_flag('redo', test, env_names) and not commit |
67 | 57 |
# never redo in commit mode (manually run `make empty_db` instead) |
58 |
end = util.cast(int, opts.get_env_var('n', None, env_names)) |
|
59 |
|
|
60 |
# Ranges |
|
61 |
start = util.cast(int, opts.get_env_var('start', '0', env_names)) |
|
62 |
if end != None: end += start |
|
63 |
|
|
64 |
# Debugging |
|
68 | 65 |
debug = opts.env_flag('debug', False, env_names) |
69 | 66 |
sql.run_raw_query.debug = debug |
70 | 67 |
verbose = debug or opts.env_flag('verbose', False, env_names) |
71 | 68 |
opts.get_env_var('profile_to', None, env_names) # add to env_names |
72 | 69 |
|
70 |
# DB |
|
71 |
db_config_names = ['engine', 'host', 'user', 'password', 'database'] |
|
72 |
def get_db_config(prefix): |
|
73 |
return opts.get_env_vars(db_config_names, prefix, env_names) |
|
74 |
in_db_config = get_db_config('in') |
|
75 |
out_db_config = get_db_config('out') |
|
76 |
in_is_db = 'engine' in in_db_config |
|
77 |
out_is_db = 'engine' in out_db_config |
|
78 |
|
|
79 |
## |
|
80 |
|
|
73 | 81 |
# Logging |
74 | 82 |
def log(msg, on=verbose): |
75 | 83 |
if on: sys.stderr.write(msg) |
Also available in: Unified diff
bin/map: Added section comments to env var config retrieval. Reordered env var config retrieval to put DB config last, since these options are input-type specific and complex, and putting them first hides the more general other options.