diff options
| author | Matthew Hooker <matt@cloudscaling.com> | 2011-08-03 19:17:08 -0400 |
|---|---|---|
| committer | Matthew Hooker <matt@cloudscaling.com> | 2011-08-03 19:17:08 -0400 |
| commit | f34a6fb9efd8d950555431f5e7268dbde8ae78c8 (patch) | |
| tree | 3a644a8729b97e69e41c87cb4835bef85b4681a4 /nova/cloudpipe | |
| parent | e2770a4558c95aa4b6e276ebe18dc580a82e6d67 (diff) | |
| download | nova-f34a6fb9efd8d950555431f5e7268dbde8ae78c8.tar.gz nova-f34a6fb9efd8d950555431f5e7268dbde8ae78c8.tar.xz nova-f34a6fb9efd8d950555431f5e7268dbde8ae78c8.zip | |
Remove instances of the "diaper pattern"
Anywhere "except:" occurs, I tried to replace it with an explicit except on
known error types. If none were known, Except was used.
In the process I've been able to unearth a few evasive bugs and clean up some
adjacent code.
Diffstat (limited to 'nova/cloudpipe')
| -rw-r--r-- | nova/cloudpipe/pipelib.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py index 521525205..46549c9d7 100644 --- a/nova/cloudpipe/pipelib.py +++ b/nova/cloudpipe/pipelib.py @@ -141,15 +141,12 @@ class CloudPipe(object): try: result = cloud._gen_key(context, context.user_id, key_name) private_key = result['private_key'] - try: - key_dir = os.path.join(FLAGS.keys_path, context.user_id) - if not os.path.exists(key_dir): - os.makedirs(key_dir) - key_path = os.path.join(key_dir, '%s.pem' % key_name) - with open(key_path, 'w') as f: - f.write(private_key) - except: - pass - except exception.Duplicate: + key_dir = os.path.join(FLAGS.keys_path, context.user_id) + if not os.path.exists(key_dir): + os.makedirs(key_dir) + key_path = os.path.join(key_dir, '%s.pem' % key_name) + with open(key_path, 'w') as f: + f.write(private_key) + except exception.Duplicate, os.error, IOError: pass return key_name |
