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

Python status.Status类代码示例

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

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



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

示例1: test_sam_error

 def test_sam_error(self):
     status = Status(self._mock_sam_api(False), {"fence": self._mock_fence_api(True)})
     self.assertItemsEqual(status.get(), [
         {"ok": True, "message": "", "subsystem": Subsystems.memcache},
         {"ok": True, "message": "", "subsystem": Subsystems.datastore},
         {"ok": True, "message": "", "subsystem": "fence"},
         {"ok": False, "message": "sam down", "subsystem": Subsystems.sam},
     ])
开发者ID:DataBiosphere,项目名称:bond,代码行数:8,代码来源:status_test.py


示例2: test_datastore_error

 def test_datastore_error(self):
     status = Status(self._mock_sam_api(True), {"fence": self._mock_fence_api(True)})
     status._datastore_status = MagicMock(return_value=(False, "datastore down"))
     self.assertItemsEqual(status.get(), [
         {"ok": True, "message": "", "subsystem": Subsystems.memcache},
         {"ok": False, "message": "datastore down", "subsystem": Subsystems.datastore},
         {"ok": True, "message": "", "subsystem": "fence"},
         {"ok": True, "message": "", "subsystem": Subsystems.sam},
     ])
开发者ID:DataBiosphere,项目名称:bond,代码行数:9,代码来源:status_test.py


示例3: search_tweets

def search_tweets(trend):
    try:
        search_results = twitter.search(q=trend.query,  lang='es', count='100')
    except TwythonError as e:
        print e
    aux = 0
    for status in search_results.get(u'statuses', []):
        s = Status(status, trend)
        print s.text
        s.save()
开发者ID:fcaptuayo,项目名称:RecTweetPython,代码行数:10,代码来源:rec_tweet.py


示例4: join_go_terms_with_genes

def join_go_terms_with_genes():
    client = pymongo.MongoClient()
    terms = client.go.terms.find()
    status = Status('joining terms with genes').n(terms.count())
    for k, term in enumerate(terms):
        status.log(k)
        genes = client.go.genes.find({'go': term['go']})
        term['genes'] = list(set(g['gene'] for g in genes))
        term['n_genes'] = len(term['genes'])
        client.go.terms.save(term)
    status.stop()
开发者ID:ndexbio,项目名称:ndex-nav,代码行数:11,代码来源:go.py


示例5: advance_to_next_game

 def advance_to_next_game(self):
   # We only need to check the preferred team's game status if we're
   # rotating during mid-innings
   if self.config.rotation_preferred_team_live_mid_inning and not self.is_offday_for_preferred_team():
     preferred_overview = self.fetch_preferred_team_overview()
     if Status.is_live(preferred_overview.status) and not Status.is_inning_break(preferred_overview.inning_state):
       self.current_game_index = self.game_index_for_preferred_team()
       self.overview = preferred_overview
       self.needs_refresh = False
       self.__update_layout_state()
       self.print_overview_debug()
       return self.current_game()
   self.current_game_index = self.__next_game_index()
   return self.current_game()
开发者ID:ccrabb,项目名称:mlb-led-scoreboard,代码行数:14,代码来源:data.py


示例6: get

  def get(self):

    debug = self.request.get('debug',False)
    self.response.out.write('<ul>')

    #自分宛のreplyを取得
    twitter = TwitterClient()
    replies = twitter.getReplies()
    replies.reverse()
    for reply in replies:
      text = reply['text']
      texts = reply['text'].split()
      #全角スペースに対応
      if len(texts) < 2:
        texts = reply['text'].split(u' ')
      if len(texts) < 2:
        self.response.out.write('<li>[%s] is irregure</li>'%(text)) 
        continue
      keyword = texts[1]
      user    = reply['user']
      #自分のreplyは無視
      if user['screen_name'] == self.username :
        self.response.out.write('<li>[%s] is my status</li>'%(text))
        continue

      #既に処理済みのreplyも無視
      if not Status.isNewStatus( reply['id'] ) :
        self.response.out.write('<li>[%s] is old status</li>'%(text)) 
        continue

      #位置を取得
      finder = LocationFinder()
      loc = finder.find( keyword )
      if not loc:
        #見つからなかった
        mes = self.fail_message%( reply['user']['screen_name'] ,keyword)
      else:
        #見つかった
        mes = self.success_message[loc['type']]%( reply['user']['screen_name'] , loc['title'] , 'L:' + str(loc['lat']) + "," + str(loc['lon']) + ' ' + loc['url'] )

      #返信した内容を保存
      Status.saveStatus( reply,loc,mes )
      #twitterのstatusを更新
      if not debug:
        twitter.sendReply( mes , reply['id'])
      self.response.out.write('<li>[%s]:[%s]</li>'%(keyword,mes) )

    self.response.out.write('</ul>')
开发者ID:hirotoshi,项目名称:twittmap,代码行数:48,代码来源:cron.py


示例7: stop

 def stop(self):
   self.active = False
   game_slugs = get_game_slugs()
   
   if self.slug in game_slugs:
     game_slugs.remove(self.slug)
     memcache.set('game_slugs', game_slugs)
   
   
   serialized_status = memcache.get_multi(self.status_ids,
                                          key_prefix='status')
   
   # Just copying my status_ids list to make some changes localy
   missing_status_ids = list(self.status_ids)
   for status_id, status in serialized_status.iteritems():
     deserialized_status = deserialize(status)
     deserialized_status.player.leave_game(self)
     missing_status_ids.remove(status_id)
   
   # Taking the missing status in database
   if missing_status_ids:
     missing_status = Status.get(missing_status_ids)
     for status in missing_status:
       status.player.leave_game(self)
   
   memcache.delete('game'+self.slug)
   self.status_ids = []
   self.put()
开发者ID:virtualjoker,项目名称:jankenpony,代码行数:28,代码来源:game.py


示例8: __init__

    def __init__(self, config):
        self.config = config                                                    # 应用程序配置
        self.connections = 0                                                    # 连接客户端列表

        if self.config['savetime'] != 0:    # 不保存数据
            self.thread = PeriodicCallback(self.save_db,
                                       int(self.config['savetime']) * 1000)
            self.thread.start()                                                 # 背景保存服务线程启动

        self.workpool = ThreadPool(int(config['work_pool']))                    # 工作线程池

        self.status = Status(CacheServer.status_fields)                         # 服务器状态
        self.slave_clients = {}                                                 # 同步客户端
        self.is_sync = False                                                    # 是否在同步

        if self.config['master'] is not None:                                   # 从服务器启动
            shutil.rmtree(config['db'])
            self.master_server = PyCachedClient(self.config['master'][0],
                                                self.config['master'][1])
            self.master_server.sync(self.config['port'])
            self.slavepool = None
            self.slave = True                                                   # 是否为Slave模式
        else:                                                                   # 主服务器启动, 需要启动从命令工作线程

            self.slavepool = ThreadPool(int(config['slave_pool']))              # slave Command send pools
            self.slave = False                                                  # 是否为Slave模式

        self.memory = Memory(config['db'])                                      # 缓存服务类
        super(CacheServer, self).__init__()
开发者ID:eicesoft,项目名称:pycached,代码行数:29,代码来源:net.py


示例9: BondStatusApi

class BondStatusApi(remote.Service):
    def __init__(self):
        sam_base_url = config.get('sam', 'BASE_URL')

        providers = {provider_name: FenceApi(config.get(provider_name, 'FENCE_BASE_URL'))
                     for provider_name in config.sections() if provider_name != 'sam'}

        sam_api = SamApi(sam_base_url)
        self.status_service = Status(sam_api, providers)

    @endpoints.method(
        message_types.VoidMessage,
        StatusResponse,
        path='/status',
        http_method='GET',
        name='status')
    def status(self, request):
        subsystems = self.status_service.get()
        ok = all(subsystem["ok"] for subsystem in subsystems)
        response = StatusResponse(ok=ok,
                                  subsystems=[SubSystemStatusResponse(ok=subsystem["ok"],
                                                                      message=subsystem["message"],
                                                                      subsystem=subsystem["subsystem"])
                                              for subsystem in subsystems])
        if ok:
            return response
        else:
            raise endpoints.InternalServerErrorException(response)
开发者ID:DataBiosphere,项目名称:bond,代码行数:28,代码来源:main.py


示例10: get_status_dict

 def get_status_dict(self):
   # It will returns a serialized status in mem_cache
   serialized_status = memcache.get_multi(self.status_ids,
                                               key_prefix='status')
   # Just copying my status_ids list to make some changes localy
   missing_status_ids = list(self.status_ids)
   game_status = {}
   for status_id, status in serialized_status.iteritems():
     game_status[status_id] = deserialize(status)
     missing_status_ids.remove(status_id)
   
   # Taking the missing status in database and add them in memcache
   if missing_status_ids:
     missing_status = Status.get(missing_status_ids)
     serialized_status = {}
     for status in missing_status:
       game_status[status_id] = deserialize(status)
       serialized_status[status.id] = serialize(status)
       
     memcache.set_multi(serialized_status, key_prefix='status')
   
   # I really dunno why, but the game_status list in this function
   # works like a list of string, and when this function pass to some
   # function or when it returns, game_status assume its really identity
   # that is a list of status, not a list of strings... (crazy, I know)
   self.actualise_status(game_status)
   
   return game_status # Returns a random list of Status playing this game
开发者ID:virtualjoker,项目名称:jankenpony,代码行数:28,代码来源:game.py


示例11: load_go_terms

def load_go_terms():
    info = {
        'database': 'go',
        'collection': 'terms',
        'url': 'http://geneontology.org/ontology/go.obo',
        'timestamp': time.time()
    }
    client = pymongo.MongoClient()
    collection = client[info['database']][info['collection']]
    collection.drop()
    with mktemp() as pathname:
        filename = os.path.join(pathname, 'go.obo')
        log.debug('downloading %s to %s', info['url'], filename)
        subprocess.call(['wget', info['url'], '-O', filename])
        with open(filename, 'rt') as fid:
            status = Status(filename, log).fid(fid).start()
            obj = None
            state = None
            for line in fid:
                status.log()
                line = line.strip()
                if line and not line.startswith('!'):
                    if line[0] == '[' and line[-1] == ']':
                        if state == 'Term' and obj:
                            collection.insert(obj)
                        state = line[1:-1]
                        obj = {}
                    elif state == 'Term':
                        key, _, value = line.partition(': ')
                        if value:
                            if key == 'id':
                                obj['go'] = value
                            else:
                                try:
                                    obj[key].append(value)
                                except KeyError:
                                    obj[key] = value
                                except AttributeError:
                                    obj[key] = [obj[key], value]
            status.stop()

    if state == 'Term' and obj:
        collection.insert(obj)

    collection.create_index('go')

    update_info(info)
开发者ID:ndexbio,项目名称:ndex-nav,代码行数:47,代码来源:go.py


示例12: read_net

 def read_net(self, event=None):
     if self.reading_net: return gtk.TRUE
     self.reading_net = True
     inKB, outKB = Status.getNet()
     if inKB > 9999: inKB = 999
     if outKB > 999: outKB = 999
     pingTimeGoogle = Status.getPingTime("google.com")
     
     if self.gw == None:
         self.gw = get_gw()
         print "gateway:", self.gw
     if self.gw != None:
         pingTimeGW = Status.getPingTime(self.gw, 2)
         self.statusStr = "%04d" % inKB +":"+"%03d" % outKB +"K/s " + " " + \
                          pingTimeGoogle + "|" + pingTimeGW + "ms"
         if pingTimeGW == "-1":
             try:
                 self.gw = get_gw()
                 print "gateway:", self.gw
             except:
                 pass
         self.statusStr = self.statusStr
     else:
         self.statusStr = strike("NET ")
     print "%.2f " % (time.time() - self.t), self.statusStr
     self.ind.set_label(self.statusStr)
     if self.gw != None:
         fullStatusStr = "UP: %03d" % inKB +"K/s\n"+"DOWN: %03d" % outKB +"K/s\n" + \
                         "Google ping: " + pingTimeGoogle + "ms\n" + \
                         "GW (" + self.gw + ") ping: " + pingTimeGW
     else:
         fullStatusStr = "No network"
     self.netMenuItem.set_label(fullStatusStr)
     self.counter += 1
     icon_name = "network"
     net_level = 5.0
     if outKB >= net_level: 
         icon_name += "-transmit"
     if inKB >= net_level:
         icon_name += "-receive"
     if outKB < net_level and inKB < net_level:
         icon_name += "-idle"
     self.ind.set_icon(icon_name)
     self.t = time.time()
     self.reading_net = False
     return gtk.TRUE
开发者ID:shofmeyr,项目名称:indicators,代码行数:46,代码来源:indicator-net.py


示例13: __init__

    def __init__(self):
        sam_base_url = config.get('sam', 'BASE_URL')

        providers = {provider_name: FenceApi(config.get(provider_name, 'FENCE_BASE_URL'))
                     for provider_name in config.sections() if provider_name != 'sam'}

        sam_api = SamApi(sam_base_url)
        self.status_service = Status(sam_api, providers)
开发者ID:DataBiosphere,项目名称:bond,代码行数:8,代码来源:main.py


示例14: get

  def get(self):
    twitter = TwitterClient()
    statuses = Status.getStatuses(20)
    user = twitter.getUser( self.username )

    def urlify(txt):
      if txt:
        txt = re.sub('(https?:\/\/[-_.!~*\'()a-zA-Z0-9;/?:@&=+$,%#]+)',  
                 '<a href="\\1">Link</a>', txt)
      return txt

    def getMapUrl(loc,type):
      if not loc:
        return None;

      if type == "google" :
        url = u'http://maps.google.com/staticmap?'
        url += urllib.urlencode( {
          'center'  : str(loc.lat) + ',' + str(loc.lon),
          'markers' : str(loc.lat) + ',' + str(loc.lon),
          'size'    : '460x320',
          'zoom'    : '15',
          'key'     : self.google_key,
        } )
      else :
        url = u'http://tp.map.yahoo.co.jp/mk_map?'
        url += urllib.urlencode( {
          'prop'      : 'clip_map',
          'scalebar'  : 'off',
          'pointer'   : 'off',
          'width'     : '460',
          'height'    : '320',
          'datum'     : 'wgs84',
          'lat'       : loc.lat,
          'lon'       : loc.lon,
          'pin'      : str(loc.lat) + "," + str(loc.lon),
          'sc'        : 4,
        })

      return url
  
    list = []
    for status in statuses:
      list.append( {
          'text'  : status.text,
          'reply' : urlify(status.reply),
          'user_screen_name' : status.user_screen_name,
          'user_profile_image_url' : status.user_profile_image_url,
          'loc_url' : status.loc_url,
          'map'   : getMapUrl( status.loc_point , status.loc_type ),
      })

    values = {
               'list'   : list,
               'user'   : user,
                }
    path = os.path.join(os.path.dirname(__file__), 'main.html')
    self.response.out.write( template.render(path,values))
开发者ID:hirotoshi,项目名称:twittmap,代码行数:58,代码来源:main.py


示例15: update

def update():
    status = Status.instance()
    updates = request.get_data().split("&")
    for u in updates:
        key, value = u.split("=")
        print "updating {0} to {1}".format(key, value)
        status.update(key, value)

    return ""
开发者ID:kevinteg,项目名称:VirtualCyberQ,代码行数:9,代码来源:views.py


示例16: __init__

 def __init__(self):
     self.adc = ADCReader()
     self.config = Config()
     self.status = Status()
     self.controller = Controller()
     self.freeze_status = 0
     self.filter_status = 0
     self.last_alert = datetime.datetime.utcfromtimestamp(0)
     self.adclock = threading.Lock()
     Timer(30.0, self.filter_timer).start()
开发者ID:eneas193933,项目名称:hot-tub-controller,代码行数:10,代码来源:startup.py


示例17: api_statuses_post_list

def api_statuses_post_list():
    if not request.mimetype == 'application/json':
        return BadRequest("Wrong content-type. Need json.")

    data = request.json
    if 'message' not in data or data['message'] not in STATUS_CHOICES:
        return BadRequest("Missing or invalid message field. "
                          "Possible values: %s." % STATUS_CHOICES)

    status = Status(message=data['message'])
    try:
        session.add(status)
        session.commit()
    except:
        # Not sure what else can happen but.. you never know!
        session.rollback()
        return BadRequest()

    return jsonify(status.serialize())
开发者ID:c-m,项目名称:mood-meter,代码行数:19,代码来源:app.py


示例18: parse_edges

def parse_edges(dir, meta_id, id_to_symbol, id_to_ensembl, threshold):
    for filename in glob.glob(os.path.join(dir, '*.cor')):
        with open(filename) as fid:
            status = Status('processing ' + filename, logger=log).fid(fid).start()
            for line in fid:
                status.log()
                try:
                    source, target, correlation, pvalue = line.split()
                    correlation = float(correlation)
                except Exception as e:
                    log.error(e.message)
                    continue

                if math.fabs(correlation) > threshold:
                    try:
                        yield {'source': id_to_ensembl[source], 'target': id_to_ensembl[target], 'correlation': correlation, 'pvalue': float(pvalue), 'meta': meta_id}
                    except KeyError as e:
                        log.error('could not map identifier %s (%s)', e.message, id_to_symbol.get(e.message))

            status.stop()
开发者ID:ndexbio,项目名称:ndex-nav,代码行数:20,代码来源:tcga.py


示例19: qiudog

def qiudog(request):
    statuses = Status.get_friends_statuses(30)
    for status in statuses:
        for pic in status.pic_urls:
            pic.thumbnail_pic = pic.thumbnail_pic.replace('thumbnail','large')
        if hasattr(status,'retweeted_status'):
            for pic in status.retweeted_status.pic_urls:
                pic.thumbnail_pic = pic.thumbnail_pic.replace('thumbnail','large')
    lastBuildDate = statuses[0].created_at

    return render_to_response('rss.xhtml',locals())
开发者ID:ruijzhan,项目名称:weiborss,代码行数:11,代码来源:views.py


示例20: load_go_genes

def load_go_genes():
    info = {
        'database': 'go',
        'collection': 'genes',
        'url': 'http://geneontology.org/gene-associations/gene_association.goa_human.gz',
        'timestamp': time.time()
    }
    client = pymongo.MongoClient()
    collection = client[info['database']][info['collection']]
    collection.drop()
    with mktemp() as pathname:
        filename = os.path.join(pathname, 'gene_association.goa_human.gz')
        log.debug('downloading %s to %s', info['url'], filename)
        subprocess.call(['wget', info['url'], '-O', filename])
        log.debug('gunzip %s', filename)
        subprocess.call(['gunzip', filename])
        filename, _ = os.path.splitext(filename)

        with open(filename, 'rt') as fid:
            log.debug('creating a name to emsembl id lookup table from go genes...')
            go_genes = set([line.split('\t')[2] for line in fid if not line.startswith('!')])

        name_to_id = genemania.id_lookup_table(go_genes)

        with open(filename, 'rt') as fid:
            status = Status(filename, log).fid(fid).start()
            for line in fid:
                status.log()
                if not line.startswith('!'):
                    tokens = line.split('\t')
                    obj = {
                        'gene': name_to_id.get(tokens[2]),
                        'go': tokens[4]
                    }
                    collection.insert(obj)
            status.stop()

    update_info(info)
    collection.create_index('go')
    collection.create_index('gene')
开发者ID:ndexbio,项目名称:ndex-nav,代码行数:40,代码来源:go.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python helper.Teacher类代码示例发布时间:2022-05-27
下一篇:
Python var_model.VAR类代码示例发布时间: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