Example #1
0
def main():
    """Main function that is called at the startup of Maraschino."""
    from optparse import OptionParser

    p = OptionParser()

    # define command line options
    p.add_option('-p',
                 '--port',
                 dest='port',
                 default=None,
                 help="Force webinterface to listen on this port")
    p.add_option('-d',
                 '--daemon',
                 dest='daemon',
                 action='store_true',
                 help='Run as a daemon')
    p.add_option(
        '--pidfile',
        dest='pidfile',
        help='Create a pid file (only relevant when running as a daemon)')
    p.add_option('--log',
                 dest='log',
                 help='Create a log file at a desired location')
    p.add_option('-v',
                 '--verbose',
                 dest='verbose',
                 action='store_true',
                 help='Silence the logger')
    p.add_option('--develop',
                 action="store_true",
                 dest='develop',
                 help="Start instance of development server")
    p.add_option('--database',
                 dest='database',
                 help='Custom database file location')
    p.add_option('--webroot', dest='webroot', help='Web root for Maraschino')
    p.add_option('--host', dest='host', help='Web host for Maraschino')
    p.add_option('--kiosk',
                 dest='kiosk',
                 action='store_true',
                 help='Disable settings in the UI')
    p.add_option('--datadir',
                 dest='datadir',
                 help='Write program data to custom location')
    p.add_option('--noupdate',
                 action="store_true",
                 dest='noupdate',
                 help='Disable the internal updater')

    # parse command line for defined options
    options, args = p.parse_args()

    if options.datadir:
        data_dir = options.datadir
    else:
        data_dir = rundir

    if options.daemon:
        maraschino.DAEMON = True
        maraschino.VERBOSE = False

    if options.pidfile:
        maraschino.PIDFILE = options.pidfile
        maraschino.VERBOSE = False

    if options.port:
        PORT = int(options.port)
    else:
        PORT = 7000

    if options.log:
        maraschino.LOG_FILE = options.log

    if options.verbose:
        maraschino.VERBOSE = True

    if options.develop:
        maraschino.DEVELOPMENT = True

    if options.database:
        DATABASE = options.database
    else:
        DATABASE = os.path.join(data_dir, 'maraschino.db')

    if options.webroot:
        maraschino.WEBROOT = options.webroot

    if options.host:
        maraschino.HOST = options.host

    if options.kiosk:
        maraschino.KIOSK = True

    if options.noupdate:
        maraschino.UPDATER = False

    maraschino.RUNDIR = rundir
    maraschino.DATA_DIR = data_dir
    maraschino.FULL_PATH = os.path.join(rundir, 'Maraschino.py')
    maraschino.ARGS = sys.argv[1:]
    maraschino.PORT = PORT
    maraschino.DATABASE = DATABASE

    maraschino.initialize()

    if maraschino.PIDFILE or maraschino.DAEMON:
        maraschino.daemonize()

    import_modules()
    maraschino.init_updater()

    maraschino.start()
Example #2
0
def main():
    """Main function that is called at the startup of Maraschino."""
    from optparse import OptionParser

    p = OptionParser()

    # define command line options
    p.add_option('-p', '--port',
                 dest='port',
                 default=None,
                 help="Force webinterface to listen on this port")
    p.add_option('-d', '--daemon',
                 dest='daemon',
                 action='store_true',
                 help='Run as a daemon')
    p.add_option('--pidfile',
                 dest='pidfile',
                 help='Create a pid file (only relevant when running as a daemon)')
    p.add_option('--log',
                 dest='log',
                 help='Create a log file at a desired location')
    p.add_option('-v', '--verbose',
                 dest='verbose',
                 action='store_true',
                 help='Silence the logger')
    p.add_option('--develop',
                 action="store_true",
                 dest='develop',
                 help="Start instance of development server")
    p.add_option('--database',
                 dest='database',
                 help='Custom database file location')
    p.add_option('--webroot',
                 dest='webroot',
                 help='Web root for Maraschino')
    p.add_option('--host',
                 dest='host',
                 help='Web host for Maraschino')
    p.add_option('--kiosk',
                 dest='kiosk',
                 action='store_true',
                 help='Disable settings in the UI')
    p.add_option('--datadir',
                 dest='datadir',
                 help='Write program data to custom location')
    p.add_option('--noupdate',
                 action="store_true",
                 dest='noupdate',
                 help='Disable the internal updater')

    # parse command line for defined options
    options, args = p.parse_args()

    if options.datadir:
        data_dir = options.datadir
    else:
        data_dir = rundir

    if options.daemon:
        maraschino.DAEMON = True
        maraschino.VERBOSE = False

    if options.pidfile:
        maraschino.PIDFILE = options.pidfile
        maraschino.VERBOSE = False

    if options.port:
        PORT = int(options.port)
    else:
        PORT = 7000

    if options.log:
        maraschino.LOG_FILE = options.log

    if options.verbose:
        maraschino.VERBOSE = True

    if options.develop:
        maraschino.DEVELOPMENT = True

    if options.database:
        DATABASE = options.database
    else:
        DATABASE = os.path.join(data_dir, 'maraschino.db')

    if options.webroot:
        maraschino.WEBROOT = options.webroot

    if options.host:
        maraschino.HOST = options.host

    if options.kiosk:
        maraschino.KIOSK = True

    if options.noupdate:
        maraschino.UPDATER = False

    maraschino.RUNDIR = rundir
    maraschino.DATA_DIR = data_dir
    maraschino.FULL_PATH = os.path.join(rundir, 'Maraschino.py')
    maraschino.ARGS = sys.argv[1:]
    maraschino.PORT = PORT
    maraschino.DATABASE = DATABASE

    maraschino.initialize()

    if maraschino.PIDFILE or maraschino.DAEMON:
        maraschino.daemonize()

    import_modules()
    maraschino.init_updater()

    maraschino.start()
Example #3
0
def main():
    from optparse import OptionParser
    p = OptionParser()

    p.add_option('-p', '--port',
                 dest='port',
                 default=None,
                 help="Force webinterface to listen on this port")
    p.add_option('-d', '--daemon',
                 dest='daemon',
                 action='store_true',
                 help='Run as a daemon')
    p.add_option('--pidfile',
                 dest='pidfile',
                 help='Create a pid file (only relevant when running as a daemon)')
    p.add_option('--log',
                 dest='log',
                 help='Create a log file at a desired location')
    p.add_option('-v', '--verbose',
                 dest='verbose',
                 action='store_true',
                 help='Silence the logger')
    p.add_option('--develop',
                 action="store_true",
                 dest='develop',
                 help="Start instance of development server")
    p.add_option('--database',
                 dest='database',
                 help='Custom database file location')
    p.add_option('--webroot',
                 dest='webroot',
                 help='web root for Maraschino')

    options, args = p.parse_args()

    if options.daemon:
        maraschino.DAEMON = True
        maraschino.VERBOSE = False

    if options.pidfile:
        maraschino.PIDFILE = options.pidfile
        maraschino.VERBOSE = False

    if options.port:
        PORT = int(options.port)
    else:
        PORT = 7000

    if options.log:
        maraschino.LOG_FILE = options.log

    if options.verbose:
        maraschino.VERBOSE = True

    if options.develop:
        maraschino.DEVELOPMENT = True

    if options.database:
        DATABASE = options.database
    else:
        DATABASE = os.path.join(rundir, 'maraschino.db')

    if options.webroot:
        maraschino.WEBROOT = options.webroot

    maraschino.RUNDIR = rundir
    maraschino.FULL_PATH = os.path.join(rundir, 'Maraschino.py')
    maraschino.ARGS = sys.argv[1:]
    maraschino.PORT = PORT
    maraschino.DATABASE = DATABASE

    maraschino.initialize()

    import_modules()

    if maraschino.PIDFILE or maraschino.DAEMON:
        maraschino.daemonize()

    maraschino.start()