Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/planemo/galaxy_serve.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell |
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d67268158946 |
|---|---|
| 1 import contextlib | |
| 2 import os | |
| 3 | |
| 4 from planemo import galaxy_config | |
| 5 from planemo import galaxy_run | |
| 6 from planemo import io | |
| 7 | |
| 8 | |
| 9 def serve(ctx, paths, **kwds): | |
| 10 # TODO: Preceate a user. | |
| 11 # TODO: Setup an admin user. | |
| 12 # TODO: Pass through more parameters. | |
| 13 # TODO: Populate test-data directory as FTP directory. | |
| 14 daemon = kwds.get("daemon", False) | |
| 15 if daemon: | |
| 16 kwds["no_cleanup"] = True | |
| 17 | |
| 18 with galaxy_config.galaxy_config(ctx, paths, **kwds) as config: | |
| 19 # TODO: Allow running dockerized Galaxy here instead. | |
| 20 run_script = os.path.join(config.galaxy_root, "run.sh") | |
| 21 if daemon: | |
| 22 run_script += " --daemon --wait" | |
| 23 config.env["GALAXY_RUN_ALL"] = "1" | |
| 24 else: | |
| 25 run_script += " --server-name '%s' --reload" % config.server_name | |
| 26 server_ini = os.path.join(config.config_directory, "galaxy.ini") | |
| 27 config.env["GALAXY_CONFIG_FILE"] = server_ini | |
| 28 cmds = [ | |
| 29 run_script, | |
| 30 ] | |
| 31 cmd = "; ".join(cmds) | |
| 32 action = "Starting galaxy" | |
| 33 galaxy_run.run_galaxy_command( | |
| 34 ctx, | |
| 35 cmd, | |
| 36 config.env, | |
| 37 action, | |
| 38 ) | |
| 39 return config | |
| 40 | |
| 41 | |
| 42 @contextlib.contextmanager | |
| 43 def shed_serve(ctx, install_args_list, **kwds): | |
| 44 config = serve(ctx, [], daemon=True, **kwds) | |
| 45 install_deps = not kwds.get("skip_dependencies", False) | |
| 46 try: | |
| 47 io.info("Installing repositories - this may take some time...") | |
| 48 for install_args in install_args_list: | |
| 49 install_args["install_tool_dependencies"] = install_deps | |
| 50 install_args["install_repository_dependencies"] = True | |
| 51 install_args["new_tool_panel_section_label"] = "Shed Installs" | |
| 52 config.install_repo( | |
| 53 **install_args | |
| 54 ) | |
| 55 config.wait_for_all_installed() | |
| 56 yield config | |
| 57 finally: | |
| 58 config.kill() | |
| 59 if not kwds.get("no_cleanup", False): | |
| 60 config.cleanup() |
