[node-patches] Change in ovirt-node[master]: Stop doing circular imports in process.check_output

rbarry at redhat.com rbarry at redhat.com
Fri Jun 28 14:51:47 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Stop doing circular imports in process.check_output
......................................................................

Stop doing circular imports in process.check_output

ovirt.node.utils.system requires ovirt.node.utils.process.
Circular imports make process unusable from a python shell.
Get rid of qualified imports and do explicit imports instead.

Change-Id: I78891bc3e1dffb6fba320f3bb8b982f2fca75049
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/utils/process.py
M src/ovirt/node/utils/system.py
2 files changed, 10 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/31/16231/1

diff --git a/src/ovirt/node/utils/process.py b/src/ovirt/node/utils/process.py
index 2f0cb17..0c25a12 100644
--- a/src/ovirt/node/utils/process.py
+++ b/src/ovirt/node/utils/process.py
@@ -19,10 +19,10 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from subprocess import STDOUT, PIPE
-import ovirt.node.utils
 import logging
 import subprocess
 import sys
+import ovirt.node.utils.system
 
 """
 Some convenience functions related to processes
diff --git a/src/ovirt/node/utils/system.py b/src/ovirt/node/utils/system.py
index 296edec..7a476a9 100644
--- a/src/ovirt/node/utils/system.py
+++ b/src/ovirt/node/utils/system.py
@@ -19,7 +19,7 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import base, utils
-from ovirt.node.utils import process
+import ovirt.node.utils.process
 import os
 import logging
 import rpm
@@ -40,7 +40,7 @@
 def reboot():
     """Reboot the system
     """
-    process.call("reboot")
+    ovirt.node.utils.process.call("reboot")
 
 
 def async_reboot(delay=3):
@@ -51,7 +51,7 @@
 def poweroff():
     """Poweroff the system
     """
-    process.call("poweroff")
+    ovirt.node.utils.process.call("poweroff")
 
 
 def is_efi():
@@ -100,9 +100,10 @@
     """
     try:
         kwargs = {"shell": False,
-                  "stderr": process.PIPE}
-        r = process.check_output(["service", name, cmd], **kwargs)
-    except process.CalledProcessError as e:
+                  "stderr": ovirt.node.utils.process.PIPE}
+        r = ovirt.node.utils.process.check_output(
+            ["service", name, cmd], **kwargs)
+    except ovirt.node.utils.process.CalledProcessError as e:
         r = e.returncode
         LOGGER.exception("Service: %s" % e.output)
         if do_raise:
@@ -130,8 +131,8 @@
     for f in os.listdir(orig):
         if os.path.isdir("%s/%s" % (orig, f)):
             if not os.path.exists("%s/%s" % (target, f)):
-                process.call("cp -av %s/%s %s &>/dev/null" % (orig, f,
-                                                              target))
+                ovirt.node.utils.process.call("cp -av %s/%s %s &>/dev/null" %
+                                             (orig, f, target))
             else:
                 copy_dir_if_not_exist("%s/%s" % (orig, f), "%s/%s" % (target,
                                                                       f))


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78891bc3e1dffb6fba320f3bb8b982f2fca75049
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list