[Swift-commit] r5074 - trunk/bin
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Tue Sep 6 10:16:00 CDT 2011
Author: wozniak
Date: 2011-09-06 10:16:00 -0500 (Tue, 06 Sep 2011)
New Revision: 5074
Modified:
trunk/bin/chxml
trunk/bin/swift
Log:
Better error handling in bin/chxml, bin/swift (ref #347)
Modified: trunk/bin/chxml
===================================================================
--- trunk/bin/chxml 2011-09-06 14:51:54 UTC (rev 5073)
+++ trunk/bin/chxml 2011-09-06 15:16:00 UTC (rev 5074)
@@ -14,22 +14,28 @@
self.endTags=[]
self.globusParams = 0
self.execProvider = ""
-
+
if len(argstr)<2:
print "please specify a sites file"
- sys.exit()
+ sys.exit(1)
i = 0
for o in argstr:
if o == "'-sites.file'":
self.sites_file = argstr[i+1].split("'")[1]
elif o == "'-config'":
- config_file = open(argstr[i+1].split("'")[1],"r")
+ try:
+ config_filename = argstr[i+1].split("'")[1]
+ config_file = open(config_filename,"r")
+ except IOError as (errno, strerror):
+ print strerror
+ sys.exit("Could not read: " + config_filename)
+
for line in config_file.readlines():
if line.strip().startswith('#'):
continue
if line.find("sites.file")>-1:
self.sites_file = line.split("=")[1].strip()
- i = i+1
+ i = i+1
if (self.sites_file == ""):
swift_loc = commands.getoutput("which swift")
swift_home = swift_loc.split("bin")[0]
@@ -55,10 +61,11 @@
def end_element(self, name):
self.endTags.append(name)
-
+
#------------------------main----------------------------------
mysite = siteProps(sys.argv)
+
try:
mysite.parsefile()
except Exception, e:
@@ -87,4 +94,4 @@
if (config<1):
print "Warning: Your site file, "+mysite.sites_file+" is missing a config entry"
sys.exit()
-
+
Modified: trunk/bin/swift
===================================================================
--- trunk/bin/swift 2011-09-06 14:51:54 UTC (rev 5073)
+++ trunk/bin/swift 2011-09-06 15:16:00 UTC (rev 5074)
@@ -64,6 +64,10 @@
# make sure sites.xml file is well-formed
$SWIFT_HOME/bin/chxml $CMDLINE
+if [[ ${?} != 0 ]]; then
+ echo "Could not process input files!"
+ exit 1
+fi
### SETUP OTHER ENV VARIABLES ####
@@ -171,4 +175,5 @@
# Local Variables:
# tab-width: 4
+# indent-tabs-mode: t
# End:
More information about the Swift-commit
mailing list