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


Python utils.check函数代码示例

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


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

示例1: get_user_tokeninfo

    def get_user_tokeninfo(self):
        """ Get user token details

        Returns:
        --------
        JSON message containing access token details
        e.g.,
        Response 200 OK (application/json)
            {
                "header": {
                    "typ": "JWT",
                    "alg": "RS256"
                },
                "payload": {
                    "jti": "7b1430a2-dd61-4a47-919c-495cadb1ea7b",
                    "iss": "http://enableiot.com",
                    "sub": "53fdff4418b547e4241b8358",
                    "exp": "2014-10-02T07:53:25.361Z"
                }
            }

        """
        url = "{0}/auth/tokenInfo".format(self.base_url)
        resp = requests.get(url, headers=get_auth_headers(self.user_token),
                            proxies=self.proxies, verify=globals.g_verify)
        check(resp, 200)
        js = resp.json()
        return js
开发者ID:bbaltz505,项目名称:iotkit-libpy,代码行数:28,代码来源:connect.py

示例2: delete_topic

	def delete_topic(self):
		try:
			user = check(
				self, 
				users.get_current_user(), 
				lambda: self.redirect(webapp2.uri_for('login')))
			topic_url = check(
				self,
				self.request.get('topic_url'),
				'Unable to delete topic page. No topic specified.')
			topic = check(
				self,
				datastore.Topic.retrieve(topic_url),
				'Unable to delete topic page. Topic cannot be found.')
			correct_user = check(
				self,
				topic.creator_id == user.user_id(),
				'Unable to delete topic page. You are not the user who created the page.')
			topic_name = topic.name
			topic.key.delete()
			datastore.SearchIndexShard.remove_topic(topic_url, topic_name)
			#self.redirect(str(self.request.host_url))
			self.response.write('The page "' + topic_name + '" has been deleted.')
		except AssertionError as e:
			logging.info(str(e.args))
开发者ID:DavidTimms,项目名称:bubl,代码行数:25,代码来源:topic.py

示例3: importScoresByNames

  def importScoresByNames(self, scores, assessmentId = 0, exactGradesourceNames = False):
    if assessmentId == 0:
      assessmentId = self.chooseAssessment()

    GsNameToStudentId, postData = self.parseScoresForm(assessmentId)
    utils.check("Gradesource name -> studentId: ", GsNameToStudentId)
    
    errors = False
    if not exactGradesourceNames:
      ExtNameToGsName = self.matchNames(scores.keys(), GsNameToStudentId.keys())
  
      for extName, GsName in ExtNameToGsName.items():
        postData[GsNameToStudentId[GsName]] = scores[extName]
    else:
      for GsName, score in scores.items():
        if GsName in GsNameToStudentId:
          postData[GsNameToStudentId[GsName]] = score
        else:
          cprint('Missing name: ' + GsName, 'white', 'on_red')
          errors = True
    if errors:
      sys.exit()
    utils.check("Data to post: ", postData)
  
    self.postScores(postData)
    cprint("Go to %s" % (self.assessmentUrl % assessmentId), 'yellow')
开发者ID:qpleple,项目名称:moodle-gradesource,代码行数:26,代码来源:gradesource.py

示例4: login

    def login(self, username, password):
        """ Submit IoT Analytics user credentials to obtain the access token

        Args:
        ----------
        username (str): username for IoT Analytics site
        password (str): password for IoT Analytics site

        Returns:
        Sets user_id and user_token attributes for connection instance
        
        """
        if not username or not password:
            raise ValueError(
                "Invalid parameter: username and password required")

        try:
            url = "{0}/auth/token".format(self.base_url)
            headers = {'content-type': 'application/json'}
            payload = {"username": username, "password": password}
            data = json.dumps(payload)
            resp = requests.post(
                url, data=data, headers=headers, proxies=self.proxies, verify=globals.g_verify)
            check(resp, 200)
            js = resp.json()
            self.user_token = js['token']

            # get my user_id (uid) within the Intel IoT Analytics Platform
            js = self.get_user_tokeninfo()
            self.user_id = js["payload"]["sub"]

        except Exception, err:
            raise RuntimeError('Auth ERROR: %s\n' % str(err))
开发者ID:bbaltz505,项目名称:iotkit-libpy,代码行数:33,代码来源:connect.py

示例5: parse

    def parse(self, data):
        target = self.target
        categories = self.categories
        categories = [getattr(target, i) for i in categories]

        assert all(c.owner is target for c in categories)
        try:
            check(sum(len(c) for c in categories))  # no cards at all

            cid = data
            g = Game.getgame()

            check(isinstance(cid, int))

            cards = g.deck.lookupcards((cid,))

            check(len(cards) == 1)  # Invalid id
            card = cards[0]

            check(card.resides_in.owner is target)
            check(card.resides_in in categories)

            return card

        except CheckFailed:
            return None
开发者ID:17night,项目名称:thbattle,代码行数:26,代码来源:inputlets.py

示例6: apply_action

    def apply_action(self):
        tgt = self.target
        g = Game.getgame()
        n = min(len([p for p in g.players if not p.dead]), 5)
        cards = g.deck.getcards(n)

        assert cards == g.deck.getcards(n)

        tgt.reveal(cards)
        rst = tgt.user_input('ran_prophet', cards, timeout=40)
        if not rst: return False
        try:
            check_type([[int, Ellipsis]]*2, rst)
            upcards = rst[0]
            downcards = rst[1]
            check(sorted(upcards+downcards) == range(n))
        except CheckFailed as e:
            try:
                print 'RAN PROPHET:', upcards, downcards
            except:
                pass
            return act

        deck = g.deck.cards
        for i, j in enumerate(downcards):
            deck[i] = cards[j]
        deck.rotate(-len(downcards))
        for i, j in enumerate(upcards):
            deck[i] = cards[j]

        cl = [cards[i] for i in upcards]
        assert g.deck.getcards(len(upcards)) == cl

        return True
开发者ID:CoolCloud,项目名称:thbattle,代码行数:34,代码来源:ran.py

示例7: apply_action

    def apply_action(self):
        g = Game.getgame()
        target = self.target
        if target.dead: return False

        try:
            while not target.dead:
                try:
                    g.emit_event('action_stage_action', target)
                    self.in_user_input = True
                    with InputTransaction('ActionStageAction', [target]) as trans:
                        p, rst = ask_for_action(
                            self, [target], ('cards', 'showncards'), g.players, trans
                        )
                    check(p is target)
                finally:
                    self.in_user_input = False

                cards, target_list = rst
                g.players.reveal(cards)
                card = cards[0]

                if not g.process_action(ActionStageLaunchCard(target, target_list, card)):
                    # invalid input
                    log.debug('ActionStage: LaunchCard failed.')
                    check(False)

                if self.one_shot or self._force_break:
                    break

        except CheckFailed:
            pass

        return True
开发者ID:TimLang,项目名称:thbattle,代码行数:34,代码来源:actions.py

示例8: cond

 def cond(self, cardlist):
     from .. import cards
     try:
         check(len(cardlist) == 1)
         check(cardlist[0].is_card(cards.RejectCard))
         return True
     except CheckFailed:
         return False
开发者ID:feng2606,项目名称:thbattle,代码行数:8,代码来源:spellcard.py

示例9: get_attributes

 def get_attributes(self):
     url = "{0}/accounts/{1}/devices".format(
         self.client.base_url, self.account_id)
     resp = requests.get(url, headers=get_auth_headers(
         self.client.user_token), proxies=self.client.proxies, verify=globals.g_verify)
     check(resp, 200)
     js = resp.json()
     return js
开发者ID:rrozestw,项目名称:iotkit-lib-python,代码行数:8,代码来源:device.py

示例10: temp

def temp(csvPath, col):
  config = utils.getConfig()
  reader = csv.reader(open(csvPath, 'rU'), delimiter=',')
  data = [{'name': "{0[0]}, {0[1]}".format(row), 'score': row[col], 'pid': row[2]} for row in reader if row[col] not in [0, '0', '-', '']]
  utils.check("Data: ", data)

  g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd'])
  g.importScoresBy(data, 'pid')
开发者ID:qpleple,项目名称:moodle-gradesource,代码行数:8,代码来源:grades.py

示例11: get_user_info

 def get_user_info(self, user_id=None):
     # Get the user's info
     url = "{0}/users/{1}".format(globals.base_url, user_id)
     resp = requests.get(url, headers=get_auth_headers(
         self.client.user_token), proxies=self.client.proxies, verify=globals.g_verify)
     check(resp, 200)
     js = resp.json()
     self.id = js["id"]
     return js
开发者ID:rrozestw,项目名称:iotkit-lib-python,代码行数:9,代码来源:user.py

示例12: __setslice__

    def __setslice__(self, f, t, v):
        '''
        Set time status
        '''
        check(0 <= f < t <= 1440, 'Timeline: f and t should satisfy 0 <= f < t <= 1440!')
        v = str(v)
        check(len(v) > 0, 'Timeline: len(v) == 0!')

        self.tldata = self.tldata[:f] + (v * (int((t - f)/len(v)) + 1))[:(t - f)] + self.tldata[t:]
开发者ID:feisuzhu,项目名称:tennissched,代码行数:9,代码来源:models.py

示例13: __init__

 def __init__(self, name=u'<未指定名字的场地>', tl=None):
     super(self.__class__, self).__init__()
     self.name = unicode(name)
     self.comment = u""
     if tl is not None:
         check(isinstance(tl, WeekTimeline), 'tl must be a WeekTimeline!')
         self.timeavail = tl
     else:
         self.timeavail = WeekTimeline()
开发者ID:feisuzhu,项目名称:tennissched,代码行数:9,代码来源:models.py

示例14: uploadClickerScores

def uploadClickerScores(csvPath, col):
  config = utils.getConfig()

  reader = csv.reader(open(csvPath, 'rU'), delimiter=',')
  # Fields: 0:LN, 1:FN, 2:id, >2:scores
  data = [{'name': '%s, %s' % (row[0], row[1]), 'score': row[col], 'pid': row[2]} for row in reader if row[col] not in [0, '0', '-', '']]
  utils.check("Clicker data: ", data)

  g = Gradesource(config['gradesourceLogin'], config['gradesourcePasswd'])
  g.importScoresBy(data, 'pid')
开发者ID:qpleple,项目名称:moodle-gradesource,代码行数:10,代码来源:grades.py

示例15: get_comp_types

 def get_comp_types(self, full=False):
     url = "{0}/accounts/{1}/cmpcatalog".format(self.client.base_url,
                                                self.account.id)
     if full == True:
         url += "?full=true"
     resp = requests.get(url, headers=get_auth_headers(
         self.client.user_token), proxies=self.client.proxies, verify=globals.g_verify)
     check(resp, 200)
     js = resp.json()
     return js
开发者ID:rrozestw,项目名称:iotkit-lib-python,代码行数:10,代码来源:componentcatalog.py


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