示例#1
0
def launch_url (url, ext=""):
    if os.name == 'nt':
        os.startfile(url)
    elif os.name == 'posix':
        try:
            gtk.show_uri(gtk.gdk.Screen(),url,0L)
        except ImportError:
            print 'gtk libraries not available, trying builtins'
            if not ext: ext=os.path.splitext(url)
            for regexp,l in launchers:
                if regexp.match('\.?%s'%regexp, ext):
                    if is_on_system(app):
                        os.popen(app + " " + url)
                        return
            # if that fails...
            print 'builtins failing, using python webbrowser functions'
            try:
                import webbrowser
                webbrowser.open(url)
            except ImportError:
                dialog_extras.show_message("Unable to open",sublabel="Failed to launch URL: %s"%url)
        except gobject.GError, err:
            #print dir(err)
            label = _('Unable to open URL')
            for reg, msg in [('mailto:',_('Unable to launch mail reader.')),
                             ('http:',_('Unable to open website.')),
                             ('file:',_('Unable to open file.'))]:
                if re.match(reg,url.lower()): label = msg
            dialog_extras.show_message(
                label=label,
                sublabel=err.message,
                expander=[_('_Details'),
                          _("There was an error launching the url: %s"%url)]
                )
示例#2
0
def launch_url (url, ext=""):
    if os.name == 'nt':
        os.startfile(url)
    elif os.name == 'posix':
        try:
            gtk.show_uri(gtk.gdk.Screen(),url,0L)
        except ImportError:
            print 'gtk libraries not available, trying builtins'
            if not ext: ext=os.path.splitext(url)
            for regexp,l in launchers:
                if regexp.match('\.?%s'%regexp, ext):
                    if is_on_system(app):
                        os.popen(app + " " + url)
                        return
            # if that fails...
            print 'builtins failing, using python webbrowser functions'
            try:
                import webbrowser
                webbrowser.open(url)
            except ImportError:
                dialog_extras.show_message("Unable to open",sublabel="Failed to launch URL: %s"%url)
        except gobject.GError, err:
            #print dir(err)
            label = _('Unable to open URL')
            for reg, msg in [('mailto:',_('Unable to launch mail reader.')),
                             ('http:',_('Unable to open website.')),
                             ('file:',_('Unable to open file.'))]:
                if re.match(reg,url.lower()): label = msg
            dialog_extras.show_message(
                label=label,
                sublabel=err.message,
                expander=[_('_Details'),
                          _("There was an error launching the url: %s"%url)]
                )
示例#3
0
 def target_func (self):
     self.run_hooks(self.pre_hooks)
     try:
         debug('SuspendableThread Running %s'%self.c,3)
         self.c.run()
     except Terminated:
         from gtk_extras import dialog_extras
         dialog_extras.show_message(
                 label=_("%s stopped."%self.name.title()),
                 sublabel=_("%s was interrupted by user request."%self.name.title())
                 )
     except:            
         if self.display_errors:
             self._threads_enter()
             from gtk_extras import dialog_extras
             dialog_extras.show_traceback(
                 label=_("%s interrupted")%self.name.title(),
                 sublabel=_("There was an error during %s.")%self.name,
                 )
             self._threads_leave()
         self.run_hooks(self.post_hooks)
         raise
     else:
         self.completed = True
         self.run_hooks(self.post_hooks)
示例#4
0
def launch_url (url, ext=""):
    if os.name == 'nt':
        os.startfile(url)
    elif os.name == 'posix':
        try:
            gtk.show_uri(gtk.gdk.Screen(),url,0L)
        except gobject.GError, err:
            #print dir(err)
            label = _('Unable to open URL')
            for reg, msg in [('mailto:',_('Unable to launch mail reader.')),
                             ('http:',_('Unable to open website.')),
                             ('file:',_('Unable to open file.'))]:
                if re.match(reg,url.lower()): label = msg
            dialog_extras.show_message(
                label=label,
                sublabel=err.message,
                expander=[_('_Details'),
                          _("There was an error launching the url: %s"%url)]
                )
示例#5
0
def launch_url(url, ext=""):
    if os.name == 'nt':
        os.startfile(url)
    elif os.name == 'posix':
        try:
            gtk.show_uri(gtk.gdk.Screen(), url, 0L)
        except gobject.GError, err:
            #print dir(err)
            label = _('Unable to open URL')
            for reg, msg in [('mailto:', _('Unable to launch mail reader.')),
                             ('http:', _('Unable to open website.')),
                             ('file:', _('Unable to open file.'))]:
                if re.match(reg, url.lower()): label = msg
            dialog_extras.show_message(
                label=label,
                sublabel=err.message,
                expander=[
                    _('_Details'),
                    _("There was an error launching the url: %s" % url)
                ])
示例#6
0
                                row[0] = False
                    else:
                        raise Exception("Cancelled")
                else:
                    self.loader.deactivate_plugin_set(plugin_set)
        except:
            details = self.loader.errors.get(plugin_set, '')
            if 'ImportError' in details:
                modname = details.split()[-1]
                n = modname.lower()
                modpossibilities = '"python-%s" ' % n + _('or') + ' "%s"' % n
                details += '\n\nYou may need to install additional python packages for this module to work properly. If you have a package management system on your computer, use it to search for a package containing "%s", such as %s' % (
                    modname, modpossibilities)
            if state:
                de.show_message(
                    message_type=gtk.MESSAGE_ERROR,
                    label=_('An error occurred activating plugin.'),
                    sublabel=details)
            else:
                de.show_message(
                    message_type=gtk.MESSAGE_ERROR,
                    label=_('An error occurred deactivating plugin.'),
                    sublabel=details)

            raise

    def response_cb(self, window, response):
        if response == gtk.RESPONSE_CLOSE: self.window.hide()


def show_plugin_chooser():
    pc = PluginChooser()
示例#7
0
                        for row in ls:
                            if row[1] in dependers:
                                row[0] = False
                    else:
                        raise Exception("Cancelled")
                else:
                    self.loader.deactivate_plugin_set(plugin_set)
        except:
            details = self.loader.errors.get(plugin_set,'')
            if 'ImportError' in details:
                modname = details.split()[-1]; n = modname.lower()
                modpossibilities = '"python-%s" '%n+_('or')+' "%s"'%n
                details += '\n\nYou may need to install additional python packages for this module to work properly. If you have a package management system on your computer, use it to search for a package containing "%s", such as %s'%(modname,modpossibilities)
            if state:
                de.show_message(message_type=gtk.MESSAGE_ERROR,
                                label=_('An error occurred activating plugin.'),
                                sublabel=details)
            else:
                de.show_message(message_type=gtk.MESSAGE_ERROR,
                                label=_('An error occurred deactivating plugin.'),
                                sublabel=details
                                )
                
            raise

    def response_cb (self, window, response):
        if response==gtk.RESPONSE_CLOSE: self.window.hide()
            
def show_plugin_chooser ():
    pc = PluginChooser()
    pc.window.show()