Francois Gouget : testbot: Use human readable durations for the administrator notifications.

Alexandre Julliard julliard at winehq.org
Thu Mar 22 16:55:09 CDT 2018


Module: tools
Branch: master
Commit: 0b308ee3291535b1a0575045d3afed25f8ec040d
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=0b308ee3291535b1a0575045d3afed25f8ec040d

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Mar 22 02:01:40 2018 +0100

testbot: Use human readable durations for the administrator notifications.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/LibvirtTool.pl     | 9 ++++-----
 testbot/lib/WineTestBot/Log.pm | 9 ++++++++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/testbot/bin/LibvirtTool.pl b/testbot/bin/LibvirtTool.pl
index c0288e7..fa07d2d 100755
--- a/testbot/bin/LibvirtTool.pl
+++ b/testbot/bin/LibvirtTool.pl
@@ -265,15 +265,14 @@ sub Monitor()
                          "$VMKey does not exist anymore";
       NotifyAdministrator("The $VMKey VM is not relevant anymore",
                           "The $VMKey VM was offline but ceased to be relevant after ".
-                          Elapsed($Start). " seconds:\n\n$Reason\n");
+                          PrettyElapsed($Start). ":\n\n$Reason\n");
       return 1;
     }
     if ($VM->Status ne "offline")
     {
       NotifyAdministrator("The $VMKey VM is working again (". $VM->Status .")",
                           "The status of the $VMKey VM unexpectedly switched from offline\n".
-                          "to ". $VM->Status ." after ". Elapsed($Start)
-                          ." seconds.");
+                          "to ". $VM->Status ." after ". PrettyElapsed($Start) .".");
       return 0;
     }
 
@@ -320,7 +319,7 @@ sub Monitor()
         return 1 if (ChangeStatus("offline", "off", "done"));
         NotifyAdministrator("The $VMKey VM is working again",
                             "The $VMKey VM started working again after ".
-                            Elapsed($Start) ." seconds.");
+                            PrettyElapsed($Start) ." seconds.");
         return 0;
       }
     }
@@ -459,6 +458,6 @@ else
   Error("Unsupported action $Action!\n");
   $Rc = 1;
 }
-LogMsg "$Action on $VMKey completed in ", Elapsed($Start), " s\n";
+LogMsg "$Action on $VMKey completed in ", PrettyElapsed($Start), " s\n";
 
 exit $Rc;
diff --git a/testbot/lib/WineTestBot/Log.pm b/testbot/lib/WineTestBot/Log.pm
index f1499dd..65782c5 100644
--- a/testbot/lib/WineTestBot/Log.pm
+++ b/testbot/lib/WineTestBot/Log.pm
@@ -26,12 +26,13 @@ WineTestBot::Log - Logging
 =cut
 
 use WineTestBot::Config;
+use WineTestBot::Utils;
 
 use vars qw (@ISA @EXPORT);
 
 require Exporter;
 @ISA = qw(Exporter);
- at EXPORT = qw(&LogMsg &OpenLog &Time &Elapsed);
+ at EXPORT = qw(&LogMsg &OpenLog &Time &Elapsed &PrettyElapsed);
 
 my $logfile;
 my $logprefix;
@@ -108,4 +109,10 @@ sub Elapsed($)
     return sprintf("%0.2f", Time()-$Start);
 }
 
+sub PrettyElapsed($)
+{
+    my ($Start) = @_;
+    return DurationToString(Time()-$Start);
+}
+
 1;




More information about the wine-cvs mailing list