コード例 #1
0
def indexFile(IPFSHash):
    path = IPFSGateway+IPFSHash
    req = requests.get(path)
    print("got request")
    rawText = req.text
    bloom = generateBloomFilter(tokenizeHTML(rawText))
    return bloom
コード例 #2
0
ファイル: UrClientPython3.py プロジェクト: UrDHT/UrDHTClients
def dial(subnet,target, cmd, **kwargs):

	buildURL = [target["addr"]]
	buildURL.append(subnet+"/client/")
	buildURL.append(cmd)
	buildURL.append("/")
	postData = None
	if cmd == "seek" or cmd == "get":
		buildURL.append(kwargs["id"])
	elif cmd == "poll":
		buildURL.append(kwargs["id"])
		buildURL.append("/")
		buildURL.append(str(kwargs["time"]))
	elif cmd == "post":
		buildURL.append(kwargs["id"])
		postData = kwargs["data"]
	elif cmd == "store":
		buildURL.append(kwargs["id"])
		postData = kwargs["data"]

	trgAddr = ''.join(buildURL)
	if postData is not None:
		r = requests.post(trgAddr, data=postData)
		if r.text:
			return r.json()
	else:
		r = requests.get(trgAddr)
		#print(r.text)
		if len(r.text)>0:
			if cmd == "get":
				return r.text
			else:
				return r.json()
コード例 #3
0
ファイル: NetworkClass.py プロジェクト: rvaughan/PyUrDHT
    def ping(self,remote):
        try:
            r = requests.get(remote.addr+"api/v0/peer/ping")

            return r.status_code == requests.codes.ok
        except:
            return False
コード例 #4
0
ファイル: chordnetwork.py プロジェクト: KhanChan18/PyUrDHT
    def ping(self, service, remote):
        try:
            r = requests.get(remote.addr + service + "/peer/ping")

            return r.status_code == requests.codes.ok
        except:
            return False
コード例 #5
0
def dial(subnet, target, cmd, **kwargs):

    buildURL = [target["addr"]]
    buildURL.append(subnet + "/client/")
    buildURL.append(cmd)
    buildURL.append("/")
    postData = None
    if cmd == "seek" or cmd == "get":
        buildURL.append(kwargs["id"])
    elif cmd == "poll":
        buildURL.append(kwargs["id"])
        buildURL.append("/")
        buildURL.append(str(kwargs["time"]))
    elif cmd == "post":
        buildURL.append(kwargs["id"])
        postData = kwargs["data"]
    elif cmd == "store":
        buildURL.append(kwargs["id"])
        postData = kwargs["data"]

    trgAddr = ''.join(buildURL)
    print(trgAddr)
    if postData is not None:
        r = requests.post(trgAddr, data=postData)
        if r.text:
            return r.json()
    else:
        r = requests.get(trgAddr)
        #print(r.text)
        if len(r.text) > 0:
            if cmd == "get":
                return r.text
            else:
                return r.json()
コード例 #6
0
ファイル: NetworkClass.py プロジェクト: UrDHT/PyChordUrDHT
    def ping(self,service,remote):
        try:
            r = requests.get(remote.addr+service+"/peer/ping")

            return r.status_code == requests.codes.ok
        except:
            return False
コード例 #7
0
def indexFile(IPFSHash):
    path = IPFSGateway + IPFSHash
    req = requests.get(path)
    print("got request")
    rawText = req.text
    bloom = generateBloomFilter(tokenizeHTML(rawText))
    return bloom
コード例 #8
0
ファイル: chordnetwork.py プロジェクト: KhanChan18/PyUrDHT
 def getIP(self, service, remote):
     ip = None
     try:
         r = requests.get(remote.addr + service + "/peer/getmyIP")
         ip = r.text
     except:
         raise DialFailed()
     return ip
コード例 #9
0
ファイル: NetworkClass.py プロジェクト: rvaughan/PyUrDHT
 def getIP(self,remote):
     ip = None
     try:
         r = requests.get(remote.addr+"api/v0/peer/getmyIP")
         ip = r.text
     except:
         raise DialFailed()
     return ip
コード例 #10
0
ファイル: myanalyzer.py プロジェクト: yuriy-logosha/myutils
def sentence_analyze_matxin(sentence):
    r = myrequests.get(
        "http://lindat.mff.cuni.cz/services/udpipe/api/process?tokenizer&tagger&parser&model=russian-syntagrus-ud-2.5-191206&output=matxin&data="
        + sentence)

    if r and r.status_code == 200:
        root = ET.fromstring(myjson.json.loads(r.text)['result'])
        return Result(root).childs[0].childs[0]

    return None
コード例 #11
0
ファイル: chordnetwork.py プロジェクト: KhanChan18/PyUrDHT
 def seekPoint(self, service, remote, point):
     path = remote.addr + service + "/peer/" + "seekPoint/%s" % point
     val = None
     try:
         r = requests.get(path)
         results = r.json()
         val = util.PeerInfo(results["id"], results["addr"], results["loc"])
     except Exception:
         raise DialFailed()
     return val
コード例 #12
0
ファイル: chordnetwork.py プロジェクト: UrDHT/PyUrDHT
 def seekPoint(self, service, remote, point):
     path = remote.addr + service + "/peer/" + "seekPoint/%s" % point
     val = None
     try:
         r = requests.get(path)
         results = r.json()
         val = util.PeerInfo(results["id"], results["addr"], results["loc"])
     except Exception:
         raise DialFailed()
     return val
コード例 #13
0
ファイル: chordnetwork.py プロジェクト: UrDHT/PyUrDHT
 def getSuccessors(self, service, remote):
     result = []
     try:
         r = requests.get(remote.addr + service + "/peer/getSuccessors/")
         if len(r.json()) == 0:
             return []
         for p in r.json():
             newPeer = util.PeerInfo(p["id"], p["addr"], p["loc"])
             result.append(newPeer)
     except Exception:
         raise DialFailed()
     return result
コード例 #14
0
ファイル: chordnetwork.py プロジェクト: KhanChan18/PyUrDHT
 def getPredecessor(self, service, remote):
     result = []
     try:
         r = requests.get(remote.addr + service + "/peer/getPredecessor/")
         if len(r.json()) == 0:
             return []
         for p in r.json():
             newPeer = util.PeerInfo(p["id"], p["addr"], p["loc"])
             result.append(newPeer)
     except Exception:
         raise DialFailed()
     return result
コード例 #15
0
    def proxy(websocket, path):
        cmd_text = yield from websocket.recv()
        print(cmd_text)
        cmd = json.loads(cmd_text)
        output = ""
        if cmd["method"] == "seek":
            seekarg = cmd["id"]
            newpath = ''.join((hostPath,"seek/",seekarg))
            r = requests.get(newpath)
            peer = r.json()
            peerAddr = peer["addr"]
            wsaddr = wsResolve(peerAddr)
            peer["wsAddr"] = wsaddr
            print(json.dumps(peer))
            output = json.dumps(peer)
        if cmd["method"] == "get":
            seekarg = cmd["id"]
            newpath = ''.join((hostPath,"get/",seekarg))
            r = requests.get(newpath)
            output = r.text
        if cmd["method"] == "poll":
            seekarg = cmd["id"]
            t = cmd["time"]
            newpath = ''.join((hostPath,"poll/",seekarg,"/",str(t)))
            r = requests.get(newpath)
            output = r.text
        if cmd["method"] == "store":
            seekarg = cmd["id"]
            newpath = ''.join((hostPath,"store/",seekarg))
            data = json.dumps(cmd["data"])
            r = requests.post(newpath, data=data)
            output = r.text
        if cmd["method"] == "post":
            seekarg = cmd["id"]
            newpath = ''.join((hostPath,"post/",seekarg))
            data = json.dumps(cmd["data"])
            r = requests.post(newpath, data=data)
            output = r.text

        yield from websocket.send(output)
コード例 #16
0
ファイル: myanalyzer.py プロジェクト: yuriy-logosha/myutils
def sentence_analyze(sentence):
    r = myrequests.get(
        "http://lindat.mff.cuni.cz/services/udpipe/api/process?tokenizer&tagger&parser&model=russian-syntagrus-ud-2.5-191206&data="
        + sentence)

    if r and r.status_code == 200:
        parsed = myjson.json.loads(r.text)
        return [
            line.split('\t')
            for line in parsed['result'].split('#')[4].split('\n')[1:]
        ]

    return None
コード例 #17
0
ファイル: NetworkClass.py プロジェクト: rvaughan/PyUrDHT
 def seek(self,remote,id):
     """
     This function remotely calls seek on the remote node,
     asking it to run LogicComponent.seek() on id
     """
     path = remote.addr+"api/v0/peer/"+"seek/%s" % id
     val = None
     try:
         r = requests.get(path)
         results = r.json()
         val = util.PeerInfo(results["id"],results["addr"],results["loc"])
     except Exception:
         raise DialFailed()
     return val
コード例 #18
0
ファイル: chordnetwork.py プロジェクト: KhanChan18/PyUrDHT
 def seek(self, service, remote, id):
     """
     This function remotely calls seek on the remote node,
     asking it to run LogicComponent.seek() on id
     """
     path = remote.addr + service + "/peer/" + "seek/%s" % id
     val = None
     try:
         r = requests.get(path)
         results = r.json()
         val = util.PeerInfo(results["id"], results["addr"], results["loc"])
     except Exception:
         raise DialFailed()
     return val
コード例 #19
0
ファイル: NetworkClass.py プロジェクト: rvaughan/PyUrDHT
 def getPeers(self,remote):
     result = []
     try:
         r = requests.get(remote.addr+"api/v0/peer/getPeers/")
         #print(r.text)
         #print(r.text)
         #print(r.text)
         if len(r.json()) == 0:
             return []
         for p in r.json():
             newPeer = util.PeerInfo(p["id"],p["addr"],p["loc"])
             result.append(newPeer)
     except Exception:
         raise DialFailed()
     return result
コード例 #20
0
 def crawler(self, url):
     return myrequests.get(url).content
コード例 #21
0
 def test_HTTPS_200_OK_GET(self):
     r = myrequests.get('https://www.baidu.com')
     self.assertEqual(r.status_code, 200)
コード例 #22
0
 def test_invald_url(self):
     r = myrequests.get('http://wwwwwwww')
     self.assertEqual(r, None)
コード例 #23
0
 def wsResolve(path):
     newpath = ''.join((path,"websocket/client/wsinfo"))
     print(newpath)
     r = requests.get(newpath)
     return r.text
コード例 #24
0
def test_myrequests1(url):

    for n in range(100):
        r = myrequests.get(url)
コード例 #25
0
def test_myrequests2(url):

    for n in range(100):
        r = myrequests.get(url, headers=headers)
コード例 #26
0
ファイル: 性能测试.py プロジェクト: xiaoya700/myrequests
def test_myrequests1(url):

    for n in range(100):
        r = myrequests.get(url)
        print(r.request.headers)