summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-11-26 17:55:56 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-12-02 17:58:47 +0000
commite571d6034528faca2a451a67207be1da201247a5 (patch)
tree663ae4e032de6381aad98524bf72f6913fab496a
parent07ec77e783020fa940aafede8e90035d83eb60e2 (diff)
downloaddefinitions-e571d6034528faca2a451a67207be1da201247a5.tar.gz
use is_device
-rwxr-xr-xinstaller/installer.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/installer/installer.py b/installer/installer.py
index 5c504ad1..e9761a5c 100755
--- a/installer/installer.py
+++ b/installer/installer.py
@@ -63,7 +63,7 @@ class BaserockInstaller():
os.execl('/bin/sh', 'sh')
def validate_install_values(self, disk_dest, rootfs):
- if not self.deploying_to_device(disk_dest):
+ if not self.is_device(disk_dest):
print "ERROR: Not deploying to a device"
raise BaseException
if not os.path.exists(disk_dest):
@@ -160,7 +160,15 @@ class BaserockInstaller():
run_script = "sh %s" % install_script
subprocess.check_call(run_script, shell=True)
- def deploying_to_device(self, location):
+ def is_device(self, location):
+ try:
+ st = os.stat(location)
+ return stat.S_ISBLK(st.st_mode)
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ return False
+ raise
+
dev_regex = re.compile("^/dev/((sd|vd|mmcblk|hd)[a-z0-9]+)$")
if dev_regex.match(location):
return True