import time
import rawsc
import rawsc.service
from rawsc import rass
import rawsc.rass.service
try:
from xml.etree import cElementTree as ElementTree
except ImportError:
try:
import cElementTree as ElementTree
except ImportError:
from elementtree import ElementTree
USER = "XXX"
PWD = "XXX"
SERVER = "rass.cdn0XXX.rambla.be"
try:
client = rawsc.rass.service.RassService(username=USER, password=PWD, server=SERVER)
feed = client.getVocabFeed()
for e in feed.entry:
print "\nVocab Entry URI: " + str(e.id.text)
print "name: " + str(e.content.params.name.text)
print "xml_namespace: " + str(e.content.params.xml_namespace.text)
print "description: " + str(e.content.params.description.text)
e = client.createVocab(name = "bigstar", xml_namespace = "http://bigstar.net/")
print "\nVocab Entry URI: " + str(e.id.text)
print "name: " + str(e.content.params.name.text)
print "xml_namespace: " + str(e.content.params.xml_namespace.text)
print "description: " + str(e.content.params.description.text)
e = client.getVocabEntry(name = "bigstar")
print "\nVocab Entry URI: " + str(e.id.text)
print "name: " + str(e.content.params.name.text)
print "xml_namespace: " + str(e.content.params.xml_namespace.text)
print "description: " + str(e.content.params.description.text)
except rawsc.service.Error, e:
print "Error Response from server, contents = %s.\n" % str(e)
error_dict = e[0]
print "status code : " + str(error_dict["status"]) + "\n"
if error_dict.has_key("body"):
print "error body : " + error_dict["body"] + "\n"
except rawsc.RawscException, e:
print "RawscException caught, reason = %s.\n" % str(e)
except StandardError, e:
print "StandardError caught, reason = %s.\n" % str(e)
except:
print "unhandled exception caught\n"