(argv)
| 4758 | |
| 4759 | |
| 4760 | def _main(argv): # pragma: no coverage |
| 4761 | args, parser = _cli_parse(argv) |
| 4762 | |
| 4763 | def _cli_error(cli_msg): |
| 4764 | parser.print_help() |
| 4765 | _stderr('\nError: %s\n' % cli_msg) |
| 4766 | sys.exit(1) |
| 4767 | |
| 4768 | if args.version: |
| 4769 | print('Bottle %s' % __version__) |
| 4770 | sys.exit(0) |
| 4771 | if not args.app: |
| 4772 | _cli_error("No application entry point specified.") |
| 4773 | |
| 4774 | sys.path.insert(0, '.') |
| 4775 | sys.modules.setdefault('bottle', sys.modules['__main__']) |
| 4776 | |
| 4777 | host, port = (args.bind or 'localhost'), 8080 |
| 4778 | if ':' in host and host.rfind(']') < host.rfind(':'): |
| 4779 | host, port = host.rsplit(':', 1) |
| 4780 | host = host.strip('[]') |
| 4781 | |
| 4782 | config = ConfigDict() |
| 4783 | |
| 4784 | for cfile in args.conf or []: |
| 4785 | try: |
| 4786 | if cfile.endswith('.json'): |
| 4787 | with open(cfile, 'rb') as fp: |
| 4788 | config.load_dict(json_loads(fp.read())) |
| 4789 | else: |
| 4790 | config.load_config(cfile) |
| 4791 | except configparser.Error as parse_error: |
| 4792 | _cli_error(parse_error) |
| 4793 | except IOError: |
| 4794 | _cli_error("Unable to read config file %r" % cfile) |
| 4795 | except (UnicodeError, TypeError, ValueError) as error: |
| 4796 | _cli_error("Unable to parse config file %r: %s" % (cfile, error)) |
| 4797 | |
| 4798 | for cval in args.param or []: |
| 4799 | if '=' in cval: |
| 4800 | config.update((cval.split('=', 1),)) |
| 4801 | else: |
| 4802 | config[cval] = True |
| 4803 | |
| 4804 | run(args.app, |
| 4805 | host=host, |
| 4806 | port=int(port), |
| 4807 | server=args.server, |
| 4808 | reloader=args.reload, |
| 4809 | plugins=args.plugin, |
| 4810 | debug=args.debug, |
| 4811 | config=config) |
| 4812 | |
| 4813 | |
| 4814 | if __name__ == '__main__': # pragma: no coverage |
no test coverage detected
searching dependent graphs…