From: Anirudha Bose Date: Wed, 17 Aug 2016 06:43:53 +0000 (+0530) Subject: ceph-disk: Use os.path.isabs instead of .startswith('/') X-Git-Tag: v10.2.4~16^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9191825c06b3d92e2caa26c9efdb69a79cc3964b;p=ceph.git ceph-disk: Use os.path.isabs instead of .startswith('/') Signed-off-by: Anirudha Bose (cherry picked from commit 6f795356de00dd7c33282183b11a03da800fde7b) --- diff --git a/src/ceph-disk/ceph_disk/main.py b/src/ceph-disk/ceph_disk/main.py index fd60ee9b650..9f4a2f03a0b 100755 --- a/src/ceph-disk/ceph_disk/main.py +++ b/src/ceph-disk/ceph_disk/main.py @@ -382,7 +382,7 @@ def _get_command_executable(arguments): Return the full path for an executable, raise if the executable is not found. If the executable has already a full path do not perform any checks. """ - if arguments[0].startswith('/'): # an absolute path + if os.path.isabs(arguments[0]): # an absolute path return arguments executable = which(arguments[0]) if not executable: @@ -768,7 +768,7 @@ def is_mounted(dev): continue mounts_dev = fields[0] path = fields[1] - if mounts_dev.startswith('/') and os.path.exists(mounts_dev): + if os.path.isabs(mounts_dev) and os.path.exists(mounts_dev): mounts_dev = os.path.realpath(mounts_dev) if mounts_dev == dev: return _bytes2str(path) @@ -3811,7 +3811,7 @@ def is_swap(dev): if len(fields) < 3: continue swaps_dev = fields[0] - if swaps_dev.startswith('/') and os.path.exists(swaps_dev): + if os.path.isabs(swaps_dev) and os.path.exists(swaps_dev): swaps_dev = os.path.realpath(swaps_dev) if swaps_dev == dev: return True