def main(args=None): """Merges commands offered by pyct and bokeh and provides help for both""" from bokeh.command.subcommands import all as bokeh_commands try: import pyct.cmd pyct_commands = ['copy-examples', 'examples'] except Exception: pass parser = argparse.ArgumentParser( prog="panel", epilog="See '<command> --help' to read about a specific subcommand.") parser.add_argument('-v', '--version', action='version', version=__version__) subs = parser.add_subparsers(help="Sub-commands") for cmd in pyct_commands: cmd = cmd.replace('-', '_') fn = getattr(pyct.cmd, cmd) subs.add_parser(cmd, help=fn.__doc__) for cls in bokeh_commands: subs.add_parser(cls.name, help=cls.help) if len(sys.argv) == 1: all_commands = sorted([c.name for c in bokeh_commands] + pyct_commands) die("ERROR: Must specify subcommand, one of: %s" % nice_join(all_commands)) if sys.argv[1] in ('--help', '-h'): args = parser.parse_args(sys.argv[1:]) args.invoke(args) sys.exit() if len(sys.argv) > 1 and any(sys.argv[1] == c.name for c in bokeh_commands): if sys.argv[1] == 'serve' and not any( arg.startswith('--index') for arg in sys.argv): sys.argv = sys.argv + ['--index=%s' % INDEX_HTML] sys.argv = transform_cmds(sys.argv) bokeh_entry_point() elif sys.argv[1] in pyct_commands: try: import pyct.cmd except ImportError: print( "install pyct to enable this command (e.g. `conda install -c pyviz pyct` or `pip install pyct[cmd]`)" ) sys.exit(1) pyct.cmd.substitute_main('panel', cmds=pyct_commands, args=args) else: parser.parse_args(sys.argv[1:]) sys.exit(1)
def main(args=None): """Special case: Allow Bokeh to handle the `serve` command; rest is handled by pyct.""" if len(sys.argv) > 1 and 'serve' == sys.argv[1]: sys.argv = transform_cmds(sys.argv) bokeh_entry_point() else: try: import pyct.cmd except ImportError: print("install pyct to enable this command (e.g. `conda install -c pyviz pyct` or `pip install pyct[cmd]`)") sys.exit(1) pyct.cmd.substitute_main('panel',args=args)
def alignment(ctx, align_catalog, bokeh_serve_args): import sys import pore_c # from pore_c.dashboard import main from bokeh.__main__ import main as bokeh_entry_point main_path = pore_c.__file__.rsplit("/", 1)[0] + "/dashboard/" sys.argv = ["bokeh", "serve"] + [main_path] + list(bokeh_serve_args) + [ "--args", align_catalog ] bokeh_entry_point()
def main(args=None): """Merges commands offered by pyct and bokeh and provides help for both""" from bokeh.command.subcommands import all as bokeh_commands bokeh_commands = bokeh_commands + [OAuthSecret] try: import pyct.cmd pyct_commands = ['copy-examples', 'examples'] except Exception: pass parser = argparse.ArgumentParser( prog="panel", epilog="See '<command> --help' to read about a specific subcommand.") parser.add_argument('-v', '--version', action='version', version=__version__) subs = parser.add_subparsers(help="Sub-commands") for cmd in pyct_commands: cmd = cmd.replace('-', '_') fn = getattr(pyct.cmd, cmd) subs.add_parser(cmd, help=fn.__doc__) for cls in bokeh_commands: if cls is BkServe: subparser = subs.add_parser(Serve.name, help=Serve.help) subcommand = Serve(parser=subparser) subparser.set_defaults(invoke=subcommand.invoke) else: subs.add_parser(cls.name, help=cls.help) if len(sys.argv) == 1: all_commands = sorted([c.name for c in bokeh_commands] + pyct_commands) die("ERROR: Must specify subcommand, one of: %s" % nice_join(all_commands)) if sys.argv[1] in ('--help', '-h'): args = parser.parse_args(sys.argv[1:]) args.invoke(args) sys.exit() if len(sys.argv) > 1 and any(sys.argv[1] == c.name for c in bokeh_commands): sys.argv = transform_cmds(sys.argv) if sys.argv[1] == 'serve': args = parser.parse_args(sys.argv[1:]) try: ret = args.invoke(args) except Exception as e: die("ERROR: " + str(e)) elif sys.argv[1] == 'oauth-secret': ret = OAuthSecret(parser).invoke(args) else: ret = bokeh_entry_point() elif sys.argv[1] in pyct_commands: try: import pyct.cmd except ImportError: print( "install pyct to enable this command (e.g. `conda install -c pyviz pyct` or `pip install pyct[cmd]`)" ) sys.exit(1) pyct.cmd.substitute_main('panel', cmds=pyct_commands, args=args) else: parser.parse_args(sys.argv[1:]) sys.exit(1) if ret is False: sys.exit(1) elif ret is not True and isinstance(ret, int) and ret != 0: sys.exit(ret)
def main(): sys.argv = transform_cmds(sys.argv) bokeh_entry_point()
def main(): bokeh_entry_point()