[yum-cvs] 2 commits - docs/yum.conf.5 yum/config.py

James Antill james at linux.duke.edu
Mon Dec 10 22:42:01 UTC 2007


 docs/yum.conf.5 |    4 +++-
 yum/config.py   |   47 ++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 4 deletions(-)

New commits:
commit dfe1d7b0037eb3e334570ba35e22667696bf547a
Author: James Antill <james at and.org>
Date:   Mon Dec 10 17:40:47 2007 -0500

    Change default metadata_expire to 1.5h, for better UI with yum-updatesd running

diff --git a/yum/config.py b/yum/config.py
index c128a92..1d1a493 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -583,13 +583,16 @@ class YumConf(StartupConf):
     enable_group_conditionals = BoolOption(True)
     group_package_types = ListOption(['mandatory', 'default'])
     
-    timeout = FloatOption(30.0)
+    timeout = FloatOption(30.0) # FIXME: Should use variation of SecondsOption
 
     bandwidth = BytesOption(0)
     throttle = ThrottleOption(0)
 
     http_caching = SelectionOption('all', ('none', 'packages', 'all'))
-    metadata_expire = SecondsOption(1800)   # time in seconds
+    #  Time in seconds (1.5h), yum-updatesd runs once per. hour by default
+    # this time means we don't do interactive network checks/updates if
+    # yum-updatesd is running.
+    metadata_expire = SecondsOption(60 * 90)
     mirrorlist_expire = SecondsOption(86400) # time in seconds (1 day)
     rpm_check_debug = BoolOption(True)
     disable_excludes = ListOption()    
commit dc237061729b85d9cfe227aca8d03fcbf6e8105a
Author: James Antill <james at and.org>
Date:   Mon Dec 10 17:36:54 2007 -0500

    Add SecondsOption() class, for user friendlier config. files

diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 46fd092..f521cf5 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -243,7 +243,9 @@ Time (in seconds) after which the metadata will expire. So that if the
 current metadata downloaded is less than this many seconds old then yum will
 not update the metadata against the repository.  If you find that
 yum is not downloading information on updates as often as you would like
-lower the value of this option.
+lower the value of this option. You can also change from the default of using
+seconds to using days, hours or minutes by appending a d, h or m respectivley.
+The default is 1.5 hours, to compliment yum-updatesd running once an hour.
 
 .IP \fBmirrorlist_expire \fR
 Time (in seconds) after which the mirrorlist locally cached will expire. 
diff --git a/yum/config.py b/yum/config.py
index 174118d..c128a92 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -229,6 +229,44 @@ class IntOption(Option):
         except (ValueError, TypeError), e:
             raise ValueError('invalid integer value')
 
+class SecondsOption(Option):
+
+    """
+    An option representing an integer value of seconds, or a human readable
+    variation specifying days, hours, minutes or seconds.
+    Works like BytesOption.
+
+    Valid inputs: 100, 1.5m, 90s, 1.2d, 1d, 0xF, 0.1
+    Invalid inputs: -10, -0.1, 45.6Z, 1d6h, 1day, 1y
+
+    Return value will always be an integer
+    """
+    MULTS = {'d': 60 * 60 * 24, 'h' : 60 * 60, 'm' : 60, 's': 1}
+
+    def parse(self, s):
+        if len(s) < 1:
+            raise ValueError("no value specified")
+
+        if s[-1].isalpha():
+            n = s[:-1]
+            unit = s[-1].lower()
+            mult = self.MULTS.get(unit, None)
+            if not mult:
+                raise ValueError("unknown unit '%s'" % unit)
+        else:
+            n = s
+            mult = 1
+
+        try:
+            n = float(n)
+        except (ValueError, TypeError), e:
+            raise ValueError('invalid value')
+
+        if n < 0:
+            raise ValueError("seconds value may not be negative")
+
+        return int(n * mult)
+
 class BoolOption(Option):
 
     """
@@ -551,8 +589,8 @@ class YumConf(StartupConf):
     throttle = ThrottleOption(0)
 
     http_caching = SelectionOption('all', ('none', 'packages', 'all'))
-    metadata_expire = IntOption(1800)   # time in seconds
-    mirrorlist_expire = IntOption(86400) # time in seconds (1 day)
+    metadata_expire = SecondsOption(1800)   # time in seconds
+    mirrorlist_expire = SecondsOption(86400) # time in seconds (1 day)
     rpm_check_debug = BoolOption(True)
     disable_excludes = ListOption()    
 



More information about the Yum-cvs-commits mailing list