+ def getSavedRadio(self):
+ path = os.path.join(self.confDir, 'radio', 'radio.dmp')
+ try:
+ f = open(path, 'rb')
+ radio = pickle.load(f)
+ f.close()
+ print radio
+ except:
+ radio = {}
+ radio['seedSongs'] = []
+ radio['seedArtists'] = []
+ radio['frowns'] = []
+ if self.saveRadio(radio) == False:
+ return None
+ return radio
+
+ def saveRadio(self, radio): #blaher
+ if radio == {}:
+ print 'Invalid radio'
+ return False
+ try:
+ dir = os.path.join(self.confDir, 'radio')
+ # Create the 'data' directory if it doesn't exist.
+ if not os.path.exists(dir):
+ os.mkdir(dir)
+ path = os.path.join(dir, 'radio.dmp')
+ f = open(path, 'wb')
+ pickle.dump(radio, f, protocol=pickle.HIGHEST_PROTOCOL)
+ f.close()
+ return True
+ except IOError, e:
+ print 'There was an error while saving the radio pickle (%s)' % e
+ return False
+ except:
+ print "An unknown error occurred during save radio: " + str(sys.exc_info()[0])
+ return False
+