def main_non_archive(args): # validation if not args.galaxy_root: raise ValueError( 'in non-archive mode the galaxy root must be specified') if not args.tools_subdir: raise ValueError( 'in non-archive mode the tools subdirectory must be specified') # get the module names module_names = meta.get_module_names( args.manifest, args.create_all, args.create_tagged) # create the python subtree tools_subdir_path = os.path.join( args.galaxy_root, 'tools', args.tools_subdir) meta.add_python_files(module_names, tools_subdir_path) shutil.copyfile('galaxy_format_tweak.py', os.path.join(tools_subdir_path, 'galaxy_format_tweak.py')) # create the galaxy xml interface files xml_filenames, import_errors = add_xml_files(args.galaxy_root, module_names, args.short_length, args.tools_subdir) for e in import_errors: print e # create the toolbox xml pointing to the installed xmls toolbox_pathname = os.path.join(args.galaxy_root, args.tool_conf) section_name = args.tools_subdir section_id = args.tools_subdir toolbox_xml = get_toolbox_xml(section_name, section_id, args.tools_subdir, xml_filenames) with open(toolbox_pathname, 'wt') as fout: fout.write(toolbox_xml)
def main_non_archive(args): # validation if not args.galaxy_root: raise ValueError( 'in non-archive mode the galaxy root must be specified') if not args.tools_subdir: raise ValueError( 'in non-archive mode the tools subdirectory must be specified') # get the module names module_names = meta.get_module_names(args.manifest, args.create_all, args.create_tagged) # create the python subtree tools_subdir_path = os.path.join(args.galaxy_root, 'tools', args.tools_subdir) meta.add_python_files(module_names, tools_subdir_path) shutil.copyfile('galaxy_format_tweak.py', os.path.join(tools_subdir_path, 'galaxy_format_tweak.py')) # create the galaxy xml interface files xml_filenames, import_errors = add_xml_files(args.galaxy_root, module_names, args.short_length, args.tools_subdir) for e in import_errors: print e # create the toolbox xml pointing to the installed xmls toolbox_pathname = os.path.join(args.galaxy_root, args.tool_conf) section_name = args.tools_subdir section_id = args.tools_subdir toolbox_xml = get_toolbox_xml(section_name, section_id, args.tools_subdir, xml_filenames) with open(toolbox_pathname, 'wt') as fout: fout.write(toolbox_xml)
def create_installer(args, cat_info, env_info, module_names): """ Overwrite a staging subtree of the current directory. The idea it to tgz this directory and send it to the target server. On the target server it should be unzipped and extracted, and the installer script should put everything in the correct prespecified directories. """ # define the local staging directory stage = args.make_installer # remove the old staging directory if it exists if os.path.isdir(stage): shutil.rmtree(stage) # create some directories os.makedirs(os.path.join(stage, 'python-files')) os.makedirs(os.path.join(stage, 'xml-files')) # add the appropriate python files and the const data meta.add_python_files(module_names, os.path.join(stage, 'python-files')) # create the xml files identifiers, import_errors = mobyle.add_xml_files( cat_info, env_info, module_names, args.short_length, os.path.join(stage, 'xml-files'), args.runbsub) for e in import_errors: print e # copy the installer script shutil.copy('install-mob-tools.py', os.path.join(stage, 'install-mob-tools.py')) # copy the installer script dependency shutil.copy('mobenv.py', os.path.join(stage, 'mobenv.py')) # create the installer configuration with open(os.path.join(stage, 'install-mob-tools.conf'), 'w') as fout: print >> fout, '#', ' '.join(sys.argv) print >> fout, '\t'.join(['auto_path', env_info.auto_path]) print >> fout, '\t'.join(['python_path', env_info.python_path]) print >> fout, '\t'.join(['mob_core', env_info.mob_core]) print >> fout, '\t'.join(['mob_version', args.mobyle_version]) # create a file with a fragment that could be added to the config with open(os.path.join(stage, 'sys.config.fragment'), 'w') as fout: print >> fout, '# begin autogenerated code' print >> fout, 'my_pca_names = [' for ident in sorted(identifiers): print >> fout, "\t\t'%s'," % ident print >> fout, "\t\t]" dstring = "dict((x, 'Sys') for x in my_pca_names)" print >> fout, 'PARTICULAR_BATCH.update(%s)' % dstring print >> fout, '# end autogenerated code' # use subprocess instead of tarfile to create the tgz cmd = ['tar', 'czvf', stage + '.tgz', stage] subprocess.call(cmd)
def main_archive(args): # validation if args.galaxy_root: raise ValueError( 'in archive mode the galaxy root must not be specified') if args.tools_subdir: raise ValueError( 'in archive mode the tools subdirectory must not be specified') # define the archive extension and the compression command archive_extension = '.tar.bz2' archive_prefix = os.path.basename(args.suite_archive.rstrip('/')) archive_name = archive_prefix + archive_extension archive_cmd = ['tar', 'cjvf', archive_name, args.suite_archive] # delete the suite directory and archive if they exist try: shutil.rmtree(args.suite_archive) os.remove(archive_name) except OSError as e: pass # get the module names module_names = meta.get_module_names(args.manifest, args.create_all, args.create_tagged) # create the empty suite directory os.makedirs(args.suite_archive) # add the python files meta.add_python_files(module_names, args.suite_archive) shutil.copyfile('galaxy_format_tweak.py', os.path.join(args.suite_archive, 'galaxy_format_tweak.py')) # create the galaxy xml interface files mod_infos, import_errors = add_xml_archive_files(module_names, args.short_length, args.suite_archive) for e in import_errors: print e # create the toolbox xml pointing to the installed xmls config_pathname = os.path.join(args.suite_archive, 'suite_config.xml') config_xml = get_suite_config_xml(mod_infos, archive_prefix) with open(config_pathname, 'wt') as fout: fout.write(config_xml) # use subprocess instead of tarfile to create the tgz subprocess.call(archive_cmd)
def main_archive(args): # validation if args.galaxy_root: raise ValueError( 'in archive mode the galaxy root must not be specified') if args.tools_subdir: raise ValueError( 'in archive mode the tools subdirectory must not be specified') # define the archive extension and the compression command archive_extension = '.tar.bz2' archive_prefix = os.path.basename(args.suite_archive.rstrip('/')) archive_name = archive_prefix + archive_extension archive_cmd = ['tar', 'cjvf', archive_name, args.suite_archive] # delete the suite directory and archive if they exist try: shutil.rmtree(args.suite_archive) os.remove(archive_name) except OSError as e: pass # get the module names module_names = meta.get_module_names( args.manifest, args.create_all, args.create_tagged) # create the empty suite directory os.makedirs(args.suite_archive) # add the python files meta.add_python_files(module_names, args.suite_archive) shutil.copyfile('galaxy_format_tweak.py', os.path.join(args.suite_archive, 'galaxy_format_tweak.py')) # create the galaxy xml interface files mod_infos, import_errors = add_xml_archive_files( module_names, args.short_length, args.suite_archive) for e in import_errors: print e # create the toolbox xml pointing to the installed xmls config_pathname = os.path.join(args.suite_archive, 'suite_config.xml') config_xml = get_suite_config_xml(mod_infos, archive_prefix) with open(config_pathname, 'wt') as fout: fout.write(config_xml) # use subprocess instead of tarfile to create the tgz subprocess.call(archive_cmd)
def main(args): # check for flag conflicts if args.deploy and args.make_installer: raise ValueError( 'the "deploy" and "make_installer" flags are incompatible') # initialize the mobyle category information cat_info = mobyle.CategoryInfo(args.show_io_types, args.show_tags, args.universal_category) # get the module names module_names = meta.get_module_names(args.manifest, args.create_all, args.create_tagged) # define the environment on the target server auto_path = os.path.join(args.target, 'auto.py') env_info = mobenv.create_environment_info(auto_path, args.python_path, args.mobyle_core, args.mobyle_version) if args.make_installer: create_installer(args, cat_info, env_info, module_names) else: # create the python subtree meta.add_python_files(module_names, args.target) # create the mobyle xml interface files import_errors = mobyle.add_xml_files(cat_info, env_info, module_names, args.short_length, env_info.get_xml_dir(), args.runbsub) for e in import_errors: print e if args.clean: cmd = env_info.get_clean_command() subprocess.call(cmd) if args.index: cmd = env_info.get_index_command() subprocess.call(cmd) if args.deploy: cmd = env_info.get_deploy_command() subprocess.call(cmd)
def main(args): # check for flag conflicts if args.deploy and args.make_installer: raise ValueError( 'the "deploy" and "make_installer" flags are incompatible') # initialize the mobyle category information cat_info = mobyle.CategoryInfo( args.show_io_types, args.show_tags, args.universal_category) # get the module names module_names = meta.get_module_names( args.manifest, args.create_all, args.create_tagged) # define the environment on the target server auto_path = os.path.join(args.target, 'auto.py') env_info = mobenv.create_environment_info( auto_path, args.python_path, args.mobyle_core, args.mobyle_version) if args.make_installer: create_installer(args, cat_info, env_info, module_names) else: # create the python subtree meta.add_python_files(module_names, args.target) # create the mobyle xml interface files import_errors = mobyle.add_xml_files( cat_info, env_info, module_names, args.short_length, env_info.get_xml_dir(), args.runbsub) for e in import_errors: print e if args.clean: cmd = env_info.get_clean_command() subprocess.call(cmd) if args.index: cmd = env_info.get_index_command() subprocess.call(cmd) if args.deploy: cmd = env_info.get_deploy_command() subprocess.call(cmd)
def main(args): with open(args.manifest) as fin: module_names = [x.strip() for x in fin] meta.add_python_files(module_names, args.target)