Author: duncan
Date: Sun Jul 22 07:19:57 2007
New Revision: 9758

Log:
When the total space is 0 becuase of an invalid path then this will crash
This fix sould stop this crash


Modified:
   branches/rel-1/freevo/src/plugins/df.py
   branches/rel-1/freevo/src/plugins/idlebar/diskfree.py

Modified: branches/rel-1/freevo/src/plugins/df.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/df.py     (original)
+++ branches/rel-1/freevo/src/plugins/df.py     Sun Jul 22 07:19:57 2007
@@ -62,7 +62,9 @@
             totalspacegb = totalspacemb / 1024
             percentage = freespace * 100.0 / totalspace
 
-            if (totalspace > 1073741824): # more than 1024 Mb
+            if (totalspace == 0): # no space perhaps a bad path
+                diskfree = _( 'Bad Path' )
+            elif (totalspace > 1073741824): # more than 1024 Mb
                 diskfree = _( '%i free of %i GB total (%i%% free)' ) % 
(freespacegb, totalspacegb, percentage)
             else:
                 diskfree = _( '%i free of %i MB total (%i%% free)' ) % 
(freespacemb, totalspacemb, percentage)

Modified: branches/rel-1/freevo/src/plugins/idlebar/diskfree.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/idlebar/diskfree.py       (original)
+++ branches/rel-1/freevo/src/plugins/idlebar/diskfree.py       Sun Jul 22 
07:19:57 2007
@@ -47,6 +47,12 @@
     This plugin displays the total amount of free disk space for recordings
     """
     def __init__(self):
+        if not config.TV_RECORD_DIR:
+            print 'TV_RECORD_DIR is not set'
+            return
+        if not os.path.isdir(config.TV_RECORD_DIR):
+            print 'TV_RECORD_DIR "%s" is not a directory' % 
(config.TV_RECORD_DIR)
+            return
         IdleBarPlugin.__init__(self)
         self.plugin_name = 'idlebar.diskfree'
         self.time = 0
@@ -62,6 +68,13 @@
         self.cacheimg = {}
 
 
+    def config(self):
+        return [
+            ('TV_RECORD_DIR', None, 'Directory for TV recordings'),
+            ('DISKFREE_LOW', 20, 'Amount of space in GB to show the low 
warning icon'),
+            ('DISKFREE_VERY_LOW', 8, 'Amount of space in GB to show the very 
low warning icon'),
+        ]
+
     def getimage(self, image, osd, cache=False):
         if image.find(config.ICON_DIR) == 0 and 
image.find(osd.settings.icon_dir) == -1:
             new_image = os.path.join(osd.settings.icon_dir, 
image[len(config.ICON_DIR)+1:])
@@ -80,13 +93,18 @@
         Update maximum every 30 seconds
 
         """
-        if (time.time()-self.time) > 30:
-            self.time = time.time()
-            freespace = util.freespace(config.TV_RECORD_DIR)
-            totalspace = util.totalspace(config.TV_RECORD_DIR)
-            self.diskfree = _('%iGB') % (((freespace / 1024) / 1024) / 1024)
-            self.freespace = (((freespace / 1024) / 1024) / 1024)
-            self.totalspace = (((totalspace / 1024) / 1024) / 1024)
+        if not os.path.isdir(config.TV_RECORD_DIR):
+            return
+
+        self.time = time.time()
+        freespace = util.freespace(config.TV_RECORD_DIR)
+        totalspace = util.totalspace(config.TV_RECORD_DIR)
+        self.diskfree = _('%iGB') % (((freespace / 1024) / 1024) / 1024)
+        self.freespace = (((freespace / 1024) / 1024) / 1024)
+        self.totalspace = (((totalspace / 1024) / 1024) / 1024)
+        if self.totalspace == 0:
+            self.percent = 0
+        else:
             self.percent = (self.totalspace - self.freespace) * 1.0 / 
self.totalspace
 
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to