Logo Search packages:      
Sourcecode: viridian version File versions  Download package

def AmpacheTools::AmpacheGUI::AmpacheGUI::login_and_get_artists (   self,
  data = None 
)

Initial Authentication.

Authenticate and populate the artists.

Definition at line 1893 of file AmpacheGUI.py.

                                                :
            """Authenticate and populate the artists."""
            self.stop_all_threads()
            self.__clear_all_list_stores()
            self.update_statusbar(_("Authenticating..."))
            # get the user inforamiton
            ampache  = self.ampache_conn.url
            username = self.ampache_conn.username
            password = self.ampache_conn.password
            print "--- Attempting to login to Ampache ---"
            print "Ampache  = %s" % ampache
            print "Username = %s" % username
            print "Password = " + len(password)*"*"
            # set the credentials and try to login
            self.__successfully_authed = None
            ################ Thread to authenticate (so the GUI doesn't lock) ############
            thread.start_new_thread(self.__authenticate, (None,))
            while self.__successfully_authed == None:
                  self.refresh_gui()
            self.go_to_ampache_menu_item.set_sensitive(True)
            ##############################################################################
            if self.__successfully_authed == True: # auth successful
                  self.update_statusbar("Authentication Successful.")
                  print "Authentication Successful!"
                  print "Authentication = %s" % self.ampache_conn.auth
                  print "Number of artists = %d" % self.ampache_conn.artists_num
                  
                  db_time      = int(self.db_session.variable_get('catalog_update', -1))
                  ampache_time = int(self.ampache_conn.get_last_update_time())
                  
                  if data == "changed":
                        db_time = ampache_time
                        self.db_session.variable_set('catalog_update', db_time)
                  
                  self.catalog_up_to_date = False
                  if db_time >= ampache_time and ampache_time != -1:
                        self.catalog_up_to_date = True
                  
                  if not self.catalog_up_to_date:
                        # not up to date
                        if data == "First" and self.automatically_update: # first time opening, update auto
                              dbfunctions.clear_cached_catalog(self.db_session)
                              self.db_session.variable_set('catalog_update', ampache_time)
                              self.catalog_up_to_date = True
                        elif data == True or data == "First": # open a popup
                              if self.create_catalog_updated_dialog(): # user pressed update
                                    dbfunctions.clear_cached_catalog(self.db_session)
                                    self.db_session.variable_set('catalog_update', ampache_time)
                                    self.catalog_up_to_date = True
                        elif data == None: # clear_cache_button pressed
                              self.db_session.variable_set('catalog_update', ampache_time)
                              self.catalog_up_to_date = True
                                    
                        #else: #do nothing, pull from cache
                                          
                  # load the artists window with, you guessed it, artists
                  self.update_statusbar(_("Pulling Artists..."))
                  self.check_and_populate_artists()
                  artists = dbfunctions.get_artist_dict(self.db_session)
                  model = self.artist_list_store
                  model.append([_("<b>All Artists (%d)</b>" % len(artists)), -1, ''])
                  for artist_id in artists:
                        artist_name = artists[artist_id]['name']
                        custom_name = artists[artist_id]['custom_name']
                        model.append([helperfunctions.convert_string_to_html(artist_name), artist_id, custom_name])
                  # now pull all the albums.. this should cut down on precache time
                  self.update_statusbar(_("Pulling Albums..."))
                  self.check_and_populate_albums()
                  self.albums = dbfunctions.get_album_dict(self.db_session)
                  self.update_statusbar(_("Ready."))
                  return True
            else: # auth failed
                  error = self.__successfully_authed
                  if error == None or error == False:
                        error = _("Unknown error, possibly an incorrect URL specified, or the server is not responding.")
                  self.update_statusbar(_("Authentication Failed."))
                  self.create_dialog_alert("error", _("Error Authenticating\n\n") + error, True)

                  return False
            
                        

Generated by  Doxygen 1.6.0   Back to index