Dima Kuznetsov has uploaded a new change for review.

Change subject: open: Change file() to open()
......................................................................

open: Change file() to open()

Update file calls to open calls due to file's deprecation.

Change-Id: I80007044be1c648ebb668704731eae8b83366025
Signed-off-by: Dima Kuznetsov <[email protected]>
---
M vdsm/API.py
M vdsm/hooks.py
M vdsm/storage/fileUtils.py
M vdsm/storage/hba.py
M vdsm/virt/sampling.py
M vdsm_hooks/nestedvt/before_vm_start.py
6 files changed, 13 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/76/26776/1

diff --git a/vdsm/API.py b/vdsm/API.py
index 94b39b6..6724559 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -185,8 +185,8 @@
                     # parmas were stored.
                     fname = self._cif.prepareVolumePath(paramFilespec)
                     try:
-                        with file(fname) as f:
-                            pickledMachineParams = pickle.load(f)
+                        with open(fname) as file:
+                            pickledMachineParams = pickle.load(file)
 
                         if type(pickledMachineParams) == dict:
                             self.log.debug('loaded pickledMachineParams ' +
diff --git a/vdsm/hooks.py b/vdsm/hooks.py
index 75f33f9..ba7bad7 100644
--- a/vdsm/hooks.py
+++ b/vdsm/hooks.py
@@ -341,8 +341,8 @@
 
 def _getScriptInfo(path):
     try:
-        with file(path) as f:
-            md5 = hashlib.md5(f.read()).hexdigest()
+        with open(path) as file:
+            md5 = hashlib.md5(file.read()).hexdigest()
     except:
         md5 = ''
     return {'md5': md5}
diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 56dc1ef..4ffe113 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -401,6 +401,6 @@
 
 
 def padToBlockSize(path):
-    with file(path, 'a') as f:
-        size = os.fstat(f.fileno()).st_size
-        os.ftruncate(f.fileno(), 512 * ((size + 511) / 512))
+    with open(path, 'a') as file:
+        size = os.fstat(file.fileno()).st_size
+        os.ftruncate(file.fileno(), 512 * ((size + 511) / 512))
diff --git a/vdsm/storage/hba.py b/vdsm/storage/hba.py
index da3feef..b649f6c 100644
--- a/vdsm/storage/hba.py
+++ b/vdsm/storage/hba.py
@@ -43,8 +43,8 @@
     """
     hbas = []
     try:
-        with file(ISCSI_INITIATOR_NAME) as f:
-            for line in f:
+        with open(ISCSI_INITIATOR_NAME) as file:
+            for line in file:
                 if line.startswith(INITIATOR_NAME):
                     hba = {'InitiatorName': line.split("=")[1].strip()}
                     hbas.append(hba)
diff --git a/vdsm/virt/sampling.py b/vdsm/virt/sampling.py
index 991c969..ed8f58e 100644
--- a/vdsm/virt/sampling.py
+++ b/vdsm/virt/sampling.py
@@ -189,8 +189,8 @@
             self.cpuLoad = '0.0'
         self.diskStats = self._getDiskStats()
         try:
-            with file(_THP_STATE_PATH) as f:
-                s = f.read()
+            with open(_THP_STATE_PATH) as file:
+                s = file.read()
                 self.thpState = s[s.index('[') + 1:s.index(']')]
         except:
             self.thpState = 'never'
diff --git a/vdsm_hooks/nestedvt/before_vm_start.py 
b/vdsm_hooks/nestedvt/before_vm_start.py
index 03f0f6f..d4fb806 100755
--- a/vdsm_hooks/nestedvt/before_vm_start.py
+++ b/vdsm_hooks/nestedvt/before_vm_start.py
@@ -29,8 +29,8 @@
 for kvm_mod in ("kvm_intel", "kvm_amd"):
     kvm_mod_path = "/sys/module/%s/parameters/nested" % kvm_mod
     try:
-        with file(kvm_mod_path) as f:
-            if f.readline().strip() in ("Y", "1"):
+        with open(kvm_mod_path) as file:
+            if file.readline().strip() in ("Y", "1"):
                 break
     except IOError:
         pass


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I80007044be1c648ebb668704731eae8b83366025
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to