Commits

Damián Nohales committed e7c4f4d

Better error handling when Grooveshark is not working.

  • Participants
  • Parent commits ba08577

Comments (0)

Files changed (4)

File lib/SharkDown.py

 
     def on_init_thread_failed(self, error):
         guihelpers.ErrorMessage(self.window,
-            _("GrooveShark service has probably changed!\ngSharkDown will not works propperly, so please\nbe patient until we find a solution.\n\nThe error was: %s")
+            _("GrooveShark service has probably changed or is not working!\ngSharkDown will not works propperly, so please\nbe patient until we find a solution.\n\nThe error was: %s\n\nThis is usually caused by a proxy misconfiguration\nplease check your proxy configuration.")
             % error
         )
 
                 self.downmenu.get_children()[0].set_sensitive(False)
                 self.downmenu.get_children()[1].set_sensitive(False)
                 for path in selected_rows:
-                    if self.downloads.get_song(path).get_state() == Song.STATE_PAUSED:
+                    if self.downloads.get_song(path).is_downloading() == False and self.downloads.get_song(path).get_state() != Song.STATE_NOT_STARTED:
                         self.downmenu.get_children()[1].set_sensitive(True)
                     else:
                         self.downmenu.get_children()[0].set_sensitive(True)
         """
         if self.is_downloading():
             self.download_thread.pause()
+        else:
+            self.state = Song.STATE_PAUSED
+            self.emit("download-paused")
         
     def cancel_download(self):
         """

File lib/groove.py

 import ipycurl
 import threading
 import time
+import gobject
 from enviroment import env
 
 if sys.version_info[1] >= 6:
 _isInitialized = False
 _initializingLock = threading.Lock()
 _onInitError = None
+_initFailed = False
 
 h = {}
 h["country"] = {}
 
 
 def init():
-    global _isInitialized
+    global _isInitialized, _initFailed
     
-    if isInitialized(): return
     _initializingLock.acquire()
     if isInitialized():
         _initializingLock.release()
+        if _initFailed == True:
+            raise Exception(_("Grooveshark is not initialized"))
         return
     
     print "[Initializing Grooveshark]"
             
             conn.close()
             getToken()
+            print "[Grooveshark initialized]"
             break
         except Exception as e:
             if e.args[0] == 11004:
                 time.sleep(1)
-            elif _onInitError != None:
-                _onInitError(e.__str__())
+            else:
+                print "[Grooveshark initialized failed]"
+                _initFailed = True
+                if _onInitError != None:
+                    gobject.idle_add(_onInitError, e.__str__())
+                break
     
-    print "[Grooveshark initialized]"
     _isInitialized = True
     _initializingLock.release()
     

File lib/tfuncs.py

         try:
             results = groove.getSearchResultsEx(self.query, self.type)
             gobject.idle_add(self.fill_results, results)
-        except Exception, e:
-            print e.args
+        except Exception as e:
+            gobject.idle_add(self.search_error, e.__str__())
 
     def fill_results(self, results):
         self.app.entry_search.set_sensitive(True)
                 "",
                 ""
             ])
+    def search_error(self, error):
+        self.app.entry_search.set_sensitive(True)
+        self.app.set_search_sensitivity(True)
+        guihelpers.ErrorMessage(self.app.window, _("An error occurred while search on Grooveshark.\n\nThe error was: %s") % error)
 
 
 class UpdateThread(threading.Thread):