示例#1
0
	name = args['instance'].replace('/','_') + "_" + args1['instance'].replace('/', '_') + path.replace('/', '_')

	if ((op == "both") | (op == "get")) :
		#Fetch the dataset contents and save them in a file
		xmlinput = api.getDatasetInfo(path)
		f = open(name + ".xml", "w");
		f.write(xmlinput)
		f.close()
		print "Dataset information fetched from " + args['instance'] + " in XML format is saved in " + name + ".xml"

	if ((op == "both") | (op == "set")) :
		#Insert the saved contents into another DBS instance
		f = open(name + ".xml", "r");
		xmlinput = f.read()
		f.close()

		flog =  open(name + ".log", "w");
		flog.write(api1.insertDatasetInfo(xmlinput))
		flog.close()
		print "The transfer log for " + args1['instance'] + " in XML format is saved in " + name + ".log"


except DbsCgiDatabaseError,e:
   print e
except InvalidDataTier, ex:
  print "Caught InvalidDataTier API exception: %s" % (ex.getErrorMessage())
except DbsApiException, ex:
  print "Caught API exception %s: %s" % (ex.getClassName(), ex.getErrorMessage())
except DbsException, ex:
  print "Caught exception %s: %s" % (ex.getClassName(), ex.getErrorMessage())