Skip to content

Instantly share code, notes, and snippets.

@hughsaunders
Created April 25, 2013 13:03
Show Gist options
  • Save hughsaunders/5459519 to your computer and use it in GitHub Desktop.
Save hughsaunders/5459519 to your computer and use it in GitHub Desktop.
diff --git a/glanceclient/v1/shell.py b/glanceclient/v1/shell.py
index 02d3c01..e1b2a35 100644
--- a/glanceclient/v1/shell.py
+++ b/glanceclient/v1/shell.py
@@ -121,7 +121,10 @@ def _set_data_field(fields, args):
# (3) no image data provided:
# glance ...
try:
- os.fstat(0)
+ stat_result = os.fstat(0)
+ if stat_result.st_size == 0:
+ # (3) stdin is open but empty
+ fields['data'] = None
except OSError:
# (1) stdin is not valid (closed...)
fields['data'] = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment