From 1dd0eac8b57b646d5772dce3adfb2d230d19222c Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 10 Oct 2014 10:56:52 +0000 Subject: Add 'is_device' function to check if we are deploying to a device --- morphlib/writeexts.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index 0fd0ad7b..48c9434e 100644 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -22,6 +22,8 @@ import shutil import sys import time import tempfile +import errno +import stat import morphlib @@ -572,3 +574,12 @@ class WriteExtension(cliapp.Application): logging.error("Error checking SSH connectivity: %s", str(e)) raise cliapp.AppException( 'Unable to SSH to %s: %s' % (ssh_host, e)) + + 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 -- cgit v1.2.1