Commits

A2K committed 8fc8cf2

Console output cleanup

Comments (0)

Files changed (9)

         #if XLIB_SHORTCUTS:
         self.register_xshortcuts()
 
-        print self.pages
         self.update_tabwidget()
 
         settings.beginGroup("MainWindow")
             self.open_dialog = QtGui.QFileDialog()
             self.open_dialog.setNameFilter(self.tr("Audio files (*.flac *.mp3 *.ogg *.wav *.wma)"))
         files = self.open_dialog.getOpenFileNames(self, self.tr("Open files"))
-        for n in [unicode(name) for name in files]:
-            print n
         tracks = read_files([unicode(name) for name in files])
-        print tracks
         if tracks:
             self.emit(QtCore.SIGNAL('add_tracks'), tracks)
 
             data = copy_treeview_selected(self.searchwidget.ui.search_view)
         else:
             data = copy_current_playing()
-        print data
         clip = QtGui.QApplication.clipboard()
         clip.setText(data)
 
         post = urllib.urlencode(data)
         xml = urllib2.urlopen(url, post).read()
 
-        print xml
 
     def get_token(self):
         data = {}
         data['api_key'] = self.api_key
         data['token'] = self.token
         txt = 'api_key'+self.api_key+'methodauth.getSession'+'token'+self.token
-        print txt
         sig = md5(txt).hexdigest()
         data['api_sig'] = sig
         post = urllib.urlencode(data)
-        print post
         xml = urllib2.urlopen(url, post).read()
-        print xml
 
     def create_session(self, login = None):
         if login is None:
         data['a'] = token
         url = baseurl + urllib.urlencode(data)
         auth = urllib2.urlopen(url).read().split()
-        #print auth
-        print auth
         if auth[0] == 'OK':
             self.session = auth[1]
             self.npurl = auth[2]
     def run(self):
         self.artists = artists = self.similiar_artists(self.artist)
 
-        print 'Lastfm.py: Emiting signal "results" with %d artists' % (len(artists),)
+        log.debug('Lastfm.py: Emiting signal "results" with %d artists' % len(artists))
         self.emit(QtCore.SIGNAL('results'), artists)
         #print artists
 
     if settings.value('caching/use').toBool():
         cdir = settings.value('caching/directory').toString()
         if not os.path.exists(cdir):
-            print cdir
+            log.info('Caching directory %s does not exist' % cdir)
             try:
                 os.mkdir(cdir)
             except:
                 if not fname.endswith(".py"):
                     continue
                 module_name = fname[: -3]
-                print module_name
+                log.debug('Loading plugin %s' % module_name)
                 if module_name == "__init__" or module_name == 'base_plugin':
                     continue
                 obj = __import__(module_name)
                             self.add_plugin(objm)
 
     def add_plugin(self, plugin):
-        print 'called'
         col = len(self.plugins)
         layout = self.ui.gridLayout
         info = plugin.plugin_info
 
 def get_playlist(title):
     plid = get_playlist_id(title)
-    if not plid:
+    if plid is None:
         return []
     query = QtSql.QSqlQuery("""SELECT artist, title, url, length
                                FROM playlists_tracks

searchprocessor.py

     #def __init__(self, login):
         #QtCore.QThread.__init__(self)
         #self.login = login
-        
+
     def search_results_handler(self, results):
         if results[0] == 0:
             self.emit(QtCore.SIGNAL("results"), results[1])
         sleep(0.01)
         for thread in self.threads:
             if thread.isRunning():
-                print thread, 'is still running, not sending progress 100'
+                log.debug('%s is still running, not sending progress 100' % str(thread))
                 all_done = False
                 break
         if all_done and not self.notfound:
             self.emit( QtCore.SIGNAL("progress"), -1)
             self._kill_all_threads()
         elif message == 'notfound':
-            print 'SearchProcessor.py: Got nothing found from search engine'
+            log.debug('Got nothing found from search engine')
             self.notfound = True
             self.emit( QtCore.SIGNAL("progress"), -2)
             self._kill_all_threads()
             self.emit( QtCore.SIGNAL("progress"), -4)
             self._kill_all_threads()
         else:
-            print 'SearchProcessor.py: Unhandled search engine status message:', message
-    
+            log.debug('Unhandled search engine status message: %s' % message)
+
     def _kill_all_threads(self):
         for thread in self.threads:
             #print help(thread.disconnect)
         self.emit( QtCore.SIGNAL("progress"), 0)
         self.notfound = False
         self._kill_all_threads()
-        
+
         self.request = request
         self.count = 0
         searcher = Search(request, 0)
         QtCore.QObject.connect(searcher, QtCore.SIGNAL('status'),
                                self.search_status_handler)
         searcher.start()
-        
+
     def search_more(self):
         self.emit( QtCore.SIGNAL("progress"), 0)
         self.count += 1

similarartistspopulator.py

             QtCore.QObject.connect(client, QtCore.SIGNAL('results'), self._tracks_receiver)
             QtCore.QObject.connect(client, QtCore.SIGNAL('status'), self._status_receiver)
             client.start()
-            print 'waiting a half of second...'
+            log.debug('Waiting a half of second...')
             time.sleep(0.5)
 
         while threads_alive(threads):
         self.emit(QtCore.SIGNAL('status'), 'done')
 
     def _status_receiver(self, status):
-        print status
         if status == 'error':
             self.error = True
             self.emit(QtCore.SIGNAL('status'), 'error')
         if status == 'wronglogin':
             self.error = True
             self.emit(QtCore.SIGNAL('status'), 'wronglogin')
-            print 'wronglogin'
+            log.error('Wrong login')
 
     def _artists_receiver(self, results):#results):
-        print 'Populator.py: Artists received'
+        log.info('Artists received')
         self.artists += results[:10]
         self.progress += 10/self.request_artist_count
         self.emit(QtCore.SIGNAL('status'), self.progress)
 
     def _tracks_receiver(self, tracks):
         if not tracks:
-            print 'populator.py: Could not find tracks for some artist'
-        print 'Populator.py: Tracks received'
+            log.info('Could not find tracks for some artist')
+            return
+        log.info('Tracks received')
         self.progress += 9
         self.emit(QtCore.SIGNAL('status'), self.progress)
         tracks = tracks[1]

similartrackspopulator.py

         if status == 'wronglogin':
             self.error = True
             self.emit(QtCore.SIGNAL('status'), 'wronglogin')
-            print 'wronglogin'
+            log.error('Wrong login')
 
     def _track_names_receiver(self, results):#results):
         log.debug('Similar track names received')
     def _tracks_receiver(self, tracks):
         log.debug('Similar tracks received')
         if not tracks:
-            print 'populator.py: Could not find tracks for some artist'
+            log.debug('Could not find tracks for some artist')
             return
-        print 'Populator.py: Tracks received'
+        log.info('Tracks received')
         while self.lock:
             time.sleep(0.01)
         self.lock = True
     def updated(self):
         if self.parent and self.index:
             self.parent.item_updated(self.index[0], self.index[1])
-        else:
-            print self.parent, self.index
 
     def free(self):
         self.resolver.remove(self)