#
# url should be something like: "http://www.na-mic.org:8081/%s/Command/" % project
# fullfile should be something like: fullPathToDestinationXMLFile
# shortfile should be something like: xmlfile
#

def XMLRPCSubmit(url, fullfile, shortfile):
 try:
   import xmlrpclib

   server = xmlrpclib.ServerProxy(url)
   print server

   try:
     fp = open(fullfile)
     content = fp.read()
     bin = xmlrpclib.Binary(content)
     print "Server responded: [%s]" % server.Submit.put(bin)
   except Exception, v:
     print "ERROR", v
     print "Unexpected error:", sys.exc_info()
     print "The file: \"%s\" content was:\n%s" % (fullfile, content)
 except:
   print "Problem submitting XML-RPC for the file: %s" % shortfile

def XMLRPCSubmitMethod(args):
 XMLRPCSubmit(args[0], args[1], args[2])

