Fix issues when working through an outbound proxy

* reqork setup-develop() to handle proxy operations and empty dependency lists
* use keystone to get admin token (eliminate a direct curl invocation)
* check for cached image files of 0 bytes and re-download if needed

Change-Id: Ief356667ed3ef8d05c6604f12513ae81f68cec04
diff --git a/functions b/functions
index 7072fdd..7fd726e 100644
--- a/functions
+++ b/functions
@@ -309,6 +309,23 @@
 }
 
 
+# pip install the dependencies of the package before we do the setup.py
+# develop, so that pip and not distutils process the dependency chain
+# setup_develop directory
+function setup_develop() {
+    (cd $1; \
+        python setup.py egg_info; \
+        raw_links=$(awk '/^.+/ {print "-f " $1}' *.egg-info/dependency_links.txt); \
+        depend_links=$(echo $raw_links | xargs); \
+        pip_install -r *-info/requires.txt $depend_links; \
+        sudo \
+            HTTP_PROXY=$http_proxy \
+            HTTPS_PROXY=$https_proxy \
+            python setup.py develop \
+    )
+}
+
+
 # Service wrapper to start services
 # start_service service-name
 function start_service() {