diff options
| author | Thomas Goirand <zigo@debian.org> | 2015-04-20 10:26:31 +0200 |
|---|---|---|
| committer | Stuart McLaren <stuart.mclaren@hp.com> | 2015-05-14 15:41:24 +0000 |
| commit | 1686d6aa535562ae2ea6e04b6dfd59b86c998c8a (patch) | |
| tree | 6abddb9bb280ba8714f8eb6e075881b50da5b327 | |
| parent | 825c4a5df2e32a2d7c1665f0924cc5b9fa675673 (diff) | |
| download | python-glanceclient-1686d6aa535562ae2ea6e04b6dfd59b86c998c8a.tar.gz | |
Do not crash on homedir mkdir
Glanceclient is trying to create ~/.glanceclient, and crashes if it can't
do that. In some environment (for example, when building the package
under Jenkins), writing on $HOME is simply not allowed, and Glanceclient
can simply ignore it. This patch allows the mkdir() to fail, which fixes
the issue.
Closes-Bug: #1446096
Change-Id: Ib3591fb4e54ccd2fe63a1a4815551ac10ef5b961
| -rw-r--r-- | glanceclient/shell.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py index f212323..6ffd53d 100644 --- a/glanceclient/shell.py +++ b/glanceclient/shell.py @@ -556,7 +556,15 @@ class OpenStackImagesShell(object): def _cache_schemas(self, options, home_dir='~/.glanceclient'): homedir = expanduser(home_dir) if not os.path.exists(homedir): - os.makedirs(homedir) + try: + os.makedirs(homedir) + except OSError as e: + # This avoids glanceclient to crash if it can't write to + # ~/.glanceclient, which may happen on some env (for me, + # it happens in Jenkins, as Glanceclient can't write to + # /var/lib/jenkins). + msg = '%s' % e + print(encodeutils.safe_decode(msg), file=sys.stderr) resources = ['image', 'metadefs/namespace', 'metadefs/resource_type'] schema_file_paths = [homedir + os.sep + x + '_schema.json' |
