@@ -33,6 +33,7 @@ PROJ_ROOT = os.path.dirname(os.path.realpath(__file__))
3333CONFIG = None
3434CONFIG_PATH = '{}/DevlabConfig.yaml' .format (PROJ_ROOT )
3535WIZARD_CONFIG = {}
36+ MIN_DEVLAB_VERSION = '2.3.0'
3637
3738##-- Classes --##
3839class NetInfo :
@@ -196,6 +197,22 @@ class NetInfo:
196197 return (ipaddr & mask ) == (netaddr & mask )
197198
198199##-- Functions --##
200+ def check_min_devlab_version ():
201+ proc = subprocess .Popen (['devlab --version' ], stdout = subprocess .PIPE , stderr = subprocess .PIPE , shell = True )
202+ stdout , stderr = proc .communicate ()
203+ if proc .returncode != 0 :
204+ print ("ERROR: Could devlab exited non-zero while checking its version: " )
205+ print (stderr )
206+ sys .exit (1 )
207+ version = stdout .split ()[1 ]
208+ if isinstance (version , bytes ):
209+ version = version .decode ()
210+ if version == 'master' :
211+ print ("## From Wizard:" )
212+ print ("## WARNING!!! Devlab version is set to 'master'. You may have to update from your devlab repository depending on which commit you're at" )
213+ print ("## Continuing anyway..." )
214+ return
215+
199216def get_selection_menu (options , enabled_options = None , title = None , loop_title = None , show_all = False , show_done = False ):
200217 enabled_opts = []
201218 if enabled_options :
@@ -329,6 +346,25 @@ def get_values_menu(options, inplace=False, title='Enter the values you want to
329346 working_options [key ] = new_val
330347 return working_options
331348
349+ def mkdirs (path ):
350+ """This is like mkdir -p"""
351+ if os .path .isdir (path ):
352+ return True
353+ try :
354+ if not os .path .isdir (path ):
355+ os .makedirs (path )
356+ return True
357+ except FileExistsError as e :
358+ if os .access (path , os .W_OK ):
359+ return True
360+ print ("Path {}: exists but is unwritable" .format (path ))
361+ return False
362+ except OSError as e :
363+ if e .errno == 17 : #This is fileexists
364+ return True
365+ print ("Mkdir failed on: '{}'. Got error: {}" .format (path , e .strerror ))
366+ return False
367+
332368def write_config (config ):
333369 print ("Writing DevlabConfig.yaml" )
334370 with open (CONFIG_PATH , 'w' ) as cfile :
@@ -342,6 +378,7 @@ def write_config(config):
342378
343379def write_wizard_config (config ):
344380 cfile_path = '{}/{}/wizard.yaml' .format (PROJ_ROOT , CONFIG ['paths' ]['component_persistence' ])
381+ mkdirs (os .path .dirname (cfile_path ))
345382 print ("Writing {}" .format (cfile_path ))
346383 with open (cfile_path , 'w' ) as cfile :
347384 cfile .write (
@@ -356,6 +393,7 @@ def write_wizard_config(config):
356393if __name__ == '__main__' :
357394 os .chdir (PROJ_ROOT )
358395 CONFIG_LOAD_FROM = CONFIG_PATH
396+ check_min_devlab_version ()
359397 NEW_CONFIG = False
360398 if not os .path .isfile (CONFIG_PATH ) or os .path .getsize (CONFIG_PATH ) == 0 :
361399 CONFIG_LOAD_FROM = '{}/defaults/DevlabConfig.yaml' .format (PROJ_ROOT )
@@ -369,6 +407,7 @@ if __name__ == '__main__':
369407 with open (CONFIG_LOAD_FROM ) as DCF :
370408 CONFIG = yaml .load (DCF , Loader = yaml .SafeLoader )
371409 ORG_CONFIG_JSON = json .dumps (CONFIG )
410+ CONFIG ['min_devlab_version' ] = MIN_DEVLAB_VERSION
372411
373412 #Load wizard's config if it exists:
374413 if os .path .isfile ('{}/{}/wizard.yaml' .format (PROJ_ROOT , CONFIG ['paths' ]['component_persistence' ])):
0 commit comments