当前位置: 首页>>代码示例>>Python>>正文


Python ServerProxy.lookup方法代码示例

本文整理汇总了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)
开发者ID:MushuTushu,项目名称:CMSC434_Final_Project,代码行数:37,代码来源:views.py

示例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
开发者ID:LineCook,项目名称:user_recipe_db,代码行数:10,代码来源:models.py

示例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)    
开发者ID:zinglax,项目名称:CMSC434_Final_Project,代码行数:53,代码来源:views.py

示例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
开发者ID:buzali,项目名称:SuperListas,代码行数:18,代码来源:upcdatabase.py

示例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
开发者ID:NURDspace,项目名称:nurdbar,代码行数:22,代码来源:barcodelookup.py

示例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)


开发者ID:courtarro,项目名称:pyCatalog,代码行数:17,代码来源:upc_db.py

示例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})
开发者ID:agmlego,项目名称:Skewer,代码行数:33,代码来源:barcode.py

示例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
开发者ID:LineCook,项目名称:user_recipe_db,代码行数:7,代码来源:models.py


注:本文中的xmlrpclib.ServerProxy.lookup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。