MCPcopy
hub / github.com/coleifer/sqlite-web / configure_app

Function configure_app

sqlite_web/sqlite_web.py:1637–1731  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1635 datasets[os.path.basename(filename)] = initialize_dataset(filename)
1636
1637def configure_app():
1638 # This function exists to act as a console script entry-point.
1639 parser = get_option_parser()
1640 options, args = parser.parse_args()
1641
1642 if not args:
1643 die('Error: missing required path to database file.')
1644
1645 werkzeug_logger = logging.getLogger('werkzeug')
1646 if options.log_file:
1647 fmt = logging.Formatter('[%(asctime)s] - [%(levelname)s] - %(message)s')
1648 handler = WatchedFileHandler(options.log_file)
1649 handler.setLevel(logging.DEBUG if options.debug else logging.WARNING)
1650 handler.setFormatter(fmt)
1651 app.logger.addHandler(handler)
1652
1653 # Remove default handler.
1654 from flask.logging import default_handler
1655 app.logger.removeHandler(default_handler)
1656
1657 if options.quiet:
1658 app.logger.setLevel(logging.ERROR)
1659 werkzeug_logger.setLevel(logging.ERROR)
1660
1661 password = None
1662 if options.prompt_password:
1663 if os.environ.get('SQLITE_WEB_PASSWORD'):
1664 password = os.environ['SQLITE_WEB_PASSWORD']
1665 else:
1666 while True:
1667 password = getpass('Enter password: ')
1668 password_confirm = getpass('Confirm password: ')
1669 if password != password_confirm:
1670 print('Passwords did not match!')
1671 else:
1672 break
1673
1674 if options.rows_per_page:
1675 app.config['ROWS_PER_PAGE'] = options.rows_per_page
1676 if options.query_rows_per_page:
1677 app.config['QUERY_ROWS_PER_PAGE'] = options.query_rows_per_page
1678 if options.base64:
1679 app.config['BLOB_AS_BASE64'] = options.base64
1680
1681 app.config['TRUNCATE_VALUES'] = options.truncate_values
1682
1683 # Store reference to these config options.
1684 app.config['ENABLE_LOAD'] = options.enable_load
1685 app.config['ENABLE_FILESYSTEM'] = options.enable_filesystem
1686 app.config['DB_UPLOAD_DIR'] = options.upload_dir
1687
1688 if options.startup_hook:
1689 try:
1690 module_path, hook_name = options.startup_hook.rsplit('.', 1)
1691 except Exception:
1692 die('startup hook must be dotted-path to module.hook_function')
1693 module = importlib.import_module(module_path)
1694 try:

Callers 2

mainFunction · 0.90
mainFunction · 0.85

Calls 4

get_option_parserFunction · 0.85
dieFunction · 0.85
initialize_appFunction · 0.85
open_browser_tabFunction · 0.85

Tested by

no test coverage detected