Here are the examples of the python api urllib.request.urlopen.read taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_list_pistas(self):
"""
Lista pistas DB
"""
call = '/list/pistas'
response = urllib.request.urlopen(URL_BASE + call).read()
# for file in response.split('\n'):
# print(file)
self.astertNotEqual(response.find("1288.ogg"), -1)
self.astertNotEqual(response.find("795.ogg"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_pista_search(self):
"""
Search query
"""
call = '/search/bast/10'
response = urllib.request.urlopen(URL_BASE + call).read()
# print(response)
self.astertNotEqual(response.find("10 resultados"), -1)
call = '/search/clarinete/10'
response = urllib.request.urlopen(URL_BASE + call).read()
# print(response)
self.astertNotEqual(response.find("10 resultados"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_get_pista_info(self):
"""
Getinfo de la pista (json)
"""
call = '/pistas/126'
response = urllib.request.urlopen(URL_BASE + call).read()
#print(response)
self.astertNotEqual(response.find("audio"), -1)
self.astertNotEqual(response.find("desc"), -1)
self.astertNotEqual(response.find("126"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_pista_descriptor(self):
"""
Get full json desc by id
"""
#WARNING: descriptor not in the repo, run mir yyyysis first to generate json file (WARNING)
call = '/pistas/76/descriptor' #id 76 (no existente en la DB) retorna 404
try:
response = urllib.request.urlopen(URL_BASE + call).read()
except Exception as e:
self.astertNotEqual(str(e).find("Error 404"), -1)
call = '/pistas/126/descriptor' # id 126 (existente, retorna json)
response = urllib.request.urlopen(URL_BASE + call).read()
self.astertNotEqual(response.find("lowlevel.dissonance.mean"), -1)
self.astertNotEqual(response.find("sfx.inharmonicity.mean"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_mir_samples_duration_greater(self):
""" Duration > 2 seg """
call = '/search/mir/samples/duration/greaterthan/2000/11' #max 10 results
response = urllib.request.urlopen(URL_BASE + call).read()
self.astertNotEqual(response.find("982_sample3.wav"), -1)
self.astertNotEqual(response.find("795_sample0.wav"), -1)
self.astertNotEqual(response.find("126_sample1.wav"), -1)
self.astertNotEqual(response.find("983_sample3.wav"), -1)
self.astertNotEqual(response.find("983_sample2.wav"), -1)
self.astertNotEqual(response.find("984_sample4.wav"), -1)
self.astertNotEqual(response.find("1288_sample3.wav"), -1)
self.astertNotEqual(response.find("982_sample0.wav"), -1)
self.astertNotEqual(response.find("982_sample3.wav"), -1)
self.astertNotEqual(response.find("126_sample3.wav"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_last_5_searchs(self):
"""
Search last results
"""
call = '/search/last/5'
response = urllib.request.urlopen(URL_BASE + call).read()
# print(response)
self.astertNotEqual(response.find("últimas 5"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_get_pista_file_path_audio(self):
"""
Get audio file path by ID
"""
call = '/pistas/126/audio'
response = urllib.request.urlopen(URL_BASE + call).read()
#print(response)
self.astertNotEqual(response.find("126"), -1)
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_search_mir_desc_less_than(self):
"""
Search by HFC <1 (5 results)
"""
call = '/search/mir/samples/HFC/lessthan/1000/5'
response = urllib.request.urlopen(URL_BASE + call).read()
# print(response)
self.astertNotEqual(response.find("126_sample2.wav"), -1)
self.astertEqual( 6, count_response_lines(response) )
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_list_samples(self):
"""
Lista samples DB
"""
call = '/list/samples'
response = urllib.request.urlopen(URL_BASE + call).read()
3
View Complete Implementation : Test_API.py
Copyright GNU General Public License v3.0
Author : sonidosmutantes
Copyright GNU General Public License v3.0
Author : sonidosmutantes
def test_mir_samples_hfc_greater(self):
""" HFC > 40. """
call = '/search/mir/samples/HFC/greaterthan/40000/5' #max 5 results
response = urllib.request.urlopen(URL_BASE + call).read()
self.astertNotEqual(response.find("984_sample4.wav"), -1)
self.astertNotEqual(response.find("984_sample1.wav"), -1)