From b81a675064780faf2d08ccd90cbc6d1c43d82b8c Mon Sep 17 00:00:00 2001 From: Dave Bouvier Date: Thu, 26 Sep 2013 10:03:23 -0400 Subject: [PATCH] Make a backup of tool_conf.xml before automatically removing references to migrated tools. Persist the XML declaration tag in tool_conf.xml. --- lib/tool_shed/galaxy_install/install_manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tool_shed/galaxy_install/install_manager.py b/lib/tool_shed/galaxy_install/install_manager.py index 8f0db4348d2..4d343118481 100644 --- a/lib/tool_shed/galaxy_install/install_manager.py +++ b/lib/tool_shed/galaxy_install/install_manager.py @@ -86,6 +86,9 @@ class InstallManager( object ): plural = 's' file_names = ', '.join( self.proprietary_tool_confs ) if missing_tool_configs_dict: + for proprietary_tool_conf in self.proprietary_tool_confs: + # Create a backup of the tool configuration in the un-migrated state. + shutil.copy( proprietary_tool_conf, '%s-pre-stage-%04d' % ( proprietary_tool_conf, latest_migration_script_number ) ) for repository_elem in root: # Make sure we have a valid repository tag. if self.__is_valid_repository_tag( repository_elem ): @@ -203,7 +206,7 @@ class InstallManager( object ): tmp_filename = fh.name fh.close() fh = open( tmp_filename, 'wb' ) - tree.write( tmp_filename ) + tree.write( tmp_filename, encoding='utf-8', xml_declaration=True ) fh.close() shutil.move( tmp_filename, os.path.abspath( proprietary_tool_conf ) ) os.chmod( proprietary_tool_conf, 0644 )