当前位置: 首页>>代码示例>>Python>>正文


Python message.error函数代码示例

本文整理汇总了Python中stoqlib.lib.message.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _check_database

    def _check_database(self):
        try:
            log.info("Locking database")
            self.default_store.lock_database()
        except DatabaseError:
            msg = _('Could not lock database. This means there are other clients '
                    'connected. Make sure to close every Stoq client '
                    'before updating the database')
            error(msg)

        # Database migration is actually run in subprocesses, We need to unlock
        # the tables again and let the upgrade continue
        log.info("Releasing database lock")
        self.default_store.unlock_database()

        sucess = db_settings.test_connection()
        if not sucess:
            # FIXME: Improve this message after 1.5 is released
            msg = _(u'Could not connect to the database using command line '
                    'tool! Aborting.') + ' '
            msg += _(u'Please, check if you can connect to the database '
                     'using:') + ' '
            msg += _(u'psql -l -h <server> -p <port> -U <username>')
            error(msg)
            return

        return True
开发者ID:Guillon88,项目名称:stoq,代码行数:27,代码来源:migration.py

示例2: install_plugin

    def install_plugin(self, plugin_name):
        """Install and enable a plugin

        @important: Calling this makes a plugin installed, but, it's
            your responsability to activate it!

        :param plugin: the :class:`IPlugin` implementation of the plugin
        """
        # Try to get the plugin first. If it was't registered yet,
        # PluginError will be raised.
        plugin = self.get_plugin(plugin_name)

        if plugin_name in self.installed_plugins_names:
            raise PluginError("Plugin %s is already enabled."
                              % (plugin_name, ))

        store = new_store()
        InstalledPlugin(store=store,
                        plugin_name=plugin_name,
                        plugin_version=0)
        store.commit(close=True)

        migration = plugin.get_migration()
        if migration:
            try:
                migration.apply_all_patches()
            except SQLError:
                # This means a lock could not be obtained. Warn user about this
                # and let stoq restart, that the schema will be upgraded
                # correctly
                error('Não foi possível terminar a instalação do plugin. '
                      'Por favor reinicie todas as instancias do Stoq que '
                      'estiver executando')
开发者ID:romaia,项目名称:stoq,代码行数:33,代码来源:pluginmanager.py

示例3: _register_branch_station

def _register_branch_station(caller_store, station_name):
    import gtk
    from stoqlib.lib.parameters import sysparam

    if not sysparam.get_bool('DEMO_MODE'):
        fmt = _(u"The computer '%s' is not registered to the Stoq "
                u"server at %s.\n\n"
                u"Do you want to register it "
                u"(requires administrator access) ?")
        if not yesno(fmt % (station_name,
                            db_settings.address),
                     gtk.RESPONSE_YES, _(u"Register computer"), _(u"Quit")):
            raise SystemExit

        from stoqlib.gui.utils.login import LoginHelper
        h = LoginHelper(username="admin")
        try:
            user = h.validate_user()
        except LoginError as e:
            error(str(e))

        if not user:
            error(_("Must login as 'admin'"))

    from stoqlib.domain.station import BranchStation
    with new_store() as store:
        branch = sysparam.get_object(store, 'MAIN_COMPANY')
        station = BranchStation.create(store, branch=branch, name=station_name)
    return caller_store.fetch(station)
开发者ID:relsi,项目名称:stoq,代码行数:29,代码来源:runtime.py

示例4: run

    def run(self, appdesc=None, appname=None):
        if not self._do_login():
            raise SystemExit
        from stoq.gui.launcher import Launcher
        from stoqlib.gui.events import StartApplicationEvent
        from stoqlib.lib.message import error
        import gtk
        app_window = Launcher(self._options, self)
        app_window.show()
        app = app_window.app
        StartApplicationEvent.emit(app.name, app)

        # A GtkWindowGroup controls grabs (blocking mouse/keyboard interaction),
        # by default all windows are added to the same window group.
        # We want to avoid setting modallity on other windows
        # when running a dialog using gtk_dialog_run/run_dialog.
        window_group = gtk.WindowGroup()
        window_group.add_window(app_window.get_toplevel())

        if appname is not None:
            appdesc = self.get_app_by_name(appname)

        if not appdesc:
            return
        if (appdesc.name != 'launcher' and
            not self._user.profile.check_app_permission(appdesc.name)):
            error(_("This user lacks credentials \nfor application %s") %
                  appdesc.name)
            return

        self.run_embedded(appdesc, app_window)
开发者ID:romaia,项目名称:stoq,代码行数:31,代码来源:shell.py

示例5: _maybe_create_database

    def _maybe_create_database(self):
        logger.info('_maybe_create_database (db_is_local=%s, enable_production=%s)'
                    % (self.wizard.db_is_local, self.wizard.enable_production))
        if self.wizard.db_is_local:
            self._launch_stoqdbadmin()
            return
        elif self.wizard.enable_production:
            self._launch_stoqdbadmin()
            return

        self.wizard.write_pgpass()
        settings = self.wizard.settings
        self.wizard.config.load_settings(settings)

        store = settings.create_super_store()
        version = get_database_version(store)

        if version < (9, 1):
            store.close()
            error(_("Stoq requires PostgresSQL 9.1 or later, but %s found") % (
                ".".join(map(str, version))))

        try:
            check_extensions(store=store)
        except ValueError:
            store.close()
            error(_("Missing PostgreSQL extension on the server, "
                    "please install postgresql-contrib on it"))

        store.close()
        self.process_view.feed("** Creating database\r\n")
        self._launch_stoqdbadmin()
开发者ID:hackedbellini,项目名称:stoq,代码行数:32,代码来源:config.py

示例6: set_current_branch_station

def set_current_branch_station(store, station_name):
    """Registers the current station and the branch of the station
    as the current branch for the system
    :param store: a store
    :param station_name: name of the station to register
    """
    # This is called from stoq-daemon, which doesn't know about Branch yet
    from stoqlib.domain.person import Branch
    Branch  # pylint: disable=W0104

    if station_name is None:
        station_name = get_hostname()

    station_name = unicode(station_name)
    from stoqlib.domain.station import BranchStation
    station = store.find(BranchStation, name=station_name).one()
    if station is None:
        station = _register_branch(store, station_name)

    if not station.is_active:
        error(_("The computer <u>%s</u> is not active in Stoq") %
              station_name,
              _("To solve this, open the administrator application "
                "and re-activate this computer."))

    provide_utility(ICurrentBranchStation, station, replace=True)

    # The station may still not be associated with a branch when creating an
    # empty database
    if station.branch:
        provide_utility(ICurrentBranch, station.branch, replace=True)
开发者ID:igorferreira,项目名称:stoq,代码行数:31,代码来源:runtime.py

示例7: create_database_functions

def create_database_functions():
    """Create some functions we define on the database

    This will simply read data/sql/functions.sql and execute it
    """
    with tempfile.NamedTemporaryFile(suffix='stoqfunctions-') as tmp_f:
        functions = environ.get_resource_string('stoq', 'sql', 'functions.sql')
        tmp_f.write(render_template_string(functions))
        tmp_f.flush()
        if db_settings.execute_sql(tmp_f.name) != 0:
            error(u'Failed to create functions')
开发者ID:Guillon88,项目名称:stoq,代码行数:11,代码来源:admin.py

示例8: populate_initial_data

def populate_initial_data(store):
    from stoqlib.domain.system import SystemTable
    generation = store.find(SystemTable).max(SystemTable.generation)
    if generation < 4:
        # FIXME: Initial data can (and needs to) only be sourced on schemas
        #        greater or equal than 4. Remove this in the future.
        return

    log.info('Populating initial data')
    initial_data = environ.find_resource('sql', 'initial.sql')
    if db_settings.execute_sql(initial_data) != 0:
        error(u'Failed to populate initial data')
开发者ID:romaia,项目名称:stoq,代码行数:12,代码来源:admin.py

示例9: create_database_functions

def create_database_functions():
    """Create some functions we define on the database

    This will simply read data/sql/functions.sql and execute it
    """
    # We cant remove the file, otherwise it will fail on windows.
    with tempfile.NamedTemporaryFile(prefix='stoqfunctions-', delete=False) as tmp_f:
        functions = environ.get_resource_string('stoq', 'sql', 'functions.sql')
        tmp_f.write(render_template_string(functions))
        tmp_f.flush()
        if db_settings.execute_sql(tmp_f.name) != 0:
            error(u'Failed to create functions')
开发者ID:hackedbellini,项目名称:stoq,代码行数:12,代码来源:admin.py

示例10: _do_login

    def _do_login(self):
        from stoqlib.exceptions import LoginError
        from stoqlib.gui.login import LoginHelper
        from stoqlib.lib.message import error

        self._login = LoginHelper(username=self._options.login_username)
        try:
            if not self.login():
                return False
        except LoginError, e:
            error(str(e))
            return False
开发者ID:romaia,项目名称:stoq,代码行数:12,代码来源:shell.py

示例11: needs_schema_update

def needs_schema_update():
    try:
        migration = StoqlibSchemaMigration()
    except StoqlibError:
        error(_("Update Error"),
             _("You need to call setup() before checking the database "
               "schema."))

    try:
        update = not (migration.check_uptodate() and migration.check_plugins())
    except DatabaseInconsistency, e:
        error(str(e))
开发者ID:romaia,项目名称:stoq,代码行数:12,代码来源:migration.py

示例12: create_base_schema

def create_base_schema():
    log.info('Creating base schema')
    create_log.info("SCHEMA")

    create_database_functions()

    # A Base schema shared between all RDBMS implementations
    schema = _get_latest_schema()
    if db_settings.execute_sql(schema) != 0:
        error(u'Failed to create base schema')

    migration = StoqlibSchemaMigration()
    migration.apply_all_patches()
开发者ID:Guillon88,项目名称:stoq,代码行数:13,代码来源:admin.py

示例13: apply

    def apply(self, store):
        """Apply the patch
        :param store: a store
        """

        # Dont lock the database here, since StoqlibSchemaMigration.update has
        # already did that before starting to apply the patches

        # SQL statement to update the system_table
        sql = self._migration.generate_sql_for_patch(self)

        if self.filename.endswith('.sql'):
            # Create a temporary file used for writing SQL statements
            temporary = tempfile.mktemp(prefix="patch-%d-%d-" % self.get_version())

            # Overwrite the temporary file with the sql patch we want to apply
            shutil.copy(self.filename, temporary)

            # After successfully executing the SQL statements, we need to
            # make sure that the system_table is updated with the correct
            # schema generation and patchlevel
            open(temporary, 'a').write(sql)

            retcode = db_settings.execute_sql(temporary)
            if retcode != 0:
                error('Failed to apply %s, psql returned error code: %d' % (
                    os.path.basename(self.filename), retcode))

            os.unlink(temporary)
        elif self.filename.endswith('.py'):
            # Execute the patch, we cannot use __import__() since there are
            # hyphens in the filename and data/sql lacks an __init__.py
            ns = {}
            execfile(self.filename, ns, ns)
            function = ns['apply_patch']

            # Create a new store that will be used to apply the patch and
            # to update the system tables after the patch has been successfully
            # applied
            patch_store = new_store()

            # Apply the patch itself
            function(patch_store)

            # After applying the patch, update the system_table within the same
            # transaction
            patch_store.execute(sql)
            patch_store.commit(close=True)
        else:
            raise AssertionError("Unknown filename: %s" % (self.filename, ))
开发者ID:romaia,项目名称:stoq,代码行数:50,代码来源:migration.py

示例14: _check_schema_migration

    def _check_schema_migration(self):
        from stoqlib.lib.message import error
        from stoqlib.database.migration import needs_schema_update
        from stoqlib.exceptions import DatabaseInconsistency
        if needs_schema_update():
            self._run_update_wizard()

        from stoqlib.database.migration import StoqlibSchemaMigration
        migration = StoqlibSchemaMigration()
        try:
            migration.check()
        except DatabaseInconsistency as e:
            error(_('The database version differs from your installed '
                    'version.'), str(e))
开发者ID:hackedbellini,项目名称:stoq,代码行数:14,代码来源:shell.py

示例15: load_config_and_call_setup

 def load_config_and_call_setup(self):
     dbargs = self.settings.get_command_line_arguments()
     parser = get_option_parser()
     db_options, unused_args = parser.parse_args(dbargs)
     self.config.set_from_options(db_options)
     try:
         setup(self.config,
               options=self.options,
               check_schema=True,
               register_station=False,
               load_plugins=False)
     except DatabaseInconsistency as err:
         error(_('The database version differs from your installed '
                 'version.'), str(err))
开发者ID:leandrorchaves,项目名称:stoq,代码行数:14,代码来源:config.py


注:本文中的stoqlib.lib.message.error函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。