def stats(self, irc, msg, args, pkg): """<source package> Reports various statistics (from http://packages.qa.debian.org/) about <source package>. """ pkg = pkg.lower() pts = Binding(self._ptsUri) try: version = pts.latest_version(pkg) maintainer = pts.maintainer(pkg) bugCounts = pts.bug_counts(pkg) except ZSI.FaultException: irc.errorInvalid("source package name") version = "%s: %s" % (self.bold("Latest version"), version) mname = maintainer["name"] memail = maintainer["email"] maintainer = format("%s: %s %u", self.bold("Maintainer"), mname, utils.web.mungeEmail(memail)) bugsAll = format("%i Total", bugCounts["all"]) bugsRC = format("%i RC", bugCounts["rc"]) bugs = format("%i Important/Normal", bugCounts["in"]) bugsMinor = format("%i Minor/Wishlist", bugCounts["mw"]) bugsFixed = format("%i Fixed/Pending", bugCounts["fp"]) bugL = (bugsAll, bugsRC, bugs, bugsMinor, bugsFixed) s = ". ".join((version, maintainer, "%s: %s" % (self.bold("Bugs"), "; ".join(bugL)))) irc.reply(s)
def bug(self, irc, msg, args, bug): """<num> Returns a description of the bug with bug id <num>. """ server = Binding(self._soapUri, self._soapNs) response = server.get_status(bug) # response = {'s-gensym3': {bug1: {'date':..., ...}, bug2: ...}} status = response["s-gensym3"] if status is None: irc.error("I could not find a bug report matching that number.", Raise=True) status = status[bug] timeFormat = conf.supybot.reply.format.time() searches = ( status["package"], status["subject"], status["originator"], time.strftime(timeFormat, time.gmtime(status["date"])), ) severity = status["severity"] tags = status["tags"].split() L = map(self.bold, ("Package", "Subject", "Reported")) resp = format("%s: %%s; %s: %%s; %s: by %%s on %%s", *L) resp = format(resp, *searches) if severity: resp += format("; %s: %s", self.bold("Severity"), severity) if tags: resp += format("; %s: %L", self.bold("Tags"), tags) resp += format("; %u", self._bugUri % bug) irc.reply(resp)
def listMembers(url): Binding.defaultHttpsTransport = HTTPSConnection2 fp = open('soap_trace', 'w') b = Binding(url=url, tracefile=fp) reply = b.RPC(None, 'listMembers', [], encodingStyle="http://schemas.xmlsoap.org/soap/encoding/", replytype=TC.Any("listMembersResponse", nillable=True)) return reply['listMembersReturn']
def call_webservice(cookies): global loggeduser, session print "Trying to call webservice using SSO with obtained credentials." url = 'https://cloud-mi-03.mib.infn.it/secure/webservice.php' client = Binding(url=url) for (key, value) in cookies.items(): client.cookies[key] = value print client.oncall(loggeduser)['return']
def open_stream(self, stream): # stream is SRU style URL to be opened as SRW (transport, user, passwd, host, port, dirname, filename, args, anchor) = self._parse_url(stream) if not port: port = 80 database = os.path.join(dirname, filename) self.binding = Binding(host=host, port=port, url=database, nsdict=self.namespaces) return SRW.types.SearchRetrieveRequest('searchRetrieveRequest', opts=args)
def exercise_one(): print('<----------------Exercise 1 ------------->') url = 'http://127.0.0.1/webgoat/services/SoapRequest' binding = Binding(url=url) binding.SetAuth(AUTH.httpbasic, 'guest', 'guest') try: browser = CustomizedBrowser() browser.add_password(url, 'guest', 'guest') browser.open('http://127.0.0.1/webgoat/services/SoapRequest?WSDL') soup = BeautifulSoup(browser.response().read(), 'lxml') print("test") print(soup) except mechanize.HTTPError, response: pass
class SrwDocumentStream(HttpDocumentStream): # same as Sru, but use request object and ZSI to fetch namespaces = {} def __init__(self, session, stream, format, tagName=None, codec=None, factory=None): self.namespaces = SRW.protocolNamespaces HttpDocumentStream.__init__(self, session, stream, format, tagName, codec, factory) def open_stream(self, stream): # stream is SRU style URL to be opened as SRW (transport, user, passwd, host, port, dirname, filename, args, anchor) = self._parse_url(stream) if not port: port = 80 database = os.path.join(dirname, filename) self.binding = Binding(host=host, port=port, url=database, nsdict=self.namespaces) return SRW.types.SearchRetrieveRequest('searchRetrieveRequest', opts=args) def find_documents(self, session, cache=0): docs = [] curr = 1 while True: self.stream.startRecord = curr resp = self.binding.RPC( self.binding.url, "searchRetrieveRequest", self.stream, requestclass=SRW.types.SearchRetrieveRequest, replytype=SRW.types.SearchRetrieveResponse.typecode, readerclass=reader) total = resp.numberOfRecords curr += len(resp.records) for d in resp.records: doc = StringDocument(d.recordData, mimeType='text/xml') doc.recordSchema = d.recordSchema if cache == 0: yield doc elif cache == 2: docs.append(doc) else: raise NotImplementedError if curr > total: if cache == 0: raise StopIteration else: break self.documents = docs
from Bio.SwissProt import SProt except: sys.stderr.write( "Can't import Bio.SwissProt.SProt. You need Biopython 1.55 to use this, or set USE_BIOPYTHON_SPROT_PARSER=False to use the Uniprot web service instead." ) if USE_ZSI: from ZSI.client import Binding else: import SOAPpy fh = open(sys.argv[1], 'rU') seqs = SeqIO.parse(fh, "fasta") if USE_ZSI: server = Binding(url='', host='localhost', port=8999) else: server = SOAPpy.SOAPProxy("http://localhost:8999/") #def get_lineage_code(species, kingdoms=KINGDOMS): # lineage = server.getLineage(species) # for l in lineage: # for n in l: # #print "----------------" # for x in n: # if x in kingdoms: # return kingdoms[x] # return None def uniprotParseSpecies(record):
#!/usr/bin/python # # This uses the Python ZSI SOAP Infrastructure from: http://pywebsvcs.sourceforge.net/ # import sys; from ZSI.client import Binding; #soapclient = Binding(url='/phpgacl/soap/server.php', host='hubcap.netnation.com', tracefile=sys.stdout); soapclient = Binding(url='/phpgacl/soap/server.php', host='hubcap.netnation.com'); def acl_check(aco_section_value, aco_value, aro_section_value, aro_value, axo_section_value=0, axo_value=0, root_aro_group_id=0, root_axo_group_id=0): return soapclient.acl_check(aco_section_value, aco_value, aro_section_value, aro_value, axo_section_value, axo_value, root_aro_group_id, root_axo_group_id); if ( acl_check('system','login','users','john_doe') ): print "John Doe has been granted access to login!<br>\n"; else: print "John Doe has been denied access to login!<br>\n";
import time, sys #Import the ZSI client from ZSI.client import Binding from ZSI import TC tracefile = None #Set to sys.sysout to see debugging print "Connecting to server" start = time.time() b = Binding(url='', ns='', host='localhost', port=8888, tracefile=tracefile) end = time.time() print "Time to connect to server, %f" % (end - start) print print "Sending a long string to the server" st = "This is a test string" * 1000 start = time.time() b.receiveLargeString(st) end = time.time() print "Time to send a string of %d chars, %f" % (len(st), end - start) print print "Recieving a long stirng from the server" start = time.time() res = b.sendLargeString() end = time.time() print "Time to receive a string of %d chars, %f" % (len(res), end - start) print print "Sending lots of ints to the server"
import time, sys #Import the ZSI client from ZSI.client import Binding from ZSI import TC tracefile = None #Set to sys.sysout to see debugging print "Connecting to server" start = time.time() b = Binding(url='', ns='', host='localhost', port=8888,tracefile=tracefile) end = time.time() print "Time to connect to server, %f" % (end-start) print print "Sending a long string to the server" st = "This is a test string" * 1000 start = time.time() b.receiveLargeString(st) end = time.time() print "Time to send a string of %d chars, %f" % (len(st),end-start) print print "Recieving a long stirng from the server" start = time.time() res = b.sendLargeString() end = time.time() print "Time to receive a string of %d chars, %f" % (len(res),end-start) print
def __getattr__(self, attr): soap_callable = Binding.__getattr__(self, attr) return SFACallable(soap_callable)
import sys #Import the ZSI client from ZSI.client import Binding u = 'http://127.0.0.1:8080' n = '' b = Binding(url=u, ns=n, host='127.0.0.1', port=8080) #result = b.getMonth(2002, 2) #print result[0] result = b.getYear(2002) print result[0]
# taxon_server.py SOAP server running to interegate the taxonomy database. from taxon_config import * import sys from Bio import SeqIO if USE_ZSI: from ZSI.client import Binding else: import SOAPpy fh = open(sys.argv[1], 'rU') seqs = SeqIO.parse(fh, "fasta") if USE_ZSI: server = Binding(url='', host='localhost', port=8999) else: server = SOAPpy.SOAPProxy("http://localhost:8999/") #def get_lineage_code(species, kingdoms=KINGDOMS): # lineage = server.getLineage(species) # for l in lineage: # for n in l: # #print "----------------" # for x in n: # if x in kingdoms: # return kingdoms[x] # return None for s in seqs: try:
#!/usr/local/bin/python from ZSI.client import Binding fp = open('debug.out', 'a') b = Binding(url='http://localhost:7000/simple-test', tracefile=fp) fp.close() a = b.average(range(1,11)) assert a == 5 print b.hello()
import time, sys #Import the ZSI client from ZSI.client import Binding from ZSI import TC tracefile = None #Set to sys.sysout to see debugging print "Connecting to server" b = Binding(url='', ns='', host='localhost', port=8888,tracefile=tracefile) print "Sending a long string to the server" st = "T" * 1000 b.receiveLargeString(st) print "Check File size and restart tcpdump." raw_input("Press Any Key to go on") print "Sending lots of ints to the server" NUM = 100 for ctr in range(NUM): b.receiveInt(1) print "Done"