Python gi.repository.GLib 模块,GError() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用gi.repository.GLib.GError()

项目:pytimetrack    作者:fhackerz    | 项目源码 | 文件源码
def tasks_downloaded(self, source, result, cache_filename):
        try:
            success, content, etag = source.load_contents_finish(result)
        except GLib.GError as e:
            url = self._download[2]
            log.error("Failed to download tasks from %s: %s", url, e)
            self.tasks_infobar.set_message_type(Gtk.MessageType.ERROR)
            self.tasks_infobar_label.set_text(_("Download failed."))
            self.tasks_infobar.show()
        else:
            log.debug("Successfully downloaded tasks (etag: %s):\n  %s",
                      etag, content.decode('UTF-8', 'replace').replace('\n', '\n  '))
            with open(cache_filename, 'wb') as f:
                f.write(content)
            self.check_reload_tasks()
            self.tasks_infobar.hide()
        self._download = None
项目:paperwork-backend    作者:openpaperwork    | 项目源码 | 文件源码
def can_import(self, file_uris, current_doc=None):
        """
        Check that the specified file looks like a directory containing many
        pdf files
        """
        if len(file_uris) <= 0:
            return False
        try:
            for file_uri in file_uris:
                file_uri = self.fs.safe(file_uri)
                parent = Gio.File.parse_name(file_uri)
                for child in recurse(parent):
                    if self.check_file_type(child.get_uri()):
                        return True
        except GLib.GError:
            pass
        return False
项目:paperwork-backend    作者:openpaperwork    | 项目源码 | 文件源码
def can_import(self, file_uris, current_doc=None):
        """
        Check that the specified file looks like a directory containing many
        pdf files
        """
        if len(file_uris) <= 0:
            return False
        try:
            for file_uri in file_uris:
                file_uri = self.fs.safe(file_uri)
                parent = Gio.File.parse_name(file_uri)
                for child in recurse(parent):
                    if self.check_file_type(child.get_uri()):
                        return True
        except GLib.GError:
            pass
        return False
项目:dogtail    作者:vhumpa    | 项目源码 | 文件源码
def _genCompareFunc(self):
        def satisfiedByNode(node):
            try:
                return node.roleName == 'application' and stringMatches(self.appName, node.name)
            except GLib.GError as e:
                if re.match(r"name :[0-9]+\.[0-9]+ was not provided", e.message):
                    logger.log("Dogtail: warning: omiting possibly broken at-spi application record")
                    return False
                else:
                    try:
                        sleep(config.defaults['searchWarningThreshold'])
                        return node.roleName == 'application' and stringMatches(self.appName, node.name)
                    except GLib.GError:
                        logger.log("Dogtail: warning: application may be hanging")
                        return False
        return satisfiedByNode
项目:eos-data-distribution    作者:endlessm    | 项目源码 | 文件源码
def return_error(self, name, error):
        skeleton, invocation, fd_list = self._obj_registery[name.toString()]
        logger.debug('returning ERROR %s for %s on %s', error, name, invocation)
        invocation.return_gerror(GLib.GError(error))
项目:ibus-typing-booster    作者:mike-fabian    | 项目源码 | 文件源码
def __init__(self,pkg):
        bus_type = Gio.BusType.SESSION
        flags = 0
        iface_info = None
        # Creating proxies does not do any blocking I/O, and never fails
        proxy = Gio.DBusProxy.new_for_bus_sync(
            bus_type,
            flags,
            iface_info,
            'org.freedesktop.PackageKit',
            '/org/freedesktop/PackageKit',
            'org.freedesktop.PackageKit.Modify',
            None)
        try:
            # The default timeout is approximately 25 seconds.
            # This is too short here, the call to InstallPackageNames
            # would usually return too early then before the package
            # has completed installing. Then the callback to reload
            # the dictionary would be called to early and would not
            # be able to load the dictionary.
            # So I use a very long timeout here to make sure
            # InstallPackageNames does not return before either the
            # dictionary is really installed or the user cancels:
            proxy.set_default_timeout(0x7fffffff) # timeout in milliseconds
            proxy.InstallPackageNames("(uass)", 0, [pkg], "show-confirm-search,hide-finished")
        except GLib.GError as e:
            print("GError: " + str(e))