<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,6 +11,7 @@ and working directly on the project:
 * Ben Snider, bensnider.com - the original code for microblogs.py, docs
 * garthrk, github.org/garthrk - random fixes and tests, docs
 * Jason Penney, jasonpenney.net - brain storming, random fixes and enhancements
+* Tony Giunta - alternate implementation of uptime that uses uptime command
 
 I want to give a special thanks to Jonathan Coulton, Brad Turcotte and Beatnik
 Turtle for freely offering their songs for download.  Being able to grab a</diff>
      <filename>CREDITS.txt</filename>
    </modified>
    <modified>
      <diff>@@ -20,6 +20,7 @@
 import string
 import os.path
 import logging
+from subprocess import Popen, PIPE
 from flashbake.plugins import AbstractMessagePlugin
 
 class UpTime(AbstractMessagePlugin):
@@ -43,8 +44,7 @@ class UpTime(AbstractMessagePlugin):
             http://thesmithfam.org/blog/2005/11/19/python-uptime-script/ &quot;&quot;&quot;
 
         if not os.path.exists('/proc/uptime'):
-            logging.warn('/proc/uptime doesn\'t exist.')
-            return None
+            return self.__run_uptime()
 
         f = open( &quot;/proc/uptime&quot; )
         try:
@@ -78,3 +78,49 @@ class UpTime(AbstractMessagePlugin):
         string += str(seconds) + &quot; &quot; + (seconds == 1 and &quot;second&quot; or &quot;seconds&quot; )
 
         return string
+    
+    
+    def __run_uptime(self):
+        &quot;&quot;&quot; For OSes that don't provide procfs, then try to use the updtime command.
+        
+            Thanks to Tony Giunta for this contribution. &quot;&quot;&quot;
+        # Try to capture output of 'uptime' command, 
+        # if not found, catch OSError, log and return None
+        try:
+            output = Popen(&quot;uptime&quot;, stdout=PIPE).communicate()[0].split()
+        except OSError:
+            logging.warn(&quot;Can't find 'uptime' command in $PATH&quot;)
+            return None
+    
+        # Parse uptime output string
+        # if len == 10 or 11, uptime is less than a day
+        if len(output) in [10,11]:
+            days = &quot;00&quot;
+            hours_and_minutes = output[2].strip(&quot;,&quot;)
+        elif len(output) == 12:
+            days = output[2]
+            hours_and_minutes = output[4].strip(&quot;,&quot;)
+        else:
+            return None
+        
+        # If time is exactly x hours/mins, no &quot;:&quot; in &quot;hours_and_minutes&quot; 
+        # and the interpreter will throw a ValueError
+        try:
+            hours, minutes = hours_and_minutes.split(&quot;:&quot;)
+        except ValueError:
+            if output[3].startswith(&quot;hr&quot;):
+                hours = hours_and_minutes
+                minutes = &quot;00&quot;
+            elif output[3].startwwith(&quot;min&quot;):
+                hours = &quot;00&quot;
+                minutes = hours_and_minutes
+            else:
+                return None
+        
+        # Build up output string, might require Python 2.5+
+        uptime = (days + (&quot; day, &quot; if days == &quot;1&quot; else &quot; days, &quot;) +
+                hours + (&quot; hour, &quot; if hours == &quot;1&quot; else &quot; hours, &quot;) +
+                minutes + (&quot; minute&quot; if minutes == &quot;1&quot; else &quot; minutes&quot;))
+    
+        return uptime
+</diff>
      <filename>flashbake/plugins/uptime.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f88b1dacc7f3e0c0e6f5a41addb0d87a3ac29c0a</id>
    </parent>
  </parents>
  <author>
    <name>Thomas Gideon</name>
    <email>cmdln@thecommandline.net</email>
  </author>
  <url>http://github.com/commandline/flashbake/commit/c3d28b3653c59b63e05bf398d7dd5a9c361fadba</url>
  <id>c3d28b3653c59b63e05bf398d7dd5a9c361fadba</id>
  <committed-date>2009-07-17T09:07:14-07:00</committed-date>
  <authored-date>2009-07-17T09:07:14-07:00</authored-date>
  <message>Included Tony's uptime enhancement.</message>
  <tree>e629bbcb3a15c3f5bdd11ea4314bc4b8eb2b9347</tree>
  <committer>
    <name>Thomas Gideon</name>
    <email>cmdln@thecommandline.net</email>
  </committer>
</commit>
