예제 #1
0
def MUSE_mapping_to_KR_precomputed(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    cli = JSONWSPClient(url)
    result = cli.mapping_to_KR_precomputed(SRL=data)

    return {'mapping': result.response_dict['result']}
예제 #2
0
def MUSE_mapping_to_KR_precomputed(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    cli = JSONWSPClient(url)
    result = cli.mapping_to_KR_precomputed(SRL=data)

    return {'mapping': result.response_dict['result']}
예제 #3
0
def MUSE_mapping_to_KR_precomputed_latest(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    cli = JSONWSPClient(url)
    result = cli.mapping_to_KR_precomputed_latest(SRL=data)
    mapping, xml = result.response_dict['result']

    return {'mapping': mapping, 'xml': xml}
예제 #4
0
def MUSE_semantic_role_labeling(input_dict):
    url = input_dict['url']
    data = input_dict['xml']

    cli = JSONWSPClient(url)
    result = cli.semantic_role_labeling(xml=data)
    srl, txt = result.response_dict['result']

    return {'xml': srl, 'txt': txt}
예제 #5
0
def MUSE_semantic_role_labeling(input_dict):
    url = input_dict['url']
    data = input_dict['xml']

    cli = JSONWSPClient(url)
    result = cli.semantic_role_labeling(xml=data)
    srl, txt = result.response_dict['result']

    return {'xml': srl, 'txt': txt}
예제 #6
0
def MUSE_mapping_to_KR_latest(input_dict):
    url = input_dict['url']
    data = input_dict['input_data']

    import socket
    cli = JSONWSPClient(url)
    socket.setdefaulttimeout(None)
    result = cli.mapping_to_KR_latest(SRL=data)
    mapping, xml = result.response_dict['result']
    return {'mapping': mapping, 'xml': xml}
예제 #7
0
def MUSE_PG_preprocessing(input_dict):
    text = input_dict['text']
    url = input_dict['url']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_preprocessing(text=text)
    result = result.response_dict['result']
    return {'structure': result[0], 'tokens': result[1]}
예제 #8
0
def MUSE_event_temprel_detection(input_dict):
    text = input_dict['text']
    url = input_dict['url']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.event_temprel_detection(text=text)
    result = result.response_dict['result']
    return {'xml': result}
예제 #9
0
def MUSE_preprocessing(input_dict):
    url = input_dict['url']
    text = input_dict['text']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.preprocessing(text=text)
    tokens = result.response_dict['result']
    return {'tokens': tokens}
예제 #10
0
def MUSE_coreference(input_dict):
    url = input_dict['url']
    tokens = input_dict['tokens']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.coreference(tokens=tokens)
    corefs = result.response_dict['result']
    return {'coreferences': corefs}
예제 #11
0
파일: library.py 프로젝트: xflows/textflows
def MUSE_event_temprel_detection(input_dict):
    text = input_dict['text']
    url = input_dict['url']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.event_temprel_detection(text=text)
    result = result.response_dict['result']
    return {'xml': result}
예제 #12
0
def MUSE_SRL(input_dict):
    url = input_dict['url']
    tokens = input_dict['tokens']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.SRL(tokens=tokens)
    srl = result.response_dict['result']
    return {'srl': srl}
예제 #13
0
파일: library.py 프로젝트: xflows/textflows
def MUSE_coreference(input_dict):
    url = input_dict['url']
    tokens = input_dict['tokens']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.coreference(tokens=tokens)
    corefs = result.response_dict['result']
    return {'coreferences': corefs}
예제 #14
0
def MUSE_PG_event_temprel_detection(input_dict):
    url = input_dict['url']
    preproc = input_dict['preproc'].strip()

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_event_temprel_detection(preprocessed=preproc)
    result = result.response_dict['result']
    return {'xml': result}
예제 #15
0
def testCalculator():

	global base_url
	print("\n\nTesting Calculator:\n")
	# Load the Calculator description
	
	calc_client = JSONWSPClient(base_url + '/Calculator/jsonwsp/description')

	# Add the numbers 23 and 45
	jsonwsp_resp = calc_client.add(a=23,b=45)
	return print_result(jsonwsp_resp)
예제 #16
0
파일: library.py 프로젝트: xflows/textflows
def MUSE_preprocessing(input_dict):
    url = input_dict['url']
    text = input_dict['text']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.preprocessing(text=text)
    tokens = result.response_dict['result']
    return {'tokens': tokens}
예제 #17
0
def testCalculator():

    global base_url
    print("\n\nTesting Calculator:\n")
    # Load the Calculator description

    calc_client = JSONWSPClient(base_url + '/Calculator/jsonwsp/description')

    # Add the numbers 23 and 45
    jsonwsp_resp = calc_client.add(a=23, b=45)
    return print_result(jsonwsp_resp)
예제 #18
0
파일: library.py 프로젝트: xflows/textflows
def MUSE_prepare_mapping(input_dict):
    url = input_dict['url']
    srlp = input_dict['srlp']
    quots = input_dict['quots']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.prepare_for_mapping(srlpronouns=srlp, quotations=quots)
    imapping = result.response_dict['result']
    return {'imapping': imapping}
예제 #19
0
def MUSE_PG_GDEE_text(input_dict):
    url = input_dict['url']
    text = input_dict['text']
    lang = input_dict['lang']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_GDEE_text(text=text, lang=lang)
    result = result.response_dict['result']
    return {'xml': result}
예제 #20
0
def MUSE_PG_GDEE_path(input_dict):
    url = input_dict['url']
    path = input_dict['path']
    lang = input_dict['lang']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_GDEE_path(path=path, lang=lang)
    result = result.response_dict['result']
    return {'xml': result}
예제 #21
0
def MUSE_prepare_mapping(input_dict):
    url = input_dict['url']
    srlp = input_dict['srlp']
    quots = input_dict['quots']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.prepare_for_mapping(srlpronouns=srlp, quotations=quots)
    imapping = result.response_dict['result']
    return {'imapping': imapping}
예제 #22
0
def MUSE_semantic_role_labeling_tuk(input_dict):
    url = input_dict['url']
    data = input_dict['xml']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.semantic_role_labeling_tuk(xml=data)
    srl, txt = result.response_dict['result']

    return {'xml': srl, 'txt': txt}
예제 #23
0
파일: library.py 프로젝트: xflows/textflows
def MUSE_pronoun_resolution(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    entities = input_dict['entities'].replace(' ', '')

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.pronoun_resolution(srl=srl, coref=coref, entities=entities)
    srlp = result.response_dict['result']
    return {'srlpronouns': srlp}
예제 #24
0
def MUSE_directspeech(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    entities = input_dict['entities'].replace(' ', '')

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.direct_speech(srl=srl, coref=coref, entities=entities)
    dspeech = result.response_dict['result']
    return {'directspeech': dspeech}
예제 #25
0
def MUSE_pronoun_resolution(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    entities = input_dict['entities'].replace(' ', '')

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.pronoun_resolution(srl=srl, coref=coref, entities=entities)
    srlp = result.response_dict['result']
    return {'srlpronouns': srlp}
예제 #26
0
def testAlbumService():

	print("\n\nTesting AlbumService:\n")
	# Load the AlbumService description
	album_client = JSONWSPClient(base_url + '/AlbumService/jsonwsp/description')

	# Fetch albums containing the substring "Zoo" in the album title
	jsonwsp_resp = album_client.listAlbums(search_frase='Bowie')
	print_result(jsonwsp_resp)

	# Fetch all bands containing the substring "Bowie" in the band name
	jsonwsp_resp = album_client.listBands(search_frase='Bowie')
	print_result(jsonwsp_resp)
예제 #27
0
파일: library.py 프로젝트: xflows/textflows
def MUSE_directspeech(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    entities = input_dict['entities'].replace(' ', '')

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.direct_speech(srl=srl, coref=coref, entities=entities)
    dspeech = result.response_dict['result']
    return {'directspeech': dspeech}
예제 #28
0
def testAlbumService():

    print("\n\nTesting AlbumService:\n")
    # Load the AlbumService description
    album_client = JSONWSPClient(base_url +
                                 '/AlbumService/jsonwsp/description')

    # Fetch albums containing the substring "Zoo" in the album title
    jsonwsp_resp = album_client.listAlbums(search_frase='Bowie')
    print_result(jsonwsp_resp)

    # Fetch all bands containing the substring "Bowie" in the band name
    jsonwsp_resp = album_client.listBands(search_frase='Bowie')
    print_result(jsonwsp_resp)
예제 #29
0
def MUSE_PG_mappingVWR(input_dict):
    url = input_dict['url']
    srl = input_dict['srl']
    coref = input_dict['coref']
    info = input_dict['info']
    events = input_dict['events']

    import socket
    socket.setdefaulttimeout(None)

    cli = JSONWSPClient(url)
    result = cli.PG_mappingVWR(srl=srl, coref=coref, info=info, events=events)
    mapping = result.response_dict['result']

    return {'mapping': mapping}
예제 #30
0
def testTransferService():
    global files_dir, download_dir

    print("\n\nTesting TransferService:\n")
    # Load the TransferService description
    transfer_client = JSONWSPClient(base_url +
                                    '/TransferService/jsonwsp/description')

    # File list for the upload() call
    file_list = []
    # list of file names fot the download() call
    name_list = []

    # Get a list of files in the "files" folder
    files = os.listdir(files_dir)
    for f in files:
        fpath = os.path.join(files_dir, f)
        # Check if the entry is a file
        if os.path.isfile(fpath):
            # Add the file as a TransferService.File object (for the upload() call)
            file_list += [{
                'data':
                open(fpath, 'rb'),  # Attach the file using an open file-handle
                'name': f  # The file name
            }]

            # Add the file name to the list of file names (for the download() call)
            name_list += [f]

    # Upload multiple files (all files found in the "files" directory) in one request
    jsonwsp_resp = transfer_client.upload(incomming=file_list)
    print_result(jsonwsp_resp)

    # Download all the files we just uploaded in one request
    jsonwsp_resp = transfer_client.download(names=name_list)
    print_result(jsonwsp_resp)

    # The attachments are referenced as open file-handles in the response object
    # read their content and save it as files in the "download" folder.
    if jsonwsp_resp.status == 200:
        for f in jsonwsp_resp.response_dict['result']:
            print(f)
            fp = open(os.path.join(download_dir, f['name']), 'wb')
            fp.write(f['data'].read())
            fp.close()
예제 #31
0
def testTransferService():
	global files_dir, download_dir

	print("\n\nTesting TransferService:\n")
	# Load the TransferService description
	transfer_client = JSONWSPClient(base_url + '/TransferService/jsonwsp/description')

	# File list for the upload() call
	file_list = []
	# list of file names fot the download() call
	name_list = []
	
	# Get a list of files in the "files" folder
	files = os.listdir(files_dir)
	for f in files:
		fpath = os.path.join(files_dir,f)
		# Check if the entry is a file
		if os.path.isfile(fpath):
			# Add the file as a TransferService.File object (for the upload() call)
			file_list += [ {
				'data': open(fpath,'rb'), # Attach the file using an open file-handle
				'name': f                 # The file name
			} ]
			
			# Add the file name to the list of file names (for the download() call)
			name_list += [f]
	
	# Upload multiple files (all files found in the "files" directory) in one request
	jsonwsp_resp = transfer_client.upload(incomming=file_list)
	print_result(jsonwsp_resp)

	# Download all the files we just uploaded in one request
	jsonwsp_resp = transfer_client.download(names=name_list)
	print_result(jsonwsp_resp)

	# The attachments are referenced as open file-handles in the response object
	# read their content and save it as files in the "download" folder.
	if jsonwsp_resp.status==200:
		for f in jsonwsp_resp.response_dict['result']:
			fp = open(os.path.join(download_dir,f['name']),'wb')
			fp.write(f['data'].read())
			fp.close()
예제 #32
0
def test_ShopService():
    album_client = JSONWSPClient(
        'http://localhost:8099/service/ShopService/jsonwsp/description')
    m_Grocery1 = {
        'item_name': '苹果',
        'price': 5,
    }
    m_Grocery2 = {
        'item_name': '香蕉',
        'price': 6,
    }
    m_Purchase1 = {
        'grocery': m_Grocery1,
        'quantity': 2,
    }
    m_Purchase2 = {
        'grocery': m_Grocery1,
        'quantity': 3,
    }
    m_GroceryList = {'purchases': [m_Purchase1, m_Purchase2]}
    jsonwsp_resp = album_client.addToBasket(glist=m_GroceryList)
    print jsonwsp_resp.response_dict['result']
예제 #33
0
def test_ShopService():
    album_client = JSONWSPClient('http://localhost:8099/service/ShopService/jsonwsp/description')
    m_Grocery1 = {
                 'item_name':'苹果',
                 'price':5,
                 }
    m_Grocery2 = {
                 'item_name':'香蕉',
                 'price':6,
                 }
    m_Purchase1 = {
                  'grocery':m_Grocery1,
                  'quantity':2,
                  }
    m_Purchase2 = {
              'grocery':m_Grocery1,
              'quantity':3,
              }
    m_GroceryList = {
                     'purchases':[m_Purchase1,m_Purchase2]
                     }
    jsonwsp_resp = album_client.addToBasket(glist =m_GroceryList)
    print jsonwsp_resp.response_dict['result']
예제 #34
0
def getOpcServer(opt):
    global base_url
    print "\n\nGet OPC Server Name from Server"
    opc_read = JSONWSPClient(base_url + '/LoadOPC/jsonwsp/description')
    jsonwsp_resp = opc_read.get_server(a=opt)
    return print_result(jsonwsp_resp)
예제 #35
0
	def parse_incoming(sh,url,headers,data):
		if url.find('logout.php?step=2')>-1:
			return LOGOUT_PROCESS_SUCCESS
		
		
		c=re.compile(u'\S*mv_login_id=(?P<mv_login_id>([0-9a-zA-Z]+))')
		m=c.match(url)
		if m:
			try:
				#server_error_logger.warning('')
				mv_login_id = m.groupdict().get('mv_login_id')
				sw = SessionWrapper(sh)
				# Fetch webservice
				## UserService
				cli_user = JSONWSPClient('http://mv-login.valhalla.local/ws-2/UserService/jsonwsp/description')
				cli_user.parse_url('http://mv-login.valhalla.local/ws-2/UserService/jsonwsp')
				res = cli_user.whoami(session_id=mv_login_id, lookup_primary_group = True, extract_usergroups = False, extract_userroles = True, extract_generated_passwords = False)
				if not res.response_dict['result']['method_result']['res_code']==0:
					raise AuthProcessFailed(MVLoginCompanyAuthHandler,details="Failed to communicate with MV-Login webservice",system_code=400)
				user_info = res.response_dict['result']['user_info']
				## DomainService
				cli_domain = JSONWSPClient('http://mv-login.valhalla.local/ws-2/DomainService/jsonwsp/description')
				cli_domain.parse_url('http://mv-login.valhalla.local/ws-2/DomainService/jsonwsp')
				res = cli_domain.listDomains(session_id=mv_login_id, parent_domain=user_info['domain'])
				if not res.response_dict['result']['method_result']['res_code']==0:
					raise AuthProcessFailed(MVLoginCompanyAuthHandler,details="Failed to communicate with MV-Login webservice",system_code=400)
				domain_info = res.response_dict['result']['domains'][0]
				
				# Institution
				#sw.set_institution_id(user_info['org_code'])
				sw.set_institution_id(domain_info['institutionCode'])
				sw.set_institution_name(domain_info['o'])
				sw.set_institution_type(domain_info.get('domainType','company'))
				
				# Domain
				sw.set_domain(user_info['domain'])
				
				# IdP
				sw.set_identity_provider('mvlogin-company')
				
				# User
				sw.set_username(user_info['uid'])
				sw.set_uid(user_info['uid'])
				sw.set_given_name(user_info.get('givenName','Unknown'))
				sw.set_surname(user_info.get('sn','Unknown'))
				roles = user_info.get('roles',['employee'])
				if not len(roles):
					raise AuthProcessFailed(MVLoginCompanyAuthHandler,details='Problem occurred while fetching roles',system_code=401)
				sw.set_role(roles)
				
				# User - optional
				if user_info.get('mail'):
					sw.set_mail(user_info.get('mail'))
				if user_info.get('sex'):
					sw.set_sex(str(user_info.get('sex')) )
				if user_info.get('mobile'):
					sw.set_mobile(str(user_info.get('mobile')) )
				if user_info.get('telephoneNumber'):
					sw.set_telephone_number(str(user_info.get('telephoneNumber')) )
				if user_info.get('street'):
					sw.set_street(user_info.get('street'))
				if user_info.get('postalCode'):
					sw.set_postal_code(str(user_info.get('postalCode')) )
				if user_info.get('l'):
					sw.set_city(user_info.get('l'))
				if user_info.get('st'):
					sw.set_state(user_info.get('st'))
				if user_info.get('birthday'):
					sw.set_date_of_birth(user_info.get('birthday'))
				
				return AUTH_PROCESS_SUCCESS
			except Exception, e:
				logger.warning('Error: %s' % e)
				logger.warning(get_traceback())
				raise e
예제 #36
0
from ladon.clients.jsonwsp import JSONWSPClient
import pprint

cli = JSONWSPClient('http://127.0.0.1:8888/TestService/jsonwsp/description')

r = cli.createServerFault()
pprint.pprint(r.response_dict)

r = cli.blameClientFault()
pprint.pprint(r.response_dict)

r = cli.unmanagedFault(anumber=1)
pprint.pprint(r.response_dict)

r = cli.unmanagedFault(anumber='hfiuwef')
pprint.pprint(r.response_dict)


예제 #37
0
	def parse_incoming(sh,url,headers,data):
		if url.find('logout.php?step=2')>-1:
			return LOGOUT_PROCESS_SUCCESS
		
		c=re.compile(u'\S*mv_login_id=(?P<mv_login_id>([0-9a-zA-Z]+))')
		m=c.match(url)
		if m:
			try:
				mv_login_id = m.groupdict().get('mv_login_id')
				sw = SessionWrapper(sh)
				# Fetch webservice
				## UserService
				cli_user = JSONWSPClient('http://mv-login.valhalla.local/ws-2/UserService/jsonwsp/description')
				cli_user.parse_url('http://mv-login.valhalla.local/ws-2/UserService/jsonwsp')
				res = cli_user.whoami(session_id=mv_login_id, lookup_primary_group = True, extract_usergroups = False, extract_userroles = True, extract_generated_passwords = False)
				if not res.response_dict['result']['method_result']['res_code']==0:
					raise AuthProcessFailed(MVLoginAuthHandler,details="Failed to communicate with MV-Login webservice",system_code=400)
				user_info = res.response_dict['result']['user_info']
				## DomainService
				cli_domain = JSONWSPClient('http://mv-login.valhalla.local/ws-2/DomainService/jsonwsp/description')
				cli_domain.parse_url('http://mv-login.valhalla.local/ws-2/DomainService/jsonwsp')
				res = cli_domain.listDomains(session_id=mv_login_id, parent_domain=user_info['domain'])
				if not res.response_dict['result']['method_result']['res_code']==0:
					raise AuthProcessFailed(MVLoginAuthHandler,details="Failed to communicate with MV-Login webservice",system_code=400)
				domain_info = res.response_dict['result']['domains'][0]
				
				# Institution
				#sw.set_institution_id(user_info['org_code'])
				sw.set_institution_id(domain_info['institutionCode'])
				sw.set_institution_name(domain_info['o'])
				sw.set_institution_type(domain_info.get('domainType','school'))
				
				# Domain
				sw.set_domain(user_info['domain'])
				
				# IdP
				sw.set_identity_provider('mvlogin')
				
				# User
				sw.set_username(user_info['uid'])
				sw.set_uid(user_info['uid'])
				sw.set_given_name(user_info.get('givenName','Unknown'))
				sw.set_surname(user_info.get('sn','Unknown'))
				roles = user_info.get('roles',['pupil'])
				if not len(roles):
					raise AuthProcessFailed(MVLoginAuthHandler,details='Problem occurred while fetching roles',system_code=401)
				sw.set_role(roles)
				
				# User - optional
				if user_info.get('mail'):
					sw.set_mail(user_info.get('mail'))
				if user_info.get('sex'):
					sw.set_sex(str(user_info.get('sex')) )
				if user_info.get('mobile'):
					sw.set_mobile(str(user_info.get('mobile')) )
				if user_info.get('telephoneNumber'):
					sw.set_telephone_number(str(user_info.get('telephoneNumber')) )
				if user_info.get('street'):
					sw.set_street(user_info.get('street'))
				if user_info.get('postalCode'):
					sw.set_postal_code(str(user_info.get('postalCode')) )
				if user_info.get('l'):
					sw.set_city(user_info.get('l'))
				if user_info.get('st'):
					sw.set_state(user_info.get('st'))
				if user_info.get('birthday'):
					sw.set_date_of_birth(user_info.get('birthday'))
				
				# User - class
				res = cli_user.listOwnGroups(session_id=mv_login_id,domain=user_info['domain'],uid=user_info['uid'],group_types=['classtype'])
				if not res.response_dict['result']['method_result']['res_code']==0:
					raise AuthProcessFailed(MVLoginAuthHandler,details="Failed to communicate with MV-Login webservice",system_code=400)
				groups = res.response_dict['result']['groups']
				if len(groups):
					first_school_year = groups[0].get(u'firstSchoolYear',None)
					grade_ok = False
					if str(first_school_year).strip().isdigit():
						grade = datetools.first_school_year_to_grade(int(first_school_year))
						sw.set_grade(str(grade))
						grade_ok = True
					track_name = groups[0].get(u'calculatedName',None)
					if not grade_ok and track_name:
						m = re.search('\d+', track_name)
						if m:
							sw.set_grade(m.group())
					if track_name:
						# Remove any digits, dots and excessive spacings from the track_name:
						tn = re.sub('\s+', ' ', re.sub('[\d,\.]+', '', track_name)).strip()
						sw.set_track_name(tn)
				return AUTH_PROCESS_SUCCESS
			
			except Exception as e:
				logger.warning('Error: %s' % e)
				logger.warning(get_traceback())
				raise e
		
		return AUTH_PROCESS_IDLE
예제 #38
0
def getOpcServer(opt):
    global base_url
    print "\n\nGet OPC Server Name from Server"
    opc_read = JSONWSPClient(base_url+'/LoadOPC/jsonwsp/description')
    jsonwsp_resp = opc_read.get_server(a=opt)
    return print_result(jsonwsp_resp)
예제 #39
0
# -*- coding: utf-8 -*-
"""
Tests the which_bus_service. The server should be started.
If not, please run runserver.py first.
"""
from ladon.clients.jsonwsp import JSONWSPClient
import pprint


def print_result(jsonwsp_resp):
    if jsonwsp_resp.status == 200:
        pprint.pprint(jsonwsp_resp.response_dict['result'], indent=2)
    else:
        print("A problem occurred while communicating with the service:\n")
        print(jsonwsp_resp.response_body)

client = JSONWSPClient('http://localhost:8080/WhichBus/jsonwsp/description')
bus_stops = client.find_bus_stops(search_phrase="5ο ΓΥΜΝΑΣΙΟ ΑΘΗΝΑΣ", n_stops=4)
print_result(bus_stops)