示例#1
0
def main(argv):
    '''
    Main entry point into the program.
    '''

    # Get arguments and argument parser.
    (args, parser) = app.cli(argv)

    # Initialize logging and set verbosity level.
    logger = logging.get_logger(__name__)

    logger.debug(f'Program arguments: {argv}')
    # Check if any command arguments have been passed.
    if (len(argv) <= 1):
        # No arguments passed.
        logger.warning(f'No command arguments passed')
        #parser.print_help()
        #sys.exit(errno.EAGAIN)

    if args.list_configs:
        configs = settings.list_configs()
        print(configs)
        return os.EX_OK

    # Initialize our app.
    try:
        app.init(args)
    except Exception as e:
        logger.exception(e)
        logger.failure(f'App initialization failed: {e.errno}')
        parser.print_help()
        return os.EX_SOFTWARE

    # Load application configuration.
    try:
        config = app.load_config(args)
    except Exception as e:
        logger.exception(e)
        logger.failure(f'App configuration failed: {e.errno}')
        parser.print_help()
        return os.EX_CONFIG

    # Do something with config before running main app logic.

    # Run main app logic
    try:
        exit_code = app.process(args, config)
    except Exception as e:
        logger.exception(e)
        logger.failure(f'App processing failed: {e.errno}')
        parser.print_help()
        return os.EX_SOFTWARE

    # Handle anything else you need to, we're getting out of here.

    return exit_code
示例#2
0
# -*- coding: utf-8 -*-


"""futuresticks.__main__: executed when futurestick directory is called as script. try 'python futuresticks get_quote' in parent folder. """


#from .bootstrap import main
#main()

from app import cli
cli()
示例#3
0
import sys
import eventlet

eventlet.monkey_patch()

# Import application modules
from app import config

# CLI Command configuration
from app import cli

# Executes the application
if __name__ == '__main__': cli()
示例#4
0
#!/usr/bin/env python

import api
from app import cli

if __name__ == '__main__':
    api.app.debug = True
    cli(api, port=5000)
示例#5
0
#!/usr/bin/env python

import website
from app import cli

if __name__ == '__main__':
    # TODO: use a conf file for this
    import _api
    _api.api_url = 'http://localhost:5000'
    website.app.config.update({
        'STATIC_ROOT': '/static/',
        'DEBUG': True,
    })
    cli(website, port=5001)