From 0295b0a19c3411bebe3e189484dade123c7b7ab2 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 26 Nov 2014 17:55:56 +0000 Subject: use is_device --- installer/installer.py | 12 ++++++++++-- 1 file 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 -- cgit v1.2.1