36
36
sys .path .append (os .path .realpath (
37
37
os .path .join (os .path .dirname (__file__ ), ".." )))
38
38
39
- from mig .shared .install import generate_confs
39
+ from mig .shared .install import MIG_BASE , generate_confs
40
40
41
- _ENVHELP_OUTPUT_DIR = os .path .realpath (
41
+ _LOCAL_ENVHELP_OUTPUT_DIR = os .path .realpath (
42
42
os .path .join (os .path .dirname (__file__ ), "output" ))
43
43
_MAKECONFIG_ALLOWED = ["local" , "test" ]
44
- _PYTHON_MAJOR = os .environ .get ('PY' , '3' )
45
44
46
45
47
46
def _at (sequence , index = - 1 , default = None ):
@@ -54,17 +53,34 @@ def _at(sequence, index=-1, default=None):
54
53
55
54
def write_testconfig (env_name , is_py2 = False ):
56
55
confs_name = 'confs' if env_name == 'local' else '%sconfs' % (env_name ,)
56
+ confs_suffix = 'py2' if is_py2 else 'py3'
57
+
57
58
overrides = {
58
- 'destination' : os .path .join (_ENVHELP_OUTPUT_DIR , confs_name ),
59
- 'destination_suffix' : "-py %s" % ('2' if is_py2 else '3' ,),
59
+ 'destination' : os .path .join (_LOCAL_ENVHELP_OUTPUT_DIR , confs_name ),
60
+ 'destination_suffix' : "-%s" % (confs_suffix ,),
60
61
}
62
+
63
+ # determine the paths by which we will access the various configured dirs
61
64
if is_py2 :
62
- overrides .update (** {
63
- 'mig_code' : '/usr/src/app/mig' ,
64
- 'mig_certs' : '/usr/src/app/envhelp/output/certs' ,
65
- 'mig_state' : '/usr/src/app/envhelp/output/state' ,
66
- })
67
- generate_confs (_ENVHELP_OUTPUT_DIR , ** overrides )
65
+ env_mig_base = '/usr/src/app'
66
+ else :
67
+ env_mig_base = MIG_BASE
68
+ conf_dir_path = os .path .join (env_mig_base , "envhelp/output" )
69
+
70
+ overrides .update (** {
71
+ 'mig_code' : os .path .join (conf_dir_path , 'mig' ),
72
+ 'mig_certs' : os .path .join (conf_dir_path , 'certs' ),
73
+ 'mig_state' : os .path .join (conf_dir_path , 'state' ),
74
+ })
75
+
76
+ print ('generating "%s" configuration ...' % (confs_name ,))
77
+
78
+ generate_confs (_LOCAL_ENVHELP_OUTPUT_DIR , ** overrides )
79
+
80
+ confs_destination = '' .join (
81
+ [overrides ['destination' ], overrides ['destination_suffix' ]])
82
+ print ('wrote configuration for "%s" env into: %s' %
83
+ (confs_suffix , confs_destination ))
68
84
69
85
70
86
def main_ (argv ):
@@ -84,8 +100,8 @@ def main_(argv):
84
100
def main (argv = sys .argv ):
85
101
try :
86
102
main_ (argv )
87
- except RuntimeError as e :
88
- print ('makeconfig: %s' % ( str ( e ),) )
103
+ except RuntimeError as rte :
104
+ print ('makeconfig: %s' % rte )
89
105
exit (1 )
90
106
91
107
0 commit comments