@@ -155,13 +155,21 @@ def config_join(*args):
155155 _handle_dependency_resolution (config_directory , kwds )
156156 _handle_job_metrics (config_directory , kwds )
157157 file_path = kwds .get ("file_path" ) or config_join ("files" )
158+ _ensure_directory (file_path )
159+
160+ tool_dependency_dir = kwds .get ("tool_dependency_dir" ) or config_join ("deps" )
161+ _ensure_directory (tool_dependency_dir )
162+
158163 shed_tool_conf = kwds .get ("shed_tool_conf" ) or config_join ("shed_tools_conf.xml" )
159164 tool_definition = _tool_conf_entry_for (tool_paths )
160165 empty_tool_conf = config_join ("empty_tool_conf.xml" )
161166
162167 tool_conf = config_join ("tool_conf.xml" )
163168 database_location = config_join ("galaxy.sqlite" )
169+
164170 shed_tool_path = kwds .get ("shed_tool_path" ) or config_join ("shed_tools" )
171+ _ensure_directory (shed_tool_path )
172+
165173 sheds_config_path = _configure_sheds_config_file (
166174 ctx , config_directory , ** kwds
167175 )
@@ -173,7 +181,7 @@ def config_join(*args):
173181 latest_galaxy = latest_galaxy ,
174182 ** kwds
175183 )
176- os . makedirs (shed_tool_path )
184+ _ensure_directory (shed_tool_path )
177185 server_name = "planemo%d" % random .randint (0 , 100000 )
178186 port = int (kwds .get ("port" , 9090 ))
179187 template_args = dict (
@@ -257,7 +265,8 @@ def config_join(*args):
257265 write_file (empty_tool_conf , EMPTY_TOOL_CONF_TEMPLATE )
258266
259267 shed_tool_conf_contents = _sub (SHED_TOOL_CONF_TEMPLATE , template_args )
260- write_file (shed_tool_conf , shed_tool_conf_contents )
268+ # Write a new shed_tool_conf.xml if needed.
269+ write_file (shed_tool_conf , shed_tool_conf_contents , force = False )
261270
262271 pid_file = kwds .get ("pid_file" ) or config_join ("galaxy.pid" )
263272
@@ -411,7 +420,7 @@ def _download_database_template(
411420 shutil .copyfile (galaxy_sqlite_database , database_location )
412421 return True
413422
414- if latest :
423+ if latest or not galaxy_root :
415424 template_url = DOWNLOADS_URL + urlopen (LATEST_URL ).read ()
416425 urlretrieve (template_url , database_location )
417426 return True
@@ -748,7 +757,6 @@ def _handle_kwd_overrides(properties, kwds):
748757 'job_config_file' ,
749758 'job_metrics_config_file' ,
750759 'dependency_resolvers_config_file' ,
751- 'tool_dependency_dir' ,
752760 ]
753761 for prop in kwds_gx_properties :
754762 val = kwds .get (prop , None )
@@ -761,7 +769,14 @@ def _sub(template, args):
761769 return ''
762770 return Template (template ).safe_substitute (args )
763771
772+
773+ def _ensure_directory (path ):
774+ if path is not None and not os .path .exists (path ):
775+ os .makedirs (path )
776+
777+
764778__all__ = [
765779 "attempt_database_preseed" ,
780+ "DATABASE_LOCATION_TEMPLATE" ,
766781 "galaxy_config" ,
767782]
0 commit comments