Esempio n. 1
0
def main(args):
    parser = optparse.OptionParser()
    parser.add_option('', '--command', action="store", dest="command")
    parser.add_option('', '--record', action="store", dest="record")
    parser.add_option('-v', '--verbose', action="store_true", dest="verbose")
    parser.add_option('-d',
                      '--duration',
                      action="store",
                      dest="duration",
                      type="float",
                      default=0.01)
    parser.add_option('-p', '--prompt', action="store_true", dest="prompt")
    parser.add_option('-i', '--interact', action="store_true", dest="interact")
    options, args = parser.parse_args(args)

    if 'DISPLAY' not in os.environ:
        import startx
        startx.startX()

    if options.record and options.command:
        raise SystemExit(
            "You can't specify a command and recording at the same time")
    if options.record:
        if options.verbose:
            set_log_level('recorder', 5)
        _record(options, options.record, args[1:])
    else:
        if len(args) < 2:
            raise SystemExit("Error: needs a filename to play")
        if options.verbose:
            set_log_level('player', 5)
        _play(options, args[1], args[2:])
Esempio n. 2
0
def main(args):
    parser = optparse.OptionParser()
    parser.add_option('', '--command', action="store",
                      dest="command")
    parser.add_option('', '--record', action="store",
                      dest="record")
    parser.add_option('-v', '--verbose', action="store_true",
                      dest="verbose")
    parser.add_option('-d', '--duration', action="store",
                      dest="duration", type="float", default=0.01)
    parser.add_option('-p', '--prompt', action="store_true",
                      dest="prompt")
    parser.add_option('-i', '--interact', action="store_true",
                      dest="interact")
    options, args = parser.parse_args(args)

    if 'DISPLAY' not in os.environ:
        import startx
        startx.startX()

    if options.record and options.command:
        raise SystemExit(
            "You can't specify a command and recording at the same time")
    if options.record:
        if options.verbose:
            set_log_level('recorder', 5)
        _record(options, options.record, args[1:])
    else:
        if len(args) < 2:
            raise SystemExit("Error: needs a filename to play")
        if options.verbose:
            set_log_level('player', 5)
        _play(options, args[1], args[2:])
Esempio n. 3
0
def main(args):
    parser = optparse.OptionParser()
    parser.add_option('', '--command', action="store", dest="command")
    parser.add_option('', '--record', action="store", dest="record")
    parser.add_option('-v', '--verbose', action="store_true", dest="verbose")
    options, args = parser.parse_args(args)

    if options.record and options.command:
        raise SystemExit(
            "You can't specify a command and recording at the same time")
    if options.record:
        if options.verbose:
            set_log_level('recorder', 5)
        _record(options, options.record, args[1:])
    else:
        if len(args) < 2:
            raise SystemExit("Error: needs a filename to play")
        if options.verbose:
            set_log_level('player', 5)
        _play(options, args[1], args[2:])
Esempio n. 4
0
File: main.py Progetto: Schevo/kiwi
def main(args):
    parser = optparse.OptionParser()
    parser.add_option('', '--command', action="store",
                      dest="command")
    parser.add_option('', '--record', action="store",
                      dest="record")
    parser.add_option('-v', '--verbose', action="store_true",
                      dest="verbose")
    options, args = parser.parse_args(args)

    if options.record and options.command:
        raise SystemExit(
            "You can't specify a command and recording at the same time")
    if options.record:
        if options.verbose:
            set_log_level('recorder', 5)
        _record(options, options.record, args[1:])
    else:
        if len(args) < 2:
            raise SystemExit("Error: needs a filename to play")
        if options.verbose:
            set_log_level('player', 5)
        _play(options, args[1], args[2:])
Esempio n. 5
0
def setup(config=None, options=None, register_station=True, check_schema=True,
          load_plugins=True):
    """
    Loads the configuration from arguments and configuration file.

    @param config: a StoqConfig instance
    @param options: a Optionparser instance
    @param register_station: if we should register the branch station.
    @param check_schema: if we should check the schema
    @param load_plugins: if we should load plugins for the system
    """

    # NOTE: No GUI calls are allowed in here
    #       If you change anything here, you need to verify that all
    #       callsites are still working properly.
    #       bin/stoq
    #       bin/stoqdbadmin
    #       python stoq/tests/runtest.py

    if options is None:
        parser = get_option_parser()
        options, args = parser.parse_args(sys.argv)

    if options.verbose:
        from kiwi.log import set_log_level
        set_log_level('stoq*', 0)

    setup_path()

    if config is None:
        config = StoqConfig()
        if options.filename:
            config.load(options.filename)
        else:
            config.load_default()
    config.set_from_options(options)

    register_config(config)

    if options and options.sqldebug:
        enable_debugging()

    from stoq.lib.applist import ApplicationDescriptions
    provide_utility(IApplicationDescriptions, ApplicationDescriptions(),
                    replace=True)

    if register_station:
        try:
            default_store = get_default_store()
        except DatabaseError as e:
            error(e.short, str(e.msg))

        config.get_settings().check_version(default_store)

        if check_schema:
            migration = StoqlibSchemaMigration()
            migration.check()

        if options and options.sqldebug:
            enable_debugging()

        set_current_branch_station(default_store, station_name=None)

    if load_plugins:
        from stoqlib.lib.pluginmanager import get_plugin_manager
        manager = get_plugin_manager()
        manager.activate_installed_plugins()

    if check_schema:
        default_store = get_default_store()
        if not default_store.table_exists('system_table'):
            error(
                _("Database schema error"),
                _("Table 'system_table' does not exist.\n"
                  "Consult your database administrator to solve this problem."))

        if check_schema:
            migration = StoqlibSchemaMigration()
            migration.check()
Esempio n. 6
0
def setup(config=None, options=None, register_station=True, check_schema=True,
          load_plugins=True):
    """
    Loads the configuration from arguments and configuration file.

    @param config: a StoqConfig instance
    @param options: a Optionparser instance
    @param register_station: if we should register the branch station.
    @param check_schema: if we should check the schema
    @param load_plugins: if we should load plugins for the system
    """

    # NOTE: No GUI calls are allowed in here
    #       If you change anything here, you need to verify that all
    #       callsites are still working properly.
    #       bin/stoq
    #       bin/stoqdbadmin
    #       python stoq/tests/runtest.py

    if options is None:
        parser = get_option_parser()
        options, args = parser.parse_args(sys.argv)

    if options.verbose:
        from kiwi.log import set_log_level
        set_log_level('stoq*', 0)

    setup_path()

    if config is None:
        config = StoqConfig()
        if options.filename:
            config.load(options.filename)
        else:
            config.load_default()
    config.set_from_options(options)

    register_config(config)

    if options and options.sqldebug:
        enable_debugging()

    from stoq.lib.applist import ApplicationDescriptions
    provide_utility(IApplicationDescriptions, ApplicationDescriptions(),
                    replace=True)

    db_settings = config.get_settings()
    try:
        default_store = get_default_store()
    except DatabaseError as e:
        # Only raise an error if a database is actually required
        if register_station or load_plugins or check_schema:
            error(e.short, str(e.msg))
        else:
            default_store = None

    if register_station:
        db_settings.check_version(default_store)
        if check_schema:
            migration = StoqlibSchemaMigration()
            migration.check()

        if options and options.sqldebug:
            enable_debugging()

        set_current_branch_station(default_store, station_name=None)

    if load_plugins:
        from stoqlib.lib.pluginmanager import get_plugin_manager
        manager = get_plugin_manager()
        manager.activate_installed_plugins()

    if check_schema:
        if not default_store.table_exists('system_table'):
            error(
                _("Database schema error"),
                _("Table 'system_table' does not exist.\n"
                  "Consult your database administrator to solve this problem."))

        if check_schema:
            migration = StoqlibSchemaMigration()
            migration.check()