Author: dmeyer
Date: Thu Oct 27 17:43:25 2005
New Revision: 7767

Modified:
   trunk/ui/src/audio/audiodiskitem.py
   trunk/ui/src/audio/plugins/coversearch.py
   trunk/ui/src/helpers/cache.py
   trunk/ui/src/mediadb/db.py
   trunk/ui/src/mediadb/generic.py
   trunk/ui/src/plugins/rom_drives.py
   trunk/ui/src/sysconfig.py
   trunk/ui/src/util/fxdimdb.py
   trunk/ui/src/util/vfs.py
   trunk/ui/src/video/database.py

Log:
clean up VFS_DIR usage

Modified: trunk/ui/src/audio/audiodiskitem.py
==============================================================================
--- trunk/ui/src/audio/audiodiskitem.py (original)
+++ trunk/ui/src/audio/audiodiskitem.py Thu Oct 27 17:43:25 2005
@@ -65,7 +65,7 @@
         # variables only for DirItem
         self.display_type = 'audio'
 
-        cover = '%s/disc/metadata/%s.jpg' % (sysconfig.VFS_DIR, self.disc_id)
+        cover = '%s/disc/metadata/%s.jpg' % (vfs.BASE, self.disc_id)
         if os.path.isfile(cover):
             self.image = cover
             

Modified: trunk/ui/src/audio/plugins/coversearch.py
==============================================================================
--- trunk/ui/src/audio/plugins/coversearch.py   (original)
+++ trunk/ui/src/audio/plugins/coversearch.py   Thu Oct 27 17:43:25 2005
@@ -258,8 +258,7 @@
         create cover file for the item
         """
         if item.type == 'audiocd':
-            filename = '%s/disc/metadata/%s.jpg' % (sysconfig.VFS_DIR,
-                                                    item.info['id'])
+            filename = '%s/disc/metadata/%s.jpg' % (vfs.BASE, item.info['id'])
         elif item.type == 'dir':
             filename = os.path.join(item.dir, 'cover.jpg')
         else:

Modified: trunk/ui/src/helpers/cache.py
==============================================================================
--- trunk/ui/src/helpers/cache.py       (original)
+++ trunk/ui/src/helpers/cache.py       Thu Oct 27 17:43:25 2005
@@ -45,6 +45,7 @@
 import mediadb
 import util.thumbnail as thumbnail
 import util.fileops as fileops
+import util.vfs as vfs
 
 # use this number to keep track of changes in this helper
 VERSION = 4
@@ -122,22 +123,20 @@
                  'disc'):
         if os.path.exists(os.path.join(config.FREEVO_CACHEDIR, name)):
             del_list.append(os.path.join(config.FREEVO_CACHEDIR, name))
-    del_list += util.match_files(sysconfig.VFS_DIR+'/disc',
-                                 ['mmpython', 'freevo'])
+    del_list += util.match_files(vfs.BASE+'/disc', ['mmpython', 'freevo'])
 
-    for file in util.match_files_recursively(sysconfig.VFS_DIR, ['raw']):
+    for file in util.match_files_recursively(vfs.BASE, ['raw']):
         if not file.endswith('.fxd.raw'):
             del_list.append(file)
 
-    for file in util.match_files_recursively(sysconfig.VFS_DIR,
-                                             config.IMAGE_SUFFIX):
+    for file in util.match_files_recursively(vfs.BASE, config.IMAGE_SUFFIX):
         if file.find('.thumb.') > 0:
             del_list.append(file)
 
     for db in ('freevo.cache', 'freevo.db', 'mmpython.cache', '*.raw.tmp',
                '*.raw-[0-9][0-9][0-9]x[0-9][0-9][0-9]', '*.fvt.png',
                'mmpython'):
-        del_list += util.recursefolders(sysconfig.VFS_DIR,1,db,1)
+        del_list += util.recursefolders(vfs.BASE,1,db,1)
     
     for f in del_list:
         if os.path.isdir(f):
@@ -154,20 +153,20 @@
     print 'deleting old cachefiles...............................',
     sys.__stdout__.flush()
     num = 0
-    for file in util.match_files_recursively(sysconfig.VFS_DIR, ['raw']):
-        if file.startswith(sysconfig.VFS_DIR + '/disc/'):
+    for file in util.match_files_recursively(vfs.BASE, ['raw']):
+        if file.startswith(vfs.BASE + '/disc/'):
             continue
-        if not vfs.isfile(file[len(sysconfig.VFS_DIR):-4]):
+        if not vfs.isfile(file[len(vfs.BASE):-4]):
             os.unlink(file)
             num += 1
     print 'deleted %s file(s)' % num
 
     print 'deleting cache for directories not existing anymore...',
-    subdirs = util.get_subdirs_recursively(sysconfig.VFS_DIR)
+    subdirs = util.get_subdirs_recursively(vfs.BASE)
     subdirs.reverse()
     for file in subdirs:
-        if not os.path.isdir(file[len(sysconfig.VFS_DIR):]) and not \
-               file.startswith(sysconfig.VFS_DIR + '/disc'):
+        if not os.path.isdir(file[len(vfs.BASE):]) and not \
+               file.startswith(vfs.BASE + '/disc'):
             for metafile in ('cover.png', 'cover.jpg'):
                 if os.path.isfile(os.path.join(file, metafile)):
                     os.unlink(os.path.join(file, metafile))
@@ -230,10 +229,10 @@
     print 'This will create thumbnails of your _video_ files'
     print
     print 'WARNING:'
-    print 'Caching needs a lot free space in sysconfig.VFS_DIR. The space is'
+    print 'Caching needs a lot free space in vfs.BASE. The space is'
     print 'also needed when Freevo generates the files during runtime. Image'
     print 'caching is the worst. So make sure you have several hundred MB'
-    print 'free! The vfs is set to %s' % sysconfig.VFS_DIR
+    print 'free! The vfs is set to %s' % vfs.BASE
     print
     print 'It may be possible to turn off image caching in future versions'
     print 'of Freevo (but this will slow things down).'

Modified: trunk/ui/src/mediadb/db.py
==============================================================================
--- trunk/ui/src/mediadb/db.py  (original)
+++ trunk/ui/src/mediadb/db.py  Thu Oct 27 17:43:25 2005
@@ -60,7 +60,7 @@
 VERSION = 0.1
 
 # cache dir for metadata
-CACHE_DIR = sysconfig.VFS_DIR + '/metadata'
+CACHE_DIR = vfs.BASE + '/metadata'
 
 if not os.path.isdir(CACHE_DIR):
     os.makedirs(CACHE_DIR)
@@ -121,7 +121,7 @@
                 self.cachefile = mp.mediadb + '/' + digest + '.db'
                 break
         else:
-            self.overlay_dir = sysconfig.VFS_DIR + dirname
+            self.overlay_dir = vfs.BASE + dirname
             digest = md5.md5(dirname).hexdigest()
             self.cachefile = CACHE_DIR + '/' + digest + '.db'
 

Modified: trunk/ui/src/mediadb/generic.py
==============================================================================
--- trunk/ui/src/mediadb/generic.py     (original)
+++ trunk/ui/src/mediadb/generic.py     Thu Oct 27 17:43:25 2005
@@ -42,6 +42,7 @@
 
 # freevo imports
 import sysconfig
+import util.vfs as vfs
 
 # mediadb imports
 from db import FileCache
@@ -77,7 +78,7 @@
     if not id:
         # bad disc, e.g. blank disc
         return DiscInfo(False, media)
-    cachefile = os.path.join(sysconfig.VFS_DIR, 'disc/metadata/%s.db' % id)
+    cachefile = os.path.join(vfs.BASE, 'disc/metadata/%s.db' % id)
     cache = FileCache(media.devicename, cachefile)
     info = DiscInfo(True, media, cache)
 

Modified: trunk/ui/src/plugins/rom_drives.py
==============================================================================
--- trunk/ui/src/plugins/rom_drives.py  (original)
+++ trunk/ui/src/plugins/rom_drives.py  Thu Oct 27 17:43:25 2005
@@ -63,6 +63,7 @@
 import application
 import plugin
 import util
+import util.vfs as vfs
 from util.ioctl import ioctl
 import mediadb
 
@@ -498,7 +499,7 @@
                 self.item = copy.copy(movie_info)
             else:
                 self.item = VideoItem('', None)
-                f = os.path.join(sysconfig.VFS_DIR, 'disc-set', self.id)
+                f = os.path.join(vfs.BASE, 'disc-set', self.id)
                 self.item.image = util.getimage(f)
             variables = self.item.info.get_variables()
             self.item.name  = title

Modified: trunk/ui/src/sysconfig.py
==============================================================================
--- trunk/ui/src/sysconfig.py   (original)
+++ trunk/ui/src/sysconfig.py   Thu Oct 27 17:43:25 2005
@@ -84,35 +84,8 @@
         break
 
 
-# create the vfs
-if not CONF.vfs_dir or CONF.vfs_dir == '/':
-    print
-    print 'ERROR: bad vfs dir.'
-    print 'Set vfs dir it to a directory on the local filesystem.'
-    print 'Make sure this partition has about 100 MB free space'
-    sys.exit(0)
-
-# Make sure CONF.vfs_dir doesn't ends with a slash
-# With that, we don't need to use os.path.join, normal string
-# concat is much faster
-if CONF.vfs_dir.endswith('/'):
-    CONF.vfs_dir = CONF.vfs_dir[:-1]
-
-if not os.path.isdir(CONF.vfs_dir):
-    os.makedirs(CONF.vfs_dir)
-
-if not os.path.isdir(CONF.vfs_dir + '/disc'):
-    os.makedirs(CONF.vfs_dir + '/disc')
-
-if not os.path.isdir(CONF.vfs_dir + '/disc/metadata'):
-    os.makedirs(CONF.vfs_dir + '/disc/metadata')
-
-if not os.path.isdir(CONF.vfs_dir + '/disc-set'):
-    os.makedirs(CONF.vfs_dir + '/disc-set')
-
-
 # add everything in CONF to the module variable list (but in upper
-# case, so CONF.vfs_dir is VFS_DIR, too
+# case, so CONF.xxx is XXX, too
 for key in CONF.__dict__:
     exec('%s = CONF.%s' % (key.upper(), key))
 

Modified: trunk/ui/src/util/fxdimdb.py
==============================================================================
--- trunk/ui/src/util/fxdimdb.py        (original)
+++ trunk/ui/src/util/fxdimdb.py        Thu Oct 27 17:43:25 2005
@@ -286,7 +286,7 @@
         
         else:
             if self.isdiscset == True:
-                self.fxdfile = os.path.join(sysconfig.VFS_DIR, 'disc-set',
+                self.fxdfile = os.path.join(vfs.BASE, 'disc-set',
                                             self.getmedia_id(self.device))
             else:
                 self.fxdfile = os.path.splitext(file)[0]

Modified: trunk/ui/src/util/vfs.py
==============================================================================
--- trunk/ui/src/util/vfs.py    (original)
+++ trunk/ui/src/util/vfs.py    Thu Oct 27 17:43:25 2005
@@ -46,7 +46,7 @@
 log = logging.getLogger('vfs')
 
 # vfs directory on disc
-_VFS_DIR = sysconfig.VFS_DIR
+BASE = sysconfig.VFS_DIR
 
 # list of mount points
 mountpoints = []
@@ -72,8 +72,8 @@
         id changes (e.g. rom drives)
         """
         self.id = id
-        self.cache = os.path.join(_VFS_DIR, 'disc/metadata/%s.db' % id)
-        vfs = os.path.join(_VFS_DIR, 'disc', id)
+        self.cache = os.path.join(BASE, 'disc/metadata/%s.db' % id)
+        vfs = os.path.join(BASE, 'disc', id)
         self.mediadb = os.path.join(vfs, '.metadata')
         self.thumbnails = os.path.join(vfs, '.thumbnails')
         
@@ -83,14 +83,14 @@
         Get overlay for filename.
         """
         filename = filename[len(self.mountdir):]
-        return '%s/disc/%s%s' % (_VFS_DIR, self.id, filename)
+        return '%s/disc/%s%s' % (BASE, self.id, filename)
 
 
     def get_root(self):
         """
         Get root dir for the vfs.
         """
-        return '%s/disc/%s' % (_VFS_DIR, self.id)
+        return '%s/disc/%s' % (BASE, self.id)
 
 
     def get_relative_path(self, filename):
@@ -146,18 +146,18 @@
 def getoverlay(directory):
     if not directory.startswith('/'):
         directory = os.path.abspath(directory)
-    if directory.startswith(_VFS_DIR):
+    if directory.startswith(BASE):
         return directory
     for media in mountpoints:
         if directory.startswith(media.mountdir):
             directory = directory[len(media.mountdir):]
-            return '%s/disc/%s%s' % (_VFS_DIR, media.id, directory)
-    return _VFS_DIR + directory
+            return '%s/disc/%s%s' % (BASE, media.id, directory)
+    return BASE + directory
 
 
 def abspath(name):
     """
-    return the complete filename (including VFS_DIR)
+    return the complete filename (including vfs.BASE)
     """
     if os.path.exists(name):
         if not name.startswith('/'):
@@ -225,3 +225,33 @@
         except IOError, e:
             log.error('vfs.codecs_open: error opening file %s' % overlay)
             raise IOError, e
+
+
+# Init VFS
+
+# Make sure BASE doesn't ends with a slash
+# With that, we don't need to use os.path.join, normal string
+# concat is much faster
+if BASE.endswith('/'):
+    BASE = BASE[:-1]
+
+# Check if BASE is valid
+if BASE == '/':
+    print
+    print 'ERROR: bad VFS dir.'
+    print 'Set vfs dir it to a directory on the local filesystem.'
+    print 'Make sure this partition has about 100 MB free space'
+    sys.exit(0)
+
+# create VFS dirs
+if not os.path.isdir(BASE):
+    os.makedirs(BASE)
+
+if not os.path.isdir(BASE + '/disc'):
+    os.makedirs(BASE + '/disc')
+
+if not os.path.isdir(BASE + '/disc/metadata'):
+    os.makedirs(BASE + '/disc/metadata')
+
+if not os.path.isdir(BASE + '/disc-set'):
+    os.makedirs(BASE + '/disc-set')

Modified: trunk/ui/src/video/database.py
==============================================================================
--- trunk/ui/src/video/database.py      (original)
+++ trunk/ui/src/video/database.py      Thu Oct 27 17:43:25 2005
@@ -90,7 +90,7 @@
 
     files = []
 
-    discset = sysconfig.VFS_DIR + '/disc-set'
+    discset = vfs.BASE + '/disc-set'
     if os.path.isdir(discset):
         listing = Listing(discset)
         if listing.num_changes:


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to