• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python store.Store类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: AddYoutubeListThread

class AddYoutubeListThread(threading.Thread):
    def __init__(self, jukebox, list_url, add_playlist):
        threading.Thread.__init__(self)
        self.jukebox = jukebox
        self.list_url = list_url
        self.add_playlist = add_playlist
        self.store = Store()

    def run(self):
        infos = youtube.get_video_infos_from_list(self.list_url)
        for info in infos:
            print(info)
            try:
                song = Song()
                song.url = info["url"]
                song.uid = info["uid"]
                song.title = info["title"]
                song.img_url = info["image_url"]
                song.duration = info['duration']

                if song.title and song.duration:
                    # 데이터가 valid 할 때만 추가
                    
                    self.store.update_or_new(song)

                    if self.add_playlist:
                        self.jukebox.append_song_playlist(song)
                
            except Exception as e:
                print(e)
开发者ID:mycat83,项目名称:book_python_example,代码行数:30,代码来源:jukebox.py


示例2: Entry

class Entry(object):
    def __init__(self):
        self.store = Store()

    def load_image(self, file_path, name):
        if not os.path.exists(file_path):
            print("Image file not existed")
            return -1

        image_hash = self.compute_hash(file_path)
        if self.store.get_face_by_hash(image_hash):
            print("Face already recorded.")
            return -2

        try:
            image = face_recognition.load_image_file(file_path)
            face_encoding = face_recognition.face_encodings(image)[0]
        except Exception:
            print("Failed to recognition face")
            return -3

        face = {
            "name": name,
            "hash": image_hash,
            "face_encoding": list(face_encoding)
        }

        self.store.create_face(face)

    def compute_hash(self, file_path):
        with open(file_path, "r") as f:
            data = f.read()
            image_md5 = hashlib.md5(data)
            return image_md5.hexdigest()
开发者ID:DeliangFan,项目名称:face,代码行数:34,代码来源:entry.py


示例3: _jsonstr_other

 def _jsonstr_other(self, thing):
     'Do our best to make JSON out of a "normal" python object - the final "other" case'
     ret = '{'
     comma = ''
     attrs = thing.__dict__.keys()
     attrs.sort()
     if Store.has_node(thing) and Store.id(thing) is not None:
         ret += '"_id": %s' %  str(Store.id(thing))
         comma = ','
     for attr in attrs:
         skip = False
         for prefix in self.filterprefixes:
             if attr.startswith(prefix):
                 skip = True
                 continue
         if skip:
             continue
         value = getattr(thing, attr)
         if self.maxJSON > 0 and attr.startswith('JSON_') and len(value) > self.maxJSON:
             continue
         if self.expandJSON and attr.startswith('JSON_') and value.startswith('{'):
             js = pyConfigContext(value)
             if js is not None:
                 value = js
         ret += '%s"%s":%s' % (comma, attr, self._jsonstr(value))
         comma = ','
     ret += '}'
     return ret
开发者ID:JJediny,项目名称:assimilation-official,代码行数:28,代码来源:assimjson.py


示例4: main

    def main(self):
        """ set everything up, then invoke go() """

        (options, args) = self.parser.parse_args()

        log_level = logging.ERROR
        if options.debug:
            log_level = logging.DEBUG
        elif options.verbose:
            log_level = logging.INFO
        logging.basicConfig(level=log_level)    #, format='%(message)s')


        if options.test:
            self.store = DummyStore(self.name, self.doc_type)
        else:
            # load in config file for real run
            config = ConfigParser.ConfigParser()
            config.readfp(open(options.ini_file))
            auth_user = config.get("DEFAULT",'user')
            auth_pass = config.get("DEFAULT",'pass')
            server = config.get("DEFAULT",'server')

            self.store = Store(self.name, self.doc_type, auth_user=auth_user, auth_pass=auth_pass, server=server)


        if options.cache:
            logging.info("using .cache")
            opener = urllib2.build_opener(CacheHandler(".cache"))
            urllib2.install_opener(opener)

        self.go(options)
开发者ID:dvogel,项目名称:publicity_machine,代码行数:32,代码来源:basescraper.py


示例5: total

def total():
    result = ['<head/><body><table><tr><td>Name</td><td>Total</td></tr>']
    s = Store('localhost:27017')
    for record in s.find('test', 'total', {}):
      result.append('<tr><td>%s</td><td>%d</td></tr>' % (record['_id'], record['value']))
    result.append('</table><body>')
    return '\n'.join(result)
开发者ID:cff29546,项目名称:EventTrigger,代码行数:7,代码来源:fe.py


示例6: setup

 def setup(dbhost='localhost', dbport=7474, dburl=None, querypath=None):
     '''
     Program to set up for running our REST server.
     We do these things:
         - Attach to the database
         - Initialize our type objects so things like ClientQuery will work...
         - Load the queries into the database from flat files
             Not sure if doing this here makes the best sense, but it
             works, and currently we're the only one who cares about them
             so it seems reasonable -- at the moment ;-)
             Also we're most likely to iterate changing on those relating to the
             REST server, so fixing them just by restarting the REST server seems
             to make a lot of sense (at the moment)
         - Remember the set of queries in the 'allqueries' hash table
     '''
     if dburl is None:
         dburl = ('http://%s:%d/db/data/' % (dbhost, dbport))
     print >> sys.stderr, 'CREATING Graph("%s")' % dburl
     neodb = neo4j.Graph(dburl)
     qstore = Store(neodb, None, None)
     print GraphNode.classmap
     for classname in GraphNode.classmap:
         GraphNode.initclasstypeobj(qstore, classname)
     print "LOADING TREE!"
     if querypath is None:
         querypath = "/home/alanr/monitor/src/queries"
     queries = ClientQuery.load_tree(qstore, querypath)
     for q in queries:
         allqueries[q.queryname] = q
     qstore.commit()
     for q in allqueries:
         allqueries[q].bind_store(qstore)
开发者ID:Alan-R,项目名称:assimilation-persistent-events,代码行数:32,代码来源:hello.py


示例7: members_ring_order

    def members_ring_order(self):
        'Return all the Drones that are members of this ring - in ring order'
        ## FIXME - There's a cypher query that will return these all in one go
        # START Drone=node:Drone(Drone="drone000001")
        # MATCH Drone-[:RingNext_The_One_Ring*]->NextDrone
        # RETURN NextDrone.designation, NextDrone

        if self._insertpoint1 is None:
            #print >> sys.stderr, 'NO INSERTPOINT1'
            return
        if Store.is_abstract(self._insertpoint1):
            #print >> sys.stderr, ('YIELDING INSERTPOINT1:', self._insertpoint1
            #,       type(self._insertpoint1))
            yield self._insertpoint1
            return
        startid = Store.id(self._insertpoint1)
        # We can't pre-compile this, but we hopefully we won't use it much...
        q = '''START Drone=node(%s)
             MATCH p=Drone-[:%s*0..]->NextDrone
             WHERE length(p) = 0 or Drone <> NextDrone
             RETURN NextDrone''' % (startid, self.ournexttype)
        query = neo4j.CypherQuery(CMAdb.cdb.db, q)
        for elem in CMAdb.store.load_cypher_nodes(query, Drone):
            yield elem
        return
开发者ID:borgified,项目名称:assimilation,代码行数:25,代码来源:hbring.py


示例8: create_player

 def create_player(cls, name):
     """
     :type name: str
     """
     if cls.get_player(name):
         raise RuntimeError('Player already exists: %s' % name)
     Store.get_store().set_player(Player(name, trueskill.Rating()))
开发者ID:mocsar,项目名称:csocso,代码行数:7,代码来源:player.py


示例9: initStigmergy

    def initStigmergy(self):
        # default travel time (sec) = length (m) / s(m/sec)
        self.long_term_stigmergies = dict([(edge_id, stigmergy.Stigmergy(
            netutil.freeFlowTravelTime(self.sumo_net, edge_id))) for edge_id in self.edge_ids])

        self.short_term_stigmergies = copy.deepcopy(self.long_term_stigmergies)

        # use stored data in long term stigmergy
        if self.conf.short_cut != -1:
            before_read_time = time.clock()

            if self.conf.redis_use:
                store = Store(self.conf.redis_host, self.network_file)
            else:
                store = StoreJSON(self.conf.short_cut_file, self.network_file, 'r')

            past_stigmergy_list = store.getLongTermStigmergy(self.conf.weight_of_past_stigmergy, self.conf.short_cut)

            for k in past_stigmergy_list:
                key = k.replace(store.createFileNameWithoutKey(
                    self.conf.weight_of_past_stigmergy,
                    self.conf.short_cut), "")
                data_list = [float(travel_time) for travel_time in store.getLongTermStigmergyWithKey(k)]
                self.long_term_stigmergies[key].addStigmergy(data_list)
            print("read long term stigmergy from redis(" + str(time.clock() - before_read_time) + "sec)")
开发者ID:gg-uah,项目名称:ParkiNego,代码行数:25,代码来源:long_short_stigmergy.py


示例10: domain_list

def domain_list():
    store = Store()
    domains = store.index()
    if request.headers.get("Accept") == "text/plain":
        return template("domains.text", domains=domains)
    else:
        return template("domains.html", domains=domains, url=url, flashed_messages=get_flashed_messages())
开发者ID:tsing,项目名称:proxy-manager,代码行数:7,代码来源:domains.py


示例11: add_mac_ip

    def add_mac_ip(self, drone, macaddr, IPlist):
        '''We process all the IP addresses that go with a given MAC address (NICNode)
        The parameters are expected to be canonical address strings like str(pyNetAddr(...)).
        '''
        nicnode = self.store.load_or_create(NICNode, domain=drone.domain, macaddr=macaddr)
        if not Store.is_abstract(nicnode):
            # This NIC already existed - let's see what IPs it already owned
            currips = {}
            oldiplist = self.store.load_related(nicnode, CMAconsts.REL_ipowner, IPaddrNode)
            for ipnode in oldiplist:
                currips[ipnode.ipaddr] = ipnode
                #print >> sys.stderr, ('IP %s already related to NIC %s'
                #%       (str(ipnode.ipaddr), str(nicnode.macaddr)))
            # See what IPs still need to be added
            ips_to_add = []
            for ip in IPlist:
                if ip not in currips:
                    ips_to_add.append(ip)
            # Replace the original list of IPs with those not already there...
            IPlist = ips_to_add

        # Now we have a NIC and IPs which aren't already related to it
        for ip in IPlist:
            ipnode = self.store.load_or_create(IPaddrNode, domain=drone.domain
            ,       ipaddr=ip)
            #print >> sys.stderr, ('CREATING IP %s for NIC %s'
            #%       (str(ipnode.ipaddr), str(nicnode.macaddr)))
            if not Store.is_abstract(ipnode):
                # Then this IP address already existed,
                # but it wasn't related to our NIC...
                # Make sure it isn't related to a different NIC
                for oldnicnode in self.store.load_in_related(ipnode, CMAconsts.REL_ipowner
                    , GraphNode.factory):
                    self.store.separate(oldnicnode, CMAconsts.REL_ipowner, ipnode)
            self.store.relate(nicnode, CMAconsts.REL_ipowner, ipnode)
开发者ID:h4ck3rm1k3,项目名称:assimilation-official,代码行数:35,代码来源:arpdiscovery.py


示例12: performTask

  def performTask(self, task):
    self.performing_task = task
    
    # Creating new store
    store = Store(task.index_fields)

    # Reading data
    self.state = 'reading data from log %s' % task.log
    data = self.filekeeper.read(task.log)
    logging.debug("[worker %s] read %d bytes from %s" % (task.collector_name, len(data), task.log))

    # Parsing and pushing data
    self.state = 'parsing data from log %s' % task.log
    total = 0
    parsed = 0
    t1 = time.time()
    for line in data.split('\n'):
      record = task.parser.parseLine(line+'\n')
      if task.parser.successful:
        parsed += 1
        # after_parse_callbacks
        for callback in task.after_parse_callbacks:
          func = callback[0]
          args = [record] + callback[1:]
          try:
            func(*args)
          except Exception, e:
            logging.debug('[%s.%s] %s' % (func.__module__, func.__name__, repr(e)))
        store.push(record)
      total += 1
开发者ID:viert,项目名称:lwatcher,代码行数:30,代码来源:tasks.py


示例13: insert

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,代码行数:8,代码来源:fe.py


示例14: create_domain

def create_domain():
    domain = request.forms.domain
    if domain:
        store = Store()
        store.create(domain)
        flash("%s added" % domain)
        fanout.update()
    return redirect(url("domains"))
开发者ID:tsing,项目名称:proxy-manager,代码行数:8,代码来源:domains.py


示例15: __init__

	def __init__(self, file_path):
		if Store.is_usable:
			Store.file_name = file_path
			print "\nFound Your File!\n\n"
		else:
			Store.file_name = file_path
			Store.create_file()
			print "Your file has been created!\n\n"
开发者ID:salmanhoque,项目名称:MovieApp_python,代码行数:8,代码来源:interface.py


示例16: validate

 def validate(self):
     """Verify current configuration and updates KID"""
     opt = Store(kid=self.kid_base)
     opt.desc = self.desc
     failed = opt.validate()
     if len(failed) > 0:
         print 'Failed validations', failed
     for k, v in opt.desc.iteritems():
         self.desc[k] = v
     return failed
开发者ID:riccardomarotti,项目名称:misura.canon,代码行数:10,代码来源:conf.py


示例17: load_face

    def load_face(self):
        store = Store()
        self.faces = store.list_faces()

        self.known_face_encodings = []
        self.known_face_names = []

        for face in self.faces["faces"]:
            self.known_face_encodings.append(face["face_encoding"])
            self.known_face_names.append(face["name"])
开发者ID:DeliangFan,项目名称:face,代码行数:10,代码来源:video.py


示例18: GET

    def GET(self,id1,id2,id3,id4,type):
#		image_url_regex = r'/([a-z0-9]{2})/([a-z0-9]{2})/([a-z0-9]{19,36})(-[sc]\d{2,4})?\.(gif|jpg|jpeg|png)$'
		id = '{0}{1}{2}'.format(id1,id2,id3)
		from store import Store
		store = Store()
		file = store.get(id)
		if file is None:
		    store.close()
		    return render.error("not found",'/')

		org_path = '{0}/{1}/{2}.{4}'.format(id1,id2,id3,id4,type)
		org_file = '{0}/{1}'.format(THUMB_ROOT, org_path)
		if not os.path.exists(org_file):
		    save_file(file, org_file)
		if id4 is None:
		    dst_path = org_path
		    dst_file = org_file
		else:
		    dst_path = '{0}/{1}/{2}{3}.{4}'.format(id1,id2,id3,id4,type)
		    dst_file = '{0}/{1}'.format(THUMB_ROOT, dst_path)
		    #print(ids[3][1:])
		    size = int(id4[2:])
		    if size not in SUPPORTED_SIZE:
		        print('unsupported size: {0}'.format(size))
		        store.close()
		        return render.error("not found",'/')
		    thumb_image(org_file, size, dst_file)
#		print(org_file)
#		print(dst_file)
#		print web.ctx.env
		server_soft = web.ctx.env['SERVER_SOFTWARE']
#		print server_soft
		if server_soft[:5] == 'nginx' and os.name != 'nt':
			print("in")
			store.close()
			#start_response('200 OK', [('X-Accel-Redirect', '{0}/{1}'.format(THUMB_PATH, dst_path))])
			web.header('X-Accel-Redirect', '{0}/{1}'.format(THUMB_PATH, dst_path))
			return ;
		
#		print(file.type) 
		web.header('Content-Type',  str(file.type))
		web.header('Content-Length', '{0.length}'.format(file))
		web.header('Via','store')
		#print(headers)
		
		# TODO: response file content
		distfile = open(dst_file, 'rb')
		data = distfile.read()
		store.close()
		return data; #200OK
		#return [data]
		
		#fd = open(dst_file,'r')
		#return environ['wsgi.file_wrapper'](fd, 4096)
		return render.error("not found",'/')
开发者ID:elementalife,项目名称:img,代码行数:55,代码来源:img.py


示例19: test_buy

 def test_buy(self):
     store = Store(2)
     count = 8
     while count > 0:
         buy_res = store.buy("PROVINCE")
         count -= 1
         self.assertEqual(store.base_inventory["PROVINCE"], count)
         self.assertEqual(buy_res, "PROVINCE")
     self.assertEqual(store.buy("PROVINCE"), None)
     self.assertEqual(store.buy("PROVINCE"), None)
     self.assertEqual(store.base_inventory["PROVINCE"], 0)
开发者ID:jhorowitz16,项目名称:dominion,代码行数:11,代码来源:storetest.py


示例20: main

def main():
    new_store = Store()

    with codecs.open('data/nouns.tsv', 'r', 'utf-8') as f:
        new_store.read_nouns(f)

    with codecs.open('data/verbs.tsv', 'r', 'utf-8') as f:
        new_store.read_verbs(f)

    with codecs.open('data/store.p', 'w', 'utf-8') as w:
        pickle.dump(new_store, w)
开发者ID:gree-gorey,项目名称:losc,代码行数:11,代码来源:pickle_creator.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python database.add函数代码示例发布时间:2022-05-27
下一篇:
Python store.path函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap