diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-10-10 10:56:52 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-11-28 18:26:15 +0000 |
commit | fb15204db565651128a4fdb3f502615b1473935d (patch) | |
tree | 6c555fd24e1aa4c90cbaaf4cd34b0e4abc1deda6 | |
parent | f034691cba14d1919a3c8d1ffa41872ff754e1d3 (diff) | |
download | morph-fb15204db565651128a4fdb3f502615b1473935d.tar.gz |
Add 'is_device' function to check if we are deploying to a device
-rw-r--r-- | morphlib/writeexts.py | 11 |
1 files changed, 11 insertions, 0 deletions
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 |