View Single Post
Posts: 402 | Thanked: 229 times | Joined on Nov 2009 @ Missouri, USA
#25
Writing a patch right now. The problem is that the config file doesn't work. In theory, creating the file /home/user/MyDocs/.easyplayer/preferences should fix it.

Will post back with more permanent solution unless OP does.

Attached a patch that corrects the following:
  • the home directory is no longer hard coded: this means that easy player is no longer broken for anyone who has changed the default user name, or runs as another user (for whatever reason you might do that)
  • default config is now created if the config file doesn't exist (this was sort of already their, but I connected the broken dots)
patch (also attached):
Code:
--- EasyPlayer.py    2010-05-15 01:46:27.000000000 -0500
+++ EasyPlayer.py.new    2010-05-15 01:46:07.000000000 -0500
@@ -83,18 +83,24 @@
     # Where to look for audio files / books
     self.base_media_dir = "/home/user/MyDocs/"
 
-    self.prefs_file = "/home/user/MyDocs/.easyplayer/preferences"
-    self.pl_dirs_file = "/home/user/MyDocs/.easyplayer/playlistdirs"
-    self.pl_files_file = "/home/user/MyDocs/.easyplayer/playlistfiles"
+    home = os.environ["HOME"] # some people change their user name from "user"
+    self.prefs_file = os.path.join(home, ".easyplayer", "preferences")
+    self.pl_dirs_file = os.path.join(home, ".easyplayer", "playlistdirs")
+    self.pl_files_file = os.path.join(home, ".easyplayer", "playlistfiles")
 
     # Try to load the preferences
-    if os.path.isfile(self.prefs_file):
-      try:
-        fd = open(self.prefs_file)
-        self.prefs = pickle.load(fd) # overwrite default values
-        fd.close()
-      except:
-        if (dbg): print "Can't load preferences"
+    try:
+        # doing everything in one function call means we don't have to close
+        # the file
+        self.prefs = pickle.load(open(self.prefs_file))
+    except IOError:
+        self.init_prefs()
+        self.save_prefs()
+        try:
+            os.mkdir(os.path.join(home, ".easyplayer"))
+        except OSError:
+            pass
+
     self.act_file_id = self.prefs["lastfile"]    
 
     # Look, if the preferences are new enough
@@ -126,13 +132,11 @@
     # Try to load the playlist 
     try:
       if (dbg): print "Trying to load dirs..."
-      fd = open(self.pl_dirs_file)     # Load list containing directories
-      self.pl_dirs = pickle.load(fd)     # overwrite default values
-      fd.close()
+      # Load list containing directories
+      self.pl_dirs = pickle.load(open(self.pl_dirs_file))
       if (dbg): print "Trying to load files..."      
-      fd = open(self.pl_files_file)     # Load list containng filenames
-      self.pl_files = pickle.load(fd) # overwrite default values
-      fd.close()
+      # Load list containing filenames
+      self.pl_files = pickle.load(open(self.pl_files_file))
       self.max_files = len(self.pl_files)    
       if (dbg): print "(load) Max Files:",self.max_files        
     except:
Attached Files
File Type: gz prefs_fix.tar.gz (873 Bytes, 102 views)
__________________
aspidites | blog | aspidites@inbox.com

Last edited by aspidites; 2010-05-15 at 06:50.
 

The Following User Says Thank You to aspidites For This Useful Post: