Martin Betak has uploaded a new change for review.

Change subject: agent: Fix python-2.4 compatibility
......................................................................

agent: Fix python-2.4 compatibility

Rewrote the use of ternary operator to if since it is not
supported in python-2.4.

Change-Id: I03c63477a2d2bcb9eb4c4307946a3486300663e1
Signed-off-by: Martin Betak <mbe...@redhat.com>
---
M ovirt-guest-agent/GuestAgentLinux2.py
M ovirt-guest-agent/GuestAgentWin32.py
M ovirt-guest-agent/OVirtAgentLogic.py
3 files changed, 14 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-guest-agent 
refs/changes/48/19148/1

diff --git a/ovirt-guest-agent/GuestAgentLinux2.py 
b/ovirt-guest-agent/GuestAgentLinux2.py
index abf0c3b..a60e7a5 100644
--- a/ovirt-guest-agent/GuestAgentLinux2.py
+++ b/ovirt-guest-agent/GuestAgentLinux2.py
@@ -167,11 +167,14 @@
         # The shutdown command works with minutes while vdsm send value in
         # seconds, so we round up the value to minutes.
         delay = (int(timeout) + 59) / 60
-        param = '-r' if reboot else '-h'
+        param = '-h'
+        action = 'shutdown'
+        if reboot:
+            param = '-r'
+            action = 'reboot'
         cmd = ['/usr/share/ovirt-guest-agent/ovirt-shutdown', param,
                "+%d" % (delay), "\"%s\"" % (msg)]
 
-        action = 'reboot' if reboot else 'shutdown'
         logging.debug("Executing %s command: %s", action, cmd)
         subprocess.call(cmd)
 
diff --git a/ovirt-guest-agent/GuestAgentWin32.py 
b/ovirt-guest-agent/GuestAgentWin32.py
index ab1725d..d59ac75 100644
--- a/ovirt-guest-agent/GuestAgentWin32.py
+++ b/ovirt-guest-agent/GuestAgentWin32.py
@@ -201,11 +201,15 @@
             logging.debug("No active session. Ignoring log off command.")
 
     def shutdown(self, timeout, msg, reboot=False):
-        param = '-r' if reboot else '-s'
+        param = '-s'
+        action = 'shutdown'
+        if reboot:
+            param = '-r'
+            action = 'reboot'
+
         cmd = "%s\\system32\\shutdown.exe %s -t %d -f -c \"%s\"" \
             % (os.environ['WINDIR'], param, timeout, msg)
 
-        action = 'reboot' if reboot else 'shutdown'
         logging.debug("Executing %s command: '%s'", action, cmd)
 
         # Since we're a 32-bit application that sometimes is executed on
diff --git a/ovirt-guest-agent/OVirtAgentLogic.py 
b/ovirt-guest-agent/OVirtAgentLogic.py
index 233e15b..52c3825 100644
--- a/ovirt-guest-agent/OVirtAgentLogic.py
+++ b/ovirt-guest-agent/OVirtAgentLogic.py
@@ -185,7 +185,9 @@
             except:
                 reboot = False
 
-            action = 'Rebooting' if reboot else 'Shutting down'
+            action = 'Shutting down'
+            if reboot:
+                action = 'Rebooting'
             logging.info("%s (timeout = %d, message = '%s')"
                          % (action, timeout, msg))
             self.commandHandler.shutdown(timeout, msg, reboot)


-- 
To view, visit http://gerrit.ovirt.org/19148
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03c63477a2d2bcb9eb4c4307946a3486300663e1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-guest-agent
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <mbe...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to