[anaconda-storage-branch PATCH 1/6] Use booleans in isys.mount() and isys.umount()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use True/False over 1/0.  It's the future.
---
 image.py            |   12 ++++++------
 isys/isys.py        |    7 ++++---
 livecd.py           |    4 ++--
 partedUtils.py      |    6 ++++--
 rescue.py           |    4 ++--
 storage/__init__.py |    2 +-
 yuminstall.py       |   10 +++++-----
 7 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/image.py b/image.py
index 83e74db..dea1e40 100644
--- a/image.py
+++ b/image.py
@@ -47,7 +47,7 @@ def findIsoImages(path, messageWindow):
 
         try:
             isys.mount("/dev/loop2", "/mnt/cdimage", fstype = "iso9660",
-                       readOnly = 1)
+                       readOnly = True)
             for num in range(1, 10):
                 if os.access("/mnt/cdimage/.discinfo", os.R_OK):
                     f = open("/mnt/cdimage/.discinfo")
@@ -95,7 +95,7 @@ def findIsoImages(path, messageWindow):
 
                     discImages[num] = file
 
-            isys.umount("/mnt/cdimage", removeDir=0)
+            isys.umount("/mnt/cdimage", removeDir=False)
         except SystemError:
             pass
 
@@ -179,7 +179,7 @@ def mountImage(isodir, tree, discnum, messageWindow, discImages={}):
         try:
             isoImage = "%s/%s" % (isodir, discImages[discnum])
             isys.losetup("/dev/loop1", isoImage, readOnly = 1)
-            isys.mount("/dev/loop1", tree, fstype = 'iso9660', readOnly = 1);
+            isys.mount("/dev/loop1", tree, fstype = 'iso9660', readOnly = True);
             break
         except:
             ans = messageWindow(_("Missing ISO 9660 Image"),
@@ -255,7 +255,7 @@ def scanForMedia(tree, storage):
             continue
 
         try:
-            if isys.mount(dev.path, tree, fstype="iso9660", readOnly=1):
+            if isys.mount(dev.path, tree, fstype="iso9660", readOnly=True):
                 continue
         except:
             continue
@@ -270,7 +270,7 @@ def scanForMedia(tree, storage):
 
 def umountImage(tree, currentMedia):
     if currentMedia is not None:
-        isys.umount(tree, removeDir=0)
+        isys.umount(tree, removeDir=False)
         isys.unlosetup("/dev/loop1")
 
 def unmountCD(path, messageWindow):
@@ -279,7 +279,7 @@ def unmountCD(path, messageWindow):
 
     while True:
         try:
-            isys.umount(path, removeDir=0)
+            isys.umount(path, removeDir=False)
             break
         except Exception, e:
             log.error("exception in _unmountCD: %s" %(e,))
diff --git a/isys/isys.py b/isys/isys.py
index d2168db..1f4f222 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -130,7 +130,7 @@ def ddfile(file, megs, pw = None):
     os.close(fd)
 
 ## Mount a filesystem, similar to the mount system call.
-# @param device The device to mount.  If bindMount is 1, this should be an
+# @param device The device to mount.  If bindMount is True, this should be an
 #               already mounted directory.  Otherwise, it should be a device
 #               name.
 # @param location The path to mount device on.
@@ -141,7 +141,8 @@ def ddfile(file, megs, pw = None):
 # @param bindMount Is this a bind mount?  (see the mount(8) man page)
 # @param remount Are we mounting an already mounted filesystem?
 # @return The return value from the mount system call.
-def mount(device, location, fstype = "ext2", readOnly = 0, bindMount = 0, remount = 0, options = "defaults"):
+def mount(device, location, fstype = "ext2", readOnly = False,
+          bindMount = False, remount = False, options = "defaults"):
     flags = None
     location = os.path.normpath(location)
     opts = string.split(options)
@@ -180,7 +181,7 @@ def mount(device, location, fstype = "ext2", readOnly = 0, bindMount = 0, remoun
 #             absolute path.
 # @param removeDir Should the mount point be removed after being unmounted?
 # @return The return value from the umount system call.
-def umount(what, removeDir = 1):
+def umount(what, removeDir = True):
     what = os.path.normpath(what)
 
     if not os.path.isdir(what):
diff --git a/livecd.py b/livecd.py
index 216b77e..2d09717 100644
--- a/livecd.py
+++ b/livecd.py
@@ -140,7 +140,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
             dirs.append("/selinux")
         for dir in dirs:
             try:
-                isys.umount("%s/%s" %(anaconda.rootPath,dir), removeDir = 0)
+                isys.umount("%s/%s" %(anaconda.rootPath,dir), removeDir = False)
             except Exception, e:
                 log.error("unable to unmount %s: %s" %(dir, e))
 
@@ -303,7 +303,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
                 isys.mount("/selinux", anaconda.rootPath + "/selinux", "selinuxfs")
             except Exception, e:
                 log.error("error mounting selinuxfs: %s" %(e,))
-        isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = 1)
+        isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = True)
 
         wait.pop()
 
diff --git a/partedUtils.py b/partedUtils.py
index d0077f2..dde4d0b 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -511,7 +511,8 @@ class DiskSet:
             fs = isys.readFSType(theDev)
             if fs is not None:
                 try:
-                    isys.mount(theDev, self.anaconda.rootPath, fs, readOnly = 1)
+                    isys.mount(theDev, self.anaconda.rootPath, fs,
+                               readOnly = True)
                     found = 1
                 except SystemError:
                     pass
@@ -557,7 +558,8 @@ class DiskSet:
             fs = isys.readFSType(theDev)
             if fs is not None:
                 try:
-                    isys.mount(theDev, self.anaconda.rootPath, fs, readOnly = 1)
+                    isys.mount(theDev, self.anaconda.rootPath, fs,
+                               readOnly = True)
                     found = 1
                 except SystemError:
                     pass
diff --git a/rescue.py b/rescue.py
index ffdd6a8..aeceb98 100644
--- a/rescue.py
+++ b/rescue.py
@@ -329,10 +329,10 @@ def runRescue(anaconda, instClass):
                         log.error("Error enabling swap")
 
                 # now that dev is udev, bind mount the installer dev there
-                isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = 1)
+                isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = True)
 
                 # and /dev/pts
-                isys.mount("/dev/pts", "%s/dev/pts" %(anaconda.rootPath,), bindMount = 1)
+                isys.mount("/dev/pts", "%s/dev/pts" %(anaconda.rootPath,), bindMount = True)
 
                 # and /selinux too
                 if flags.selinux and os.path.isdir("%s/selinux" %(anaconda.rootPath,)):
diff --git a/storage/__init__.py b/storage/__init__.py
index 08ba90a..a393226 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -1459,7 +1459,7 @@ class FSSet(object):
     def umountFilesystems(self, instPath, ignoreErrors=True, swapoff=True):
         # XXX if we tracked the /dev bind mount this wouln't be necessary
         if os.path.ismount("%s/dev" % instPath):
-            isys.umount("%s/dev" % instPath, removeDir=0)
+            isys.umount("%s/dev" % instPath, removeDir=False)
 
         devices = self.mountpoints.values() + self.swapDevices
         devices.extend([self.devshm, self.devpts, self.sysfs, self.proc])
diff --git a/yuminstall.py b/yuminstall.py
index a5de702..19f31be 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -329,7 +329,7 @@ class AnacondaYum(YumSorter):
         if self.currentMedia is None:
             try:
                 isys.mount(self.anaconda.mediaDevice, self.tree,
-                           fstype="iso9660", readOnly=1)
+                           fstype="iso9660", readOnly=True)
 
                 if verifyMedia(self.tree, discnum, None):
                     self.currentMedia = discnum
@@ -355,7 +355,7 @@ class AnacondaYum(YumSorter):
 
             try:
                 isys.mount(self.anaconda.mediaDevice, self.tree,
-                           fstype = "iso9660", readOnly = 1)
+                           fstype = "iso9660", readOnly = True)
 
                 if verifyMedia(self.tree, discnum, self._timestamp):
                     self.currentMedia = discnum
@@ -432,7 +432,7 @@ class AnacondaYum(YumSorter):
                 # install instead.
                 images = findIsoImages(self.tree, self.anaconda.intf.messageWindow)
                 if images != {}:
-                    isys.umount(self.tree, removeDir=0)
+                    isys.umount(self.tree, removeDir=False)
                     self.anaconda.methodstr = "nfsiso:%s" % m[4:]
                     self.configBaseURL()
                     return
@@ -1367,7 +1367,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
         if anaconda.dir == DISPATCH_BACK:
             for d in ("/selinux", "/dev"):
                 try:
-                    isys.umount(anaconda.rootPath + d, removeDir = 0)
+                    isys.umount(anaconda.rootPath + d, removeDir = False)
                 except Exception, e:
                     log.error("unable to unmount %s: %s" %(d, e))
             return
@@ -1458,7 +1458,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
             # handling /dev, it gets to be more fun.  so just bind mount the
             # installer /dev
             log.warning("no dev package, going to bind mount /dev")
-            isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = 1)
+            isys.mount("/dev", "%s/dev" %(anaconda.rootPath,), bindMount = True)
             if not upgrade:
                 anaconda.id.storage.fsset.mkDevRoot(anaconda.rootPath)
 
-- 
1.6.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux