本文整理汇总了Python中xmlrpclib.ServerProxy.lookup方法的典型用法代码示例。如果您正苦于以下问题:Python ServerProxy.lookup方法的具体用法?Python ServerProxy.lookup怎么用?Python ServerProxy.lookup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib.ServerProxy
的用法示例。
在下文中一共展示了ServerProxy.lookup方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: item
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
def item(request):
s = ServerProxy('http://www.upcdatabase.com/xmlrpc')
# Gets the ean-code value
ean = request.GET.get('ean', '')
print ean
# Nothing Scanned
if (ean == ''):
return render_to_response("fms/home.html",script_args)
elif (len(ean) == 13 and ean[0]=='0'):
# Scanned From Pic-2-Shop App From Mobile Device (Trims leading 0)
ean = ean[1:]
# elif """query for upc locally"""
# Happens when there is a local entry already stored
# Redirects to the items page
params = { 'rpc_key': rpc_key, 'upc': ean }
item_lookup_data = s.lookup(params)
print item_lookup_data
i_l_d = []
for key, value in item_lookup_data.iteritems():
i_l_d.append((key,value))
script_args['item_lookup_data']= i_l_d
return render_to_response("fms/item.html", script_args)
return render_to_response("fms/item.html", script_args)
示例2: set_name_from_cloud
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
def set_name_from_cloud(self):
s = ServerProxy('http://www.upcdatabase.com/xmlrpc')
params = { 'rpc_key': rpc_key, 'upc': self.convert_upc() }
response = s.lookup(params)
if response['status'] == 'success':
self.name = response['description']
self.save()
return
示例3: item
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
def item(request):
s = ServerProxy('http://www.upcdatabase.com/xmlrpc')
# Gets the ean-code value
ean = request.GET.get('ean', '')
print ean
# Nothing Scanned
if (ean == ''):
return render_to_response("fms/home.html",script_args)
elif (len(ean) == 13 and ean[0]=='0'):
# Scanned From Pic-2-Shop App From Mobile Device (Trims leading 0)
ean = ean[1:]
i_l_d = []
local_upc = Item.objects.all().filter(Q(upc__iexact=ean))
if (local_upc.exists()):
# Happens when there is a local entry already stored
i_l_d = [("Local data", "Found")]
print "found you locally"
#for key, value in local_upc[0]:
#i_l_d.append((key,value))
else:
# Redirects to the items page
params = { 'rpc_key': rpc_key, 'upc': ean }
item_lookup_data = s.lookup(params)
print item_lookup_data
# Creating Hanger for New UPC
#new_upc = Hanger(name=ean,hung_on=local_upc)
#new_upc.save()
new_item = Item(upc=ean)
new_item._meta.get_all_field_names()
for key, value in item_lookup_data.iteritems():
i_l_d.append((key,value))
setattr(new_item,key,value)
new_item.save()
script_args['item_lookup_data']= i_l_d
return render_to_response("fms/item.html", script_args)
示例4: query
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
def query(upc):
"""Saca la descripción del producto usando la API de upcdatabase.com"""
queryurl = 'http://www.upcdatabase.com/xmlrpc'
s = ServerProxy(queryurl)
params = {
'rpc_key': rpc_key,
'upc': upc
}
response = s.lookup(params)
if response.has_key('description'):
description = response['description']
description = str(BeautifulStoneSoup(description, convertEntities=BeautifulStoneSoup.HTML_ENTITIES))
return description
else:
return response
示例5: UPCDatabaseProvider
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
class UPCDatabaseProvider(BarcodeLookupProvider):
def __init__(self):
self.server = ServerProxy('http://www.upcdatabase.com/xmlrpc')
self.rpc_key = 'c4a7f4f0bd0a0f2ea4df549d4f8bcbd3e0229b08'
def lookupBarcode(self,barcode):
if len(barcode)<13:
barcode = '0'*(13-len(barcode)) + barcode
params = { 'rpc_key': self.rpc_key, 'ean': barcode }
logging.warn(params)
results = self.server.lookup(params)
logging.warn(results)
try:
if results['found']:
return (results['description'],results['size'],results['issuerCountry'])
return None
except:
logging.warn('Scan resulted in error.')
return None
示例6: len
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
#!/usr/bin/env python
import sys
from xmlrpclib import ServerProxy, Error
__author__ = 'Ethan Trewhitt'
if __name__ == '__main__':
if len(sys.argv) != 2:
print 'Usage: upc_db.py <upc>'
exit
else:
s = ServerProxy('http://www.upcdatabase.com/xmlrpc')
params = {'rpc_key': UPC_DB_KEY, 'upc': sys.argv[1]}
print s.lookup(params)
示例7: shouldExit
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
for row in cur:
print '\t'.join(row[0][1:-1].split(','))
exit_loop = shouldExit()
continue
elif d.has_key(code):
data = d[code]
if datetime.strptime(data['noCacheAfterUTC'], "%Y-%m-%dT%H:%M:%S") < timestamp:
lookup = True
else:
# TODO figure out why the cache is being stupid with datetime
# objects and such...
#lookup = False
lookup=True
if lookup:
data = s.lookup({'rpc_key' : rpc_key, 'upc' : code})
if data['status'] == 'success':
if data['found']:
d[code] = data
if type(d[code]['noCacheAfterUTC']) is not str:
d[code]['noCacheAfterUTC'] = d[code]['noCacheAfterUTC'].value
else:
print 'Item not found!'
c = raw_input('Do you want to submit a correction? (y/N) ')
if c.lower() == 'y':
description = raw_input('Description: ')
size = raw_input('Size: ')
result = s.writeEntry({'rpc_key' : rpc_key, 'upc' : code,
'description' : description})
示例8: get_info
# 需要导入模块: from xmlrpclib import ServerProxy [as 别名]
# 或者: from xmlrpclib.ServerProxy import lookup [as 别名]
def get_info(self):
s = ServerProxy('http://www.upcdatabase.com/xmlrpc')
params = { 'rpc_key': rpc_key, 'upc': self.upc }
response = s.lookup(params)
return response