summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaryl W. Grunau <DarylGrunau@gmail.com>2019-11-11 16:47:47 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2019-12-01 20:21:08 -0800
commit9c5b58350804b7179ae7f12fffb2a55fff626110 (patch)
tree1ba8e627758a4fe26eaf9be26477f349d913cfa2
parenteb22abc5211a2600f62d72ca9fb6f013cec9a3f6 (diff)
downloadspack-9c5b58350804b7179ae7f12fffb2a55fff626110.tar.gz
spack-9c5b58350804b7179ae7f12fffb2a55fff626110.tar.bz2
spack-9c5b58350804b7179ae7f12fffb2a55fff626110.tar.xz
spack-9c5b58350804b7179ae7f12fffb2a55fff626110.zip
verify.py: os.path.exists exception handling (#13656)
-rw-r--r--lib/spack/spack/verify.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/spack/spack/verify.py b/lib/spack/spack/verify.py
index ec604a3240..88b89cf17c 100644
--- a/lib/spack/spack/verify.py
+++ b/lib/spack/spack/verify.py
@@ -28,24 +28,26 @@ def compute_hash(path):
def create_manifest_entry(path):
data = {}
- stat = os.stat(path)
- data['mode'] = stat.st_mode
- data['owner'] = stat.st_uid
- data['group'] = stat.st_gid
+ if os.path.exists(path):
+ stat = os.stat(path)
- if os.path.islink(path):
- data['type'] = 'link'
- data['dest'] = os.readlink(path)
+ data['mode'] = stat.st_mode
+ data['owner'] = stat.st_uid
+ data['group'] = stat.st_gid
- elif os.path.isdir(path):
- data['type'] = 'dir'
+ if os.path.islink(path):
+ data['type'] = 'link'
+ data['dest'] = os.readlink(path)
- else:
- data['type'] = 'file'
- data['hash'] = compute_hash(path)
- data['time'] = stat.st_mtime
- data['size'] = stat.st_size
+ elif os.path.isdir(path):
+ data['type'] = 'dir'
+
+ else:
+ data['type'] = 'file'
+ data['hash'] = compute_hash(path)
+ data['time'] = stat.st_mtime
+ data['size'] = stat.st_size
return data