當前位置: 首頁>>代碼示例>>Python>>正文


Python httplib.NOT_FOUND屬性代碼示例

本文整理匯總了Python中httplib.NOT_FOUND屬性的典型用法代碼示例。如果您正苦於以下問題:Python httplib.NOT_FOUND屬性的具體用法?Python httplib.NOT_FOUND怎麽用?Python httplib.NOT_FOUND使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在httplib的用法示例。


在下文中一共展示了httplib.NOT_FOUND屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: query_session_hosts

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def query_session_hosts(session, user=None):
    """
    :type session: Session
    :type user: User
    """
    session = Session.objects.with_id(session)
    if not session:
        return None, httplib.NOT_FOUND

    host_ids = set()
    for event in DataModelEvent.objects(sessions=session):
        event.update_host()
        if event.host:
            host_ids.add(event.host.id)

    host_list = [Host.objects.with_id(_) for _ in host_ids]
    return host_list, httplib.OK 
開發者ID:mitre,項目名稱:cascade-server,代碼行數:19,代碼來源:api.py

示例2: query_job

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def query_job(job, user=None):
    """
    :type job: Job
    :type user: User
    """
    job = Job.objects.with_id(job), httplib.OK
    if job is None:
        return None, httplib.NOT_FOUND

    if request.method == 'GET':
        return job, httplib.OK

    elif request.method == 'POST':
        return job.modify(**request.json), httplib.OK

    elif job and request.method == 'DELETE':
        job.delete()
        return None, httplib.OK 
開發者ID:mitre,項目名稱:cascade-server,代碼行數:20,代碼來源:api.py

示例3: automate_session

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def automate_session(session, user=None):
    """
    :type session: cascade.session.Session
    :type user: User
    """
    session = Session.objects.with_id(session)
    if not session:
        return None, httplib.NOT_FOUND

    if isinstance(request.json, dict):
        if request.json.get('analytics') is not None:
            requested_analytics = request.json['analytics']

            for requested_analytic in requested_analytics:
                analytic = Analytic.objects.with_id(requested_analytic['_id'])
                if analytic:
                    mode = requested_analytic.get('mode', analytic.mode)
                    config = AnalyticConfiguration(analytic=analytic, mode=mode)
                    session.update(add_to_set__state__analytics=config)
                    job = AnalyticJob.update_existing(analytic=analytic, user=user, session=session, mode=mode)
                    job.submit()
            return len(requested_analytics), httplib.OK

    return 0, httplib.BAD_REQUEST 
開發者ID:mitre,項目名稱:cascade-server,代碼行數:26,代碼來源:api.py

示例4: investigate_event

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def investigate_event(session, event, user=None):
    """
    :type session: cascade.session.Session
    :type user: User
    """
    session = Session.objects.with_id(session)
    if not session:
        return None, httplib.NOT_FOUND

    event = DataModelEvent.objects.with_id(event)
    if event is None or session.id not in {_.id for _ in event.sessions}:
        return None, httplib.NOT_FOUND

    job = InvestigateJob.update_existing(session=session, event=event, user=user)
    job.submit()
    return None, httplib.OK 
開發者ID:mitre,項目名稱:cascade-server,代碼行數:18,代碼來源:api.py

示例5: get_flows

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def get_flows(address, dpid):
    assert type(dpid) == int

    flows = []
    try:
        path = '%s%d' % (_FLOW_PATH_BASE, dpid)
        flows = json.loads(_do_request(address, path).read())[str(dpid)]
    except IOError as e:
        LOG.error('REST API(%s) is not available.', address)
        raise
    except httplib.HTTPException as e:
        if e[0].status == httplib.NOT_FOUND:
            pass  # switch already deleted
        else:
            LOG.error('REST API(%s, path=%s) request error.', address, path)
            raise
    return flows 
開發者ID:OpenState-SDN,項目名稱:ryu,代碼行數:19,代碼來源:proxy.py

示例6: test_get_config_by_hash

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def test_get_config_by_hash(self):
    self.mock(storage, 'get_configs_by_hashes_async', mock.Mock())
    storage.get_configs_by_hashes_async.return_value = future({
      'deadbeef': 'some content',
    })

    req = {'content_hash': 'deadbeef'}
    resp = self.call_api('get_config_by_hash', req).json_body

    self.assertEqual(resp, {
      'content': base64.b64encode('some content'),
    })

    storage.get_configs_by_hashes_async.return_value = future({
      'deadbeef': None,
    })
    with self.call_should_fail(httplib.NOT_FOUND):
      self.call_api('get_config_by_hash', req)

  ##############################################################################
  # get_projects 
開發者ID:luci,項目名稱:luci-py,代碼行數:23,代碼來源:api_test.py

示例7: _promote_draft_model_callback

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def _promote_draft_model_callback(searchinfo):
        """
        a closure function that take the necessary info to clone a model within the same namespace.
        Args:
            searchinfo:

        Returns:
            (func) a callback to copy_model that takes model_name <string> as an argument
        """

        def callback(model_name):
            draft_model_name = get_experiment_draft_model_name(model_name)

            try:
                return copy_model(searchinfo, draft_model_name, searchinfo, model_name)
            except ModelNotFoundException as e:
                cexc.log_traceback()
                logger.error(e)
                raise SplunkRestProxyException("%s: %s" % (str(e), draft_model_name), logging.ERROR, httplib.NOT_FOUND)

        return callback 
開發者ID:nccgroup,項目名稱:Splunking-Crime,代碼行數:23,代碼來源:experiment_store.py

示例8: _handle_head

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def _handle_head(gcs_stub, filename):
  """Handle HEAD request."""
  filestat = gcs_stub.head_object(filename)
  if not filestat:
    return _FakeUrlFetchResult(httplib.NOT_FOUND, {}, '')

  http_time = common.posix_time_to_http(filestat.st_ctime)

  response_headers = {
      'x-goog-stored-content-length': filestat.st_size,
      'content-length': 0,
      'content-type': filestat.content_type,
      'etag': filestat.etag,
      'last-modified': http_time
  }

  if filestat.metadata:
    response_headers.update(filestat.metadata)

  return _FakeUrlFetchResult(httplib.OK, response_headers, '') 
開發者ID:GoogleCloudPlatform,項目名稱:python-compat-runtime,代碼行數:22,代碼來源:stub_dispatcher.py

示例9: HasProjectReadAccess

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def HasProjectReadAccess(environ):
  """Assert that the current user has project read permissions.

  Args:
    environ: the current WSGI environ

  Returns:
    True if the current user has read access to the current project.
  """
  project = environ['playground.project']
  if not project:
    Abort(httplib.NOT_FOUND, 'requested read access to non-existent project')
  access_key = environ.get('mimic.access_key')
  if access_key and access_key == project.access_key:
    return True
  if users.is_current_user_admin():
    return True
  user = environ.get('playground.user', None)
  if user and user.key.id() in project.writers:
    return True
  if settings.PUBLIC_PROJECT_TEMPLATE_OWNER in project.writers:
    return True
  if settings.MANUAL_PROJECT_TEMPLATE_OWNER in project.writers:
    return True
  return False 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:27,代碼來源:shared.py

示例10: HasProjectWriteAccess

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def HasProjectWriteAccess(environ):
  """Assert that the current user has project write permissions.

  Args:
    environ: the current WSGI environ

  Returns:
    True if the current user as write access to the current project.
  """
  project = environ['playground.project']
  if not project:
    Abort(httplib.NOT_FOUND, 'requested write access to non-existent project')
  if users.is_current_user_admin():
    return True
  user = environ.get('playground.user')
  if user and user.key.id() in project.writers:
    return True
  return False 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:20,代碼來源:shared.py

示例11: post

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def post(self):  # pylint:disable-msg=invalid-name
    """Handles HTTP POST requests."""
    if not users.is_current_user_admin():
      self.response.set_status(httplib.UNAUTHORIZED)
      return
    project_id = self.request.data['project_id']
    if not project_id:
      Abort(httplib.BAD_REQUEST, 'project_id required')
    project = model.GetProject(project_id)
    if not project:
      Abort(httplib.NOT_FOUND,
            'failed to retrieve project {}'.format(project_id))
    repo_url = project.template_url
    repo = model.GetRepo(repo_url)
    model.CreateRepoAsync(owner=model.GetOrCreateUser(repo.owner),
                          repo_url=repo.key.id(),
                          html_url=repo.html_url,
                          name=repo.name,
                          description=repo.description,
                          show_files=repo.show_files,
                          read_only_files=repo.read_only_files,
                          read_only_demo_url=repo.read_only_demo_url) 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:24,代碼來源:playground.py

示例12: get

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def get(self, user_id=None):  # pylint: disable=g-bad-name
    logging.info('UserHandler GET method called with ID: %s', user_id)
    if not user_id or self.user.email == user_id:
      user = self.user
    else:
      user = self._get_another_user(user_id)
    if user:
      user_info = user.to_dict()
      user_info.update({
          'name': user.nickname,
          'permissions': user.permissions,
          'is_admin': user.is_admin,
      })
      self.respond_json(user_info)
    else:
      self.abort(httplib.NOT_FOUND, explanation='User not found') 
開發者ID:google,項目名稱:upvote,代碼行數:18,代碼來源:users.py

示例13: get

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def get(self, rule_key):
    logging.info('Rule handler get method called with key: %s', rule_key)
    key = datastore_utils.GetKeyFromUrlsafe(rule_key)
    if not key:
      self.abort(
          httplib.BAD_REQUEST,
          explanation='Rule key %s could not be parsed' % rule_key)

    rule = key.get()
    if rule:
      response = rule.to_dict()
      response['target_id'] = rule.key.parent().id()
      self.respond_json(response)
    else:
      self.abort(httplib.NOT_FOUND, explanation='Rule not found')


# The Webapp2 routes defined for these handlers. 
開發者ID:google,項目名稱:upvote,代碼行數:20,代碼來源:rules.py

示例14: get

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def get(self, blockable_id):  # pylint: disable=g-bad-name
    """View of single blockable, accessible to anyone with URL."""
    blockable_id = blockable_id.lower()
    logging.info(
        'Blockable handler get method called with ID: %s', blockable_id)
    blockable = binary_models.Blockable.get_by_id(blockable_id)
    if not blockable:
      self.abort(httplib.NOT_FOUND, explanation='Blockable not found')

    # Augment the response dict with related voting data.
    blockable_dict = blockable.to_dict()
    allowed, reason = voting_api.IsVotingAllowed(blockable.key)
    blockable_dict['is_voting_allowed'] = allowed
    blockable_dict['voting_prohibited_reason'] = reason

    self.respond_json(blockable_dict) 
開發者ID:google,項目名稱:upvote,代碼行數:18,代碼來源:blockables.py

示例15: test_admin_api_create__creation_error

# 需要導入模塊: import httplib [as 別名]
# 或者: from httplib import NOT_FOUND [as 別名]
def test_admin_api_create__creation_error(self):
    """Test the App Engine project creation for an invalid project."""
    test_app_engine_admin_api = app_engine.AdminAPI(self.config, mock.Mock())
    test_app_engine_admin_api._client.apps.side_effect = errors.HttpError(
        httplib2.Response({
            'reason': 'Not found.', 'status': http_status.NOT_FOUND}),
        'Project not found.'.encode(encoding='UTF-8'))
    with self.assertRaises(app_engine.CreationError):
      test_app_engine_admin_api.create('us-east1') 
開發者ID:google,項目名稱:loaner,代碼行數:11,代碼來源:app_engine_test.py


注:本文中的httplib.NOT_FOUND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。