当前位置: 首页>>代码示例>>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;未经允许,请勿转载。