def __call__(self, *args, **kw): if self._name == "_": if self.__name in ["__repr__", "__str__"]: return self.__repr__() else: chain = [] parent = self._parent while parent._parent: chain = [parent._name] + chain parent = parent._parent url = parent._icontrol_url % parent.__dict__ ns = parent._icontrol_ns + ':' + '/'.join(chain) if parent._url_params: url = "%s?%s" % (url, urllib.urlencode(parent._url_params)) parent._cache.clear() p = parent if p._cache.get(ns) is not None: ic = p._cache[ns] else: if parent._session: headers = SOAPpy.Types.headerType() sess_t = SOAPpy.Types.integerType(parent._session) sess_t._setMustUnderstand(0) sess_t._setAttr('xmlns:myns1', parent._icontrol_ns) headers._addItem('myns1:session', sess_t) ic = SOAPpy.SOAPProxy(url, ns, header=headers, timeout=p.timeout) else: ic = SOAPpy.SOAPProxy(url, ns, timeout=p.timeout) p._cache[ns] = ic #ic.config.debug = p._debug ic.simplify_objects = 1 try: # An ugly way of setting the timeout per socket, but it # seems that SOAPpy is ignoring the timeout parameter set in # the SOAPProxy constructor. before = socket.getdefaulttimeout() socket.setdefaulttimeout(p.timeout) if p._debug: LOG.debug( "%s -> %s.%s(%s)", url, '.'.join(chain), self._name, ', '.join( ['%s=%s' % (x, y) for x, y in kw.items()])) ret = getattr(ic, self._name)(*args, **kw) if p._debug: LOG.debug(ret) return ret except SOAPpy.Types.faultType, e: if 'Unknown method' in e.faultstring: raise UnknownMethod(e) raise IControlFault(e) except SOAPpy.Errors.HTTPError, e: if 401 == e.code: raise AuthFailed(e) raise IControlTransportError(e)
def GetServiceConnection(headers, config, url, http_proxy, is_jaxb_api): """Get SOAP service connection. Args: headers: dict Dictionary object with populated authentication credentials. config: dict Dictionary object with populated configuration values. url: str URL of the web service to call. http_proxy: str HTTP proxy to use. is_jaxb_api: bool Whether API uses JAXB. Returns: instance SOAPpy.SOAPProxy with set headers. """ # Catch empty SOAP header elements and exclude them from request. full_headers = {} for key in headers: if headers[key]: full_headers[key] = headers[key] if is_jaxb_api or Utils.BoolTypeConvert(config['wsse']): headers = SOAPpy.Types.headerType( {config['ns_target'][1]: full_headers}) headers._setAttr('xmlns', config['ns_target'][0]) service = SOAPpy.SOAPProxy(url, http_proxy=http_proxy, header=headers, transport=HTTPTransportHandler) service.transport.data_injects = config['data_injects'] elif Utils.BoolTypeConvert(config['force_data_inject']): service = SOAPpy.SOAPProxy(url, http_proxy=http_proxy, header=headers, transport=HTTPTransportHandler) service.transport.data_injects = config['data_injects'] else: headers = SOAPpy.Types.headerType(full_headers) service = SOAPpy.SOAPProxy(url, http_proxy=http_proxy, header=headers) service.config.dumpHeadersIn = 1 service.config.dumpHeadersOut = 1 service.config.dumpSOAPIn = 1 service.config.dumpSOAPOut = 1 # Turn off type information, since SOAPpy usually gets the types wrong. service.config.typed = 0 # Turn on noroot, to skip including "SOAP-ENC:root" as part of the request. service.noroot = 1 # Explicitly set the style of the namespace, otherwise will default to 1999. service.config.namespaceStyle = '2001' # Set up OAuth, if applicable. if 'oauth_enabled' in config and config['oauth_enabled']: service.transport.oauth_enabled = True service.transport.oauth_handler = config['oauth_handler'] service.transport.oauth_credentials = config['oauth_credentials'] return service
def __init__(self, url, user=None, passwd=None): if user is None: self.server = SOAPpy.SOAPProxy(url) else: self.server = SOAPpy.SOAPProxy(url, transport=HTTPHeaderTransport, namespace=self.namespace) self.server.transport.headers = { 'Username': user, 'Password': passwd }
def main(): global generator generator = SOAPpy.SOAPProxy(URL, namespace=NS) for tracking_number in get_batch(generator.next_tracking_number_set): print pretty_tracking_number(tracking_number)
def testSpyneHelloExample(self): tns = 'spyne.examples.hello.soap' binding = self.createBinding(tns, HelloWorldService) self.commit() result, = SOAPpy.SOAPProxy(binding.absolute_url()).say_hello( name=u'Jérôme', times=5) self.assertEqual(result, [u'Hello, Jérôme'] * 5)
def __init__(self,tenant_index=0,tenant_name=None): self.tenant_index = int(tenant_index) self.tenant_name = "default" if tenant_name: self.tenant_name = tenant_name self.cert_file = '/etc/smithproxy/certs/default/srv-cert.pem' self.key_file = '/etc/smithproxy/certs/default/srv-key.pem' self.context = SSL.Context() self.context.load_cert(self.cert_file,keyfile=self.key_file) self.service_port = 65000 + self.tenant_index self.bend_port = 64000 + self.tenant_index self.l_server = SOAPpy.ThreadingSOAPServer(("0.0.0.0", self.service_port),ssl_context = self.context) self.r_server = SOAPpy.SOAPProxy("http://localhost:%d/" % (self.bend_port,)) self.l_server.registerFunction( SOAPpy.MethodSig(self.ping, keywords=0, context=1) ) self.l_server.registerFunction( SOAPpy.MethodSig(self.whoami, keywords=0, context=1) ) self.l_server.registerFunction( SOAPpy.MethodSig(self.authenticate, keywords=0, context=1) ) self.l_server.registerFunction( SOAPpy.MethodSig(self.admin_login, keywords=0, context=1) ) self.l_server.registerFunction( SOAPpy.MethodSig(self.admin_token_list, keywords=0, context=1) ) self.l_server.registerFunction( SOAPpy.MethodSig(self.admin_keepalive, keywords=0, context=1) ) self.l_server.registerFunction( SOAPpy.MethodSig(self.admin_logout, keywords=0, context=1) ) self.create_logger() self.load_config()
def __init__(self, name, parentIP="127.0.0.1", parentPort=9559, brokerIP="127.0.0.1", brokerPort=0): if brokerPort == 0: raise ALError( "ALBoker Python", "no port defined", "A port number must be specify to launch the python broker.") self.name = name self.ip = brokerIP self.port = brokerPort self.parentIP = parentIP self.parentPort = parentPort # Connect to the parent broker endpoint = parentIP + ":" + str(parentPort) print "endpoint of the broker : " + endpoint parentBroker = SOAPpy.SOAPProxy(endpoint) # create info of this broker self.brokerInfo = ALModuleInfo() self.brokerInfo.processId = -1 self.brokerInfo.name = self.name self.brokerInfo.ip = self.ip self.brokerInfo.port = self.port self.brokerInfo.modulePointer = 0 # JM 19/01/08 : OS is specify here as "other", in the future we can specify the current os, is it usefull ? self.brokerInfo.architecture = 3 self.brokerInfo.isABroker = 1 print "register Broker" parentBroker._ns("urn:albroker").registerBroker(self.brokerInfo, 1) threading.Thread.__init__(self)
def _Dynamic_GetPresence(self, request, response): """Implementation of XmppService::GetPresence. Reads the file containing the list of online users to see if the given user is online or not. Args: request: A PresenceRequest. response: A PresenceResponse. """ appname = os.environ['APPNAME'] xmpp_username = appname + "@" + self.xmpp_domain jid = request.jid() server = SOAPpy.SOAPProxy(self.login) online_users = server.get_online_users_list(self.uasecret) user_is_online = False try: online_users.index(jid) user_is_online = True except ValueError: pass response.set_is_available(user_is_online)
def is_user_capable(user, api_name): user = urllib.unquote(user) sys.stderr.write("checking permissions for user " + user + " on api " + api_name + "\n") secret_file = open('/etc/appscale/secret.key', 'r') secret = secret_file.read() secret = secret[0:-1] secret_file.close() uaserver_file = open('/etc/appscale/hypersoap', 'r') uaserver = uaserver_file.read() # uaserver = uaserver[0:-1] # no newline on this file uaserver_file.close() #sys.stderr.write("will create a connection to https://" + uaserver + ":4343\n") server = SOAPpy.SOAPProxy("https://" + uaserver + ":4343") capabilities = server.get_capabilities(user, secret) # if a non-existant user was specified this will be ['DB_ERROR', 'no user'] # instead of a string with their capabilities if not isinstance(capabilities, str): return False capabilities = capabilities.split(":") sys.stderr.write("user " + user + " has the following capabilities: " + str(capabilities) + "\n") if api_name in capabilities: return True else: return False
def __init__(self, options): # on definit les parametres de connection au blog self.xmlrpcserver = options.xmlrpcserver self.blogid = options.blogid self.user = options.bloguser self.password = options.blogpass self.category_nbr = options.blogcategory #if you want accept comment, replace False by True self.comment = False #or ping self.ping = False self.category = [{'isPrimary': True, "categoryId": self.category_nbr}] self.error = "" self.log = "" self.idrecord = options.idrecord self.webserviceserver = SOAPpy.SOAPProxy("http://localhost:8081/") #we try the connection to the xml/rpc server try: self.connect = xmlrpclib.Server(self.xmlrpcserver) self.error = False except: print("can't connect the server")
def main(): global generator generator = SOAPpy.SOAPProxy(URL, namespace=NS) for mcid in get_batch(generator.next_mcid_set): print pretty_mcid(mcid)
def get_all_stats(): """ Collects platform stats from all deployment nodes. Returns: A dictionary containing all the monitoring stats, if all nodes are accessible. {"success": False, "error": message} otherwise. """ all_stats = {} secret = appscale_info.get_secret() logging.debug("Retrieved deployment secret: {}".format(secret)) for ip in appscale_info.get_all_ips(): appcontroller_endpoint = "https://{}:{}".format( ip, hermes_constants.APPCONTROLLER_PORT) logging.debug("Connecting to AC at: {}".format(appcontroller_endpoint)) # Do a SOAP call to the AppController on that IP to get stats. server = SOAPpy.SOAPProxy(appcontroller_endpoint) try: all_stats[ip] = server.get_all_stats(secret) except SOAPpy.SOAPException as soap_exception: logging.exception("Exception while performing SOAP call to " "{}".format(appcontroller_endpoint)) logging.exception(soap_exception) all_stats[ip] = {JSONTags.ERROR: JSONTags.UNREACHABLE} except socket_error as serr: logging.error("Socket error while performing SOAP call to " "{}".format(appcontroller_endpoint)) logging.error(serr) all_stats[ip] = {JSONTags.ERROR: JSONTags.UNREACHABLE} return all_stats
def handle_urban_verifykey(bot, ievent): server = SOAPpy.SOAPProxy(cfg.data['url']) result = server.verify_key(cfg.data['key']) if result: ievent.reply("License key is valid") else: ievent.reply("License key is invalid")
def connexion_SOAP(self): '''Création du client SOAP, connexion au serveur''' serveur_soap = variables.SERVEUR_SOAP print "Serveur:", serveur_soap if variables.version_dev == 1: serveur_soap = serveur_soap + "/djl_dev.php" else: serveur_soap = serveur_soap + "/djl.php" self.clientSOAP = SOAPpy.SOAPProxy(serveur_soap) self.clientSOAP.config.dict_encoding = "utf8" self.clientSOAP.config.debug = 0 self.clientSOAP.config.dumpSOAPIn = 0 self.clientSOAP.config.dumpSOAPOut = 0 try: self.maj_depot() # print "Ok on a le dépôt" #temp1 except (SOAPpy.Errors.HTTPError, socket.error), x: # Si ça merde, c'est qu'on a pas de dépôt accessible en ligne, on affiche # donc rien dans le dépot print "Problème chargement du dépôt:", x self.liste_genre = [] self.liste_jeux = [] self.nb_jeux = 0 self.charge_depot() # Charge le dépôt en dur return
def __init__(self, key, proxy=None): """Get a new google search thing.""" self.server = SOAPpy.SOAPProxy("http://api.google.com/search/beta2", namespace='urn:GoogleSearch', http_proxy=proxy) self.key = key self.results = None
def connect(self, wsdl_url): """ Connecting to wiki @param wsdl_url: WSDL """ self.wsdl_url = wsdl_url self.server = SOAPpy.SOAPProxy(self.wsdl_url) self.wsdl = SOAPpy.WSDL.Proxy(self.wsdl_url)
def __init__(self, soapPort, soapProxy, espmlFile): """ Initialize the SOAP system server and add the functions it supports to it. """ self._server = SOAPpy.SOAPServer(("", soapPort)) self._server.registerFunction(self.execute) self._registry = SOAPpy.SOAPProxy(soapProxy) self._registerSystem(espmlFile)
def getSoap(self, url, port, path): logger.info("getSOAP is running") try: url = "http://"+str(url)+":"+str(port)+"/"+str(path) soap = SOAPpy.SOAPProxy(url) return soap except Exception as e: logger.info("fail to create the SOAP: %s"%(str(e))) return None
def connect(self): """Get a handle to a remote connection.""" # TODO: # * transport (http) level authentication using self._user_name and # self._password. # * support calling from restricted environment. url = self.url proxy = SOAPpy.SOAPProxy(url) return proxy
def get_soap_accessor(): """ Returns the SOAP server accessor to deal with application and users. Returns: A soap server accessor. """ db_ip = appscale_info.get_db_master_ip() bindport = constants.UA_SERVER_PORT return SOAPpy.SOAPProxy("https://{0}:{1}".format(db_ip, bindport))
def __init__(self, url, port=80): if SOAPPY_AVAILABLE: proxy = SOAPpy.SOAPProxy('http://' + url + ':' + str(port)) else: proxy = None msg = "The optional library 'SOAPpy' is not available. The communications between different servers will not work through SOAP. Since the client is being instanciated, there will probably be uncommon errors." print >> sys.stderr, msg log.log(self, log.level.Error, msg) clientSkel.__init__(self, proxy)
def __init__(self): self.system = SOAPpy.SOAPProxy("http://localhost:8081") espmlFile = "sos_function.xml" espmlDocObject = espml.parse(espmlFile) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) r = self.system.execute(espmlDocXml.getvalue()) print r
def __create_soap_proxy(self, url): if not '://' in url: url = 'http://' + url if url.lower().startswith('https://'): import ssl ssl._create_default_https_context = ssl._create_unverified_context self._url = url return SOAPpy.SOAPProxy(url.rstrip('/') + '/SOAP', namespace='http://services.vdom.net/VDOMServices')
def get_uaserver(self): """ Retrieves our saved UserAppServer connection, creating a new one if none currently exist. Returns: An SOAPpy object, representing a connection to the UserAppServer. """ if self.uaserver is None: self.uaserver = SOAPpy.SOAPProxy('https://{0}:{1}'.format( UA_SERVER_IP, self.UA_SERVER_PORT)) return self.uaserver
def main(): global outfile input_id = sys.argv[1] output_file_name = sys.argv[2] server = SOAPpy.SOAPProxy("http://www.pdb.org/pdb/services/pdbws") output_line = get_pdb_struc2D( input_id, server ) write_output_struc2D( output_line, output_file_name )
def __init__(self, host, secret): """Creates a new AppControllerClient. Args: host: The location where an AppController can be found. secret: A str containing the secret key, used to authenticate this client when talking to remote AppControllers. """ self.host = host self.server = SOAPpy.SOAPProxy('https://{0}:{1}'.format(host, self.PORT)) self.secret = secret
def __init__(self, host, secret): """Creates a new UserAppClient. Args: host: The location where an UserAppClient can be found. secret: A str containing the secret key, used to authenticate this client when talking to remote UserAppServers. """ self.host = host self.server = SOAPpy.SOAPProxy('https://%s:%s' % (host, self.PORT)) self.secret = secret
def benchmark_wam1(url): """ Benchmark PDF WAM implementation 1 for the time it takes to perform the operation """ print "Benchmarking PDF-WAM1 (SOAPpy) using", url proxy = SOAPpy.SOAPProxy('http://loft2492.serverloft.com:8893', 'eGovMon') with bench.bench('getPDFContent'): proxy.getPDFContent(url) with bench.bench('checkacc'): proxy.checkacc(url)
def notify_master(host='http://localhost:8088/', message="done", data=None): # p = SOAPpy.SOAPProxy(host) # try: # p.done(results="") # except AttributeError: # pass p = SOAPpy.SOAPProxy(host) try: p.done(results=data) except AttributeError: pass
def __init__(self, *args, **kwargs): self.session_id = None if 'server' in kwargs: server = kwargs['server'] del kwargs['server'] else: server = "http://127.0.0.1:8888" self.grobot_server = SOAPpy.SOAPProxy(server) self.session_id = self.grobot_server.create_robot(*args, **kwargs)