Here are the examples of the python api bokeh.command.util.die taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Source : test_util.py
with MIT License
from rthorst
with MIT License
from rthorst
def test_die(capsys):
with pytest.raises(SystemExit):
util.die("foo")
out, err = capsys.readouterr()
assert err == "foo\n"
assert out == ""
def test_build_single_handler_application_unknown_file():
0
Source : __init__.py
with BSD 3-Clause "New" or "Revised" License
from holoviz
with BSD 3-Clause "New" or "Revised" License
from holoviz
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)
sys.exit()
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)
if __name__ == "__main__":