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


Python Store.store方法代码示例

本文整理汇总了Python中store.Store.store方法的典型用法代码示例。如果您正苦于以下问题:Python Store.store方法的具体用法?Python Store.store怎么用?Python Store.store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在store.Store的用法示例。


在下文中一共展示了Store.store方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: insert

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import store [as 别名]
def insert(name, data):
    global connection
    doc = {'time': datetime.utcnow(), 'name': name, 'data': data}
    print doc
    s = Store('localhost:27017')
    s.store('test', 'doc', doc)
    connection.push('stats', doc)
    return 'Inserted [%s:%d]' % (name, data)
开发者ID:cff29546,项目名称:EventTrigger,代码行数:10,代码来源:fe.py

示例2: POST

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import store [as 别名]
	def POST(self):
		#print web.input()
		url = web.input()['url']
		image_url_regex = r'/.*/([^/]+)\.(gif|jpg|jpeg|png)$'
		match = re.search(image_url_regex, url)
		if match is None:
			return json.dumps([False, 'invalid image file'])
		fileName = "{0}.{1}".format(* match.groups())
		#print fileName
		import urllib
		file = urllib.urlopen(url)
		data = file.read()
		store = Store()
		result = store.store(data,name=fileName)
		file.close()
		
		if(hasattr(web.input(),'callback')):
			web.header('Location', web.input()['callback']+"?"+"("+json.dumps(result)+")")
			return "";
		return "("+json.dumps(result)+")"
开发者ID:elementalife,项目名称:img,代码行数:22,代码来源:img.py

示例3: main

# 需要导入模块: from store import Store [as 别名]
# 或者: from store.Store import store [as 别名]
def main(argv=None):
	if argv is None:
		argv = sys.argv
	
	try:
		try:
			opts, args = getopt.getopt(argv[1:], "hi:q:lt:v", ["help", "import=", "id=", "list", "test", "verbose", "limit=", "start="])
		except getopt.error, msg:
			raise Usage(msg)
		
		#print(opts)
		#print(args)
		action = None
		store_file = None
		# option processing
		for option, value in opts:
			if option == "-v":
				verbose = True
			if option in ("-h", "--help"):
				raise Usage(help_message)
			if option in ("-i", "--import"):
				store_file = value
				print('store file: {0}'.format(store_file))
				action = 'import'
			elif option in ("-l", "--list"):
				action = 'list'
			elif option in ("-t", "--test"):
				action = 'test'
				filename = value
			elif option in ("-q", "--id"):
				action = 'get'
				id = value
			else:
				pass
		
		print('action: {}'.format(action))
		if (action == 'list'):
			store = Store()
			gallery = store.browse()
			for img in gallery['items']:
				#print(img)
				print("{0[filename]}\t{0[length]:8,d}".format(img))
			return 0
		elif (action == 'get') and id is not None:
			store = Store()
			if not store.getFs().exists(id):
				print ('not found')
				return 1
			gf = store.get(id)
			#print(gf)
			print ("found: {0.name}\t{0.length}".format(gf))
			return 0
		elif (action == 'test'):
			print('filename: %r' % filename)
			fp = open(filename, 'rb')
			h = fp.read(32)
			print(getImageType(h))
			return 0
		elif (action == 'import'):
			print('storing: %r' % store_file)
			fp = open(store_file, 'rb')
			type = "IMAGE"
			data = fp.read()
#			h = fp.read(32)
#			type =  getImageType(h)
#			print(store_file+": "+type )
			store = Store()
			result = store.store(data, type, store_file)
			print result
			return 0
开发者ID:elementalife,项目名称:img,代码行数:72,代码来源:tool.py


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