diff getXenaData.py @ 43:78d6e6772e30

more reliable
author jingchunzhu <jingchunzhu@gmail.com>
date Mon, 27 Jul 2015 12:21:55 -0700
parents bc9784300015
children 3167c1a26101
line wrap: on
line diff
--- a/getXenaData.py	Mon Jul 27 12:01:42 2015 -0700
+++ b/getXenaData.py	Mon Jul 27 12:21:55 2015 -0700
@@ -16,22 +16,29 @@
   url = "https://galaxyxena.soe.ucsc.edu:443/xena"
 
 #testing if the url is reachable
-#try:
-r =json.loads(xena.post(url, "(+ 1 2)")) 
-if  r!=3.0:
-  print "The hub seems can not be reached, either it is not running, the url has a typo, or it is not accessible to you."
-  print "You entered hub: %s" % (url)
-  fout.write("The hub seems can not be reached, either it is not running, the url has a typo, or it is not accessible to you.\n")
-  fout.write("You entered hub: %s\n" % (url))
-  fout.close()
-  sys.exit(1)
+try:
+  r =json.loads(xena.post(url, "(+ 1 2)")) 
+  if  r!=3.0:
+    print "The hub seems can not be reached, either it is not running, the url has a typo, or it is not accessible to you."
+    print "You entered hub: %s" % (url)
+    fout.write("The hub seems can not be reached, either it is not running, the url has a typo, or it is not accessible to you.\n")
+    fout.write("You entered hub: %s\n" % (url))
+    fout.close()
+    sys.exit(1)
+except: 
+    print "The hub seems can not be reached, either it is not running, the url has a typo, or it is not accessible to you."
+    print "You entered hub: %s" % (url)
+    fout.write("The hub seems can not be reached, either it is not running, the url has a typo, or it is not accessible to you.\n")
+    fout.write("You entered hub: %s\n" % (url))
+    fout.close()
+    sys.exit(1)
 
 samples = xena.dataset_samples (url, dataset)
 if not samples:
   print "Dataset does not exist"
   print "You entered dataset id: %s" % (dataset)
   fout.write("Dataset does not exists\n")
-  fout.wriet("You entered dataset id: %s\n" % (dataset))
+  fout.write("You entered dataset id: %s\n" % (dataset))
   fout.close()
   sys.exit(1)