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


Python Backend.handler_info方法代码示例

本文整理汇总了Python中backend.Backend.handler_info方法的典型用法代码示例。如果您正苦于以下问题:Python Backend.handler_info方法的具体用法?Python Backend.handler_info怎么用?Python Backend.handler_info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backend.Backend的用法示例。


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

示例1: AbstractUI

# 需要导入模块: from backend import Backend [as 别名]
# 或者: from backend.Backend import handler_info [as 别名]
class AbstractUI(dbus.service.Object):
    '''Abstract user interface.

    This encapsulates the entire program logic and all strings, but does not
    implement any concrete user interface.
    '''
    def __init__(self):
        '''Initialize system.
        
        This parses command line arguments, detects available hardware,
        and already installed drivers and handlers.
        '''
        gettext.install('jockey', unicode=True)

        (self.argv_options, self.argv_args) = self.parse_argv()
        fix_stdouterr()

        if not OSLib.inst:
            OSLib.inst = OSLib(client_only=not self.argv_options.no_dbus,
                    target_kernel=self.argv_options.kernel)

        if self.argv_options.check:
            time.sleep(self.argv_options.check)

        self.init_strings()

        self._dbus_iface = None
        self.dbus_server_main_loop = None
        self.have_ui = False
        self.search_only = False
        self.current_search = (None, None) # query, result

        # make Control-C work properly
        signal.signal(signal.SIGINT, signal.SIG_DFL)

    def backend(self):
        '''Return D-BUS backend client interface.

        This gets initialized lazily.

        Set self.search_only to True to suppress a full system hardware
        detection, especially if you use only search_driver() to
        find a remote driver for a selected, already detected device.
        '''
        if self._dbus_iface is None:
            try:
                if self.argv_options.no_dbus:
                    self._dbus_iface = Backend()
                else:
                    self._dbus_iface = Backend.create_dbus_client()
            except Exception as e:
                if hasattr(e, '_dbus_error_name') and e._dbus_error_name in (
                    'org.freedesktop.DBus.Error.FileNotFound',
                    'org.freedesktop.DBus.Error.NoServer'):
                    if self.have_ui:
                        self.error_message(self._('Cannot connect to D-BUS,'+\
                            ' please use the --no-dbus option as root to'+\
                            ' use jockey without it.'),
                            str(e))
                    else:
                        self.error_msg(str(e))
                    sys.exit(1)
                else:
                    raise
            self._check_repositories()
            self._call_progress_dialog(
                self._('Searching for available drivers...'),
                self.search_only and self._dbus_iface.db_init or self._dbus_iface.detect, 
                timeout=600)
        else:
            # handle backend timeouts
            try:
                self._dbus_iface.handler_info(' ')
            except Exception as e:
                if hasattr(e, '_dbus_error_name') and e._dbus_error_name == \
                    'org.freedesktop.DBus.Error.ServiceUnknown':
                    self._dbus_iface = Backend.create_dbus_client()
                    self._check_repositories()
                    self._call_progress_dialog(
                        self._('Searching for available drivers...'),
                        self.search_only and self._dbus_iface.db_init or self._dbus_iface.detect, 
                        timeout=600)

        return self._dbus_iface

    def _(self, str, convert_keybindings=False):
        '''Keyboard accelerator aware gettext() wrapper.
        
        This optionally converts keyboard accelerators to the appropriate
        format for the frontend.

        All strings in the source code should use the '_' prefix for key
        accelerators (like in GTK). For inserting a real '_', use '__'.
        '''
        result = _(str)

        if convert_keybindings:
            result = self.convert_keybindings(result)

        return result
#.........这里部分代码省略.........
开发者ID:Fabioamd87,项目名称:nfs-manager,代码行数:103,代码来源:ui.py


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