Ejemplo n.º 1
0
class GulpPluginsCommand(BaseCommand):
    def work(self):
        self.plugins = None
        self.request_plugin_list()

    def request_plugin_list(self):
        progress = ProgressNotifier("%s: Working" % Settings.PACKAGE_NAME)
        thread = PluginRegistryCall()
        thread.start()
        self.handle_thread(thread, progress)

    def handle_thread(self, thread, progress):
        if thread.is_alive() and not thread.error:
            set_timeout(lambda: self.handle_thread(thread, progress), 100)
        else:
            progress.stop()
            if thread.result:
                plugin_response = json.loads(thread.result.decode('utf-8'))
                self.plugins = PluginList(plugin_response)
                self.show_quick_panel(self.plugins.quick_panel_list(), self.open_in_browser, font=0)
            else:
                self.error_message(self.error_text_for(thread))

    def error_text_for(self, thread):
        error_tuple = (
            "The plugin repository seems to be down.",
            "If http://gulpjs.com/plugins is working, please report this issue at the Sublime Gulp repo (https://github.com/NicoSantangelo/sublime-gulp).",
            "Thanks!",
            thread.error
        )
        return "\n\n%s\n\n%s\n\n%s\n\n%s" % error_tuple

    def open_in_browser(self, index=-1):
        if index >= 0 and index < self.plugins.length:
            webbrowser.open_new(self.plugins.get(index).get('homepage'))
Ejemplo n.º 2
0
class GulpPluginsCommand(BaseCommand):
    def work(self):
        self.plugins = None
        self.request_plugin_list()

    def request_plugin_list(self):
        progress = ProgressNotifier("Gulp: Working")
        thread = PluginRegistryCall()
        thread.start()
        self.handle_thread(thread, progress)

    def handle_thread(self, thread, progress):
        if thread.is_alive() and not thread.error:
            sublime.set_timeout(lambda: self.handle_thread(thread, progress), 100)
        else:
            progress.stop()
            if thread.result:
                plugin_response = json.loads(thread.result.decode('utf-8'))
                self.plugins = PluginList(plugin_response)
                self.show_quick_panel(self.plugins.quick_panel_list(), self.open_in_browser, font = 0)
            else:
                self.error_message(self.error_text_for(thread))

    def error_text_for(self, thread):
        error_tuple = (
            "The plugin repository seems to be down.",
            "If http://gulpjs.com/plugins is working, please report this issue at the Sublime Gulp repo (https://github.com/NicoSantangelo/sublime-gulp).",
            "Thanks!",
            thread.error
        )
        return "\n\n%s\n\n%s\n\n%s\n\n%s" % error_tuple

    def open_in_browser(self, index=-1):
        if index >= 0 and index < self.plugins.length:
            webbrowser.open_new(self.plugins.get(index).get('homepage'))
Ejemplo n.º 3
0
 def handle_thread(self, thread, progress):
     if thread.is_alive() and not thread.error:
         sublime.set_timeout(lambda: self.handle_thread(thread, progress), 100)
     else:
         progress.stop()
         if thread.result:
             plugin_response = json.loads(thread.result.decode('utf-8'))
             self.plugins = PluginList(plugin_response)
             self.show_quick_panel(self.plugins.quick_panel_list(), self.open_in_browser, font = 0)
         else:
             self.error_message(self.error_text_for(thread))
Ejemplo n.º 4
0
 def handle_thread(self, thread, progress):
     if thread.is_alive() and not thread.error:
         set_timeout(lambda: self.handle_thread(thread, progress), 100)
     else:
         progress.stop()
         if thread.result:
             plugin_response = json.loads(thread.result.decode('utf-8'))
             self.plugins = PluginList(plugin_response)
             self.show_quick_panel(self.plugins.quick_panel_list(), self.open_in_browser, font=0)
         else:
             self.error_message(self.error_text_for(thread))