python类Key()的实例源码

status.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def handle(self):
    cursor = self.request.get("cursor")
    count = int(self.request.get("count", "50"))

    query = model.MapreduceState.all()
    if cursor:
      query.filter("__key__ >=", db.Key(cursor))
    query.order("__key__")

    jobs_list = query.fetch(count + 1)
    if len(jobs_list) == (count + 1):
      self.json_response["cursor"] = str(jobs_list[-1].key())
      jobs_list = jobs_list[:-1]

    all_jobs = []
    for job in jobs_list:
      out = {

          "name": job.mapreduce_spec.name,
          "mapreduce_id": job.mapreduce_spec.mapreduce_id,
          "active": job.active,
          "start_timestamp_ms":
              int(time.mktime(job.start_time.utctimetuple()) * 1000),
          "updated_timestamp_ms":
              int(time.mktime(job.last_poll_time.utctimetuple()) * 1000),


          "chart_url": job.sparkline_url,
          "chart_width": job.chart_width,
          "active_shards": job.active_shards,
          "shards": job.mapreduce_spec.mapper.shard_count,
      }
      if job.result_status:
        out["result_status"] = job.result_status
      all_jobs.append(out)

    self.json_response["jobs"] = all_jobs
input_readers.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _iter_key_range(self, k_range):
    """Yields a db.Key and the value that should be yielded by self.__iter__().

    Args:
      k_range: The key_range.KeyRange to iterate over.

    Yields:
      A 2-tuple containing the last db.Key processed and the value that should
      be yielded by __iter__. The returned db.Key will be used to determine the
      InputReader's current position in self._current_key_range.
    """
    raise NotImplementedError("_iter_key_range() not implemented in %s" %
                              self.__class__)
blobstore.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __normalize_and_convert_keys(cls, keys):
    """Normalize and convert all keys to BlobKey type.

    This method is based on datastore.NormalizeAndTypeCheck().

    Args:
      keys: A single key or a list/tuple of keys.  Keys may be a string
        or BlobKey

    Returns:
      Single key or list with all strings replaced by BlobKey instances.
    """
    if isinstance(keys, (list, tuple)):
      multiple = True

      keys = list(keys)
    else:
      multiple = False
      keys = [keys]

    for index, key in enumerate(keys):
      if not isinstance(key, (basestring, BlobKey)):
        raise datastore_errors.BadArgumentError(
            'Expected str or BlobKey; received %s (a %s)' % (
                key,
                datastore.typename(key)))
      keys[index] = datastore.Key.from_path(cls.kind(), str(key), namespace='')

    if multiple:
      return keys
    else:
      return keys[0]
__init__.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def advance(self, key):
    """Updates the start of the range immediately past the specified key.

    Args:
      key: A db.Key or ndb.Key.
    """
    self.include_start = False
    if ndb is not None:
      if isinstance(key, ndb.Key):
        key = key.to_old_key()
    self.key_start = key
__init__.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __cmp__(self, other):
    """Compare two key ranges.

    Key ranges with a value of None for key_start or key_end, are always
    considered to have include_start=False or include_end=False, respectively,
    when comparing.  Since None indicates an unbounded side of the range,
    the include specifier is meaningless.  The ordering generated is total
    but somewhat arbitrary.

    Args:
      other: An object to compare to this one.

    Returns:
      -1: if this key range is less than other.
      0:  if this key range is equal to other.
      1: if this key range is greater than other.
    """
    if not isinstance(other, KeyRange):
      return 1

    self_list = [self.key_start, self.key_end, self.direction,
                 self.include_start, self.include_end, self._app,
                 self.namespace]
    if not self.key_start:
      self_list[3] = False
    if not self.key_end:
      self_list[4] = False

    other_list = [other.key_start,
                  other.key_end,
                  other.direction,
                  other.include_start,
                  other.include_end,
                  other._app,
                  other.namespace]
    if not other.key_start:
      other_list[3] = False
    if not other.key_end:
      other_list[4] = False

    return cmp(self_list, other_list)
__init__.py 文件源码 项目:Intranet-Penetration 作者: yuxiaokui 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self,
               key_start=None,
               key_end=None,
               direction=None,
               include_start=True,
               include_end=True,
               namespace=None,
               _app=None):
    """Initialize a KeyRange object.

    Args:
      key_start: The starting key for this range (db.Key or ndb.Key).
      key_end: The ending key for this range (db.Key or ndb.Key).
      direction: The direction of the query for this range.
      include_start: Whether the start key should be included in the range.
      include_end: Whether the end key should be included in the range.
      namespace: The namespace for this range. If None then the current
          namespace is used.

    NOTE: If NDB keys are passed in, they are converted to db.Key
    instances before being stored.
    """




    if direction is None:
      direction = KeyRange.ASC
    assert direction in (KeyRange.ASC, KeyRange.DESC)
    self.direction = direction


    if ndb is not None:
      if isinstance(key_start, ndb.Key):
        key_start = key_start.to_old_key()
      if isinstance(key_end, ndb.Key):
        key_end = key_end.to_old_key()
    self.key_start = key_start
    self.key_end = key_end
    self.include_start = include_start
    self.include_end = include_end
    if namespace is not None:
      self.namespace = namespace
    else:
      self.namespace = namespace_manager.get_namespace()
    self._app = _app
__init__.py 文件源码 项目:MKFQ 作者: maojingios 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self,
               key_start=None,
               key_end=None,
               direction=None,
               include_start=True,
               include_end=True,
               namespace=None,
               _app=None):
    """Initialize a KeyRange object.

    Args:
      key_start: The starting key for this range (db.Key or ndb.Key).
      key_end: The ending key for this range (db.Key or ndb.Key).
      direction: The direction of the query for this range.
      include_start: Whether the start key should be included in the range.
      include_end: Whether the end key should be included in the range.
      namespace: The namespace for this range. If None then the current
          namespace is used.

    NOTE: If NDB keys are passed in, they are converted to db.Key
    instances before being stored.
    """




    if direction is None:
      direction = KeyRange.ASC
    assert direction in (KeyRange.ASC, KeyRange.DESC)
    self.direction = direction


    if ndb is not None:
      if isinstance(key_start, ndb.Key):
        key_start = key_start.to_old_key()
      if isinstance(key_end, ndb.Key):
        key_end = key_end.to_old_key()
    self.key_start = key_start
    self.key_end = key_end
    self.include_start = include_start
    self.include_end = include_end
    if namespace is not None:
      self.namespace = namespace
    else:
      self.namespace = namespace_manager.get_namespace()
    self._app = _app
__init__.py 文件源码 项目:xxNet 作者: drzorm 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self,
               key_start=None,
               key_end=None,
               direction=None,
               include_start=True,
               include_end=True,
               namespace=None,
               _app=None):
    """Initialize a KeyRange object.

    Args:
      key_start: The starting key for this range (db.Key or ndb.Key).
      key_end: The ending key for this range (db.Key or ndb.Key).
      direction: The direction of the query for this range.
      include_start: Whether the start key should be included in the range.
      include_end: Whether the end key should be included in the range.
      namespace: The namespace for this range. If None then the current
          namespace is used.

    NOTE: If NDB keys are passed in, they are converted to db.Key
    instances before being stored.
    """




    if direction is None:
      direction = KeyRange.ASC
    assert direction in (KeyRange.ASC, KeyRange.DESC)
    self.direction = direction


    if ndb is not None:
      if isinstance(key_start, ndb.Key):
        key_start = key_start.to_old_key()
      if isinstance(key_end, ndb.Key):
        key_end = key_end.to_old_key()
    self.key_start = key_start
    self.key_end = key_end
    self.include_start = include_start
    self.include_end = include_end
    if namespace is not None:
      self.namespace = namespace
    else:
      self.namespace = namespace_manager.get_namespace()
    self._app = _app
__init__.py 文件源码 项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self,
               key_start=None,
               key_end=None,
               direction=None,
               include_start=True,
               include_end=True,
               namespace=None,
               _app=None):
    """Initialize a KeyRange object.

    Args:
      key_start: The starting key for this range (db.Key or ndb.Key).
      key_end: The ending key for this range (db.Key or ndb.Key).
      direction: The direction of the query for this range.
      include_start: Whether the start key should be included in the range.
      include_end: Whether the end key should be included in the range.
      namespace: The namespace for this range. If None then the current
          namespace is used.

    NOTE: If NDB keys are passed in, they are converted to db.Key
    instances before being stored.
    """




    if direction is None:
      direction = KeyRange.ASC
    assert direction in (KeyRange.ASC, KeyRange.DESC)
    self.direction = direction


    if ndb is not None:
      if isinstance(key_start, ndb.Key):
        key_start = key_start.to_old_key()
      if isinstance(key_end, ndb.Key):
        key_end = key_end.to_old_key()
    self.key_start = key_start
    self.key_end = key_end
    self.include_start = include_start
    self.include_end = include_end
    if namespace is not None:
      self.namespace = namespace
    else:
      self.namespace = namespace_manager.get_namespace()
    self._app = _app
__init__.py 文件源码 项目:Docker-XX-Net 作者: kuanghy 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self,
               key_start=None,
               key_end=None,
               direction=None,
               include_start=True,
               include_end=True,
               namespace=None,
               _app=None):
    """Initialize a KeyRange object.

    Args:
      key_start: The starting key for this range (db.Key or ndb.Key).
      key_end: The ending key for this range (db.Key or ndb.Key).
      direction: The direction of the query for this range.
      include_start: Whether the start key should be included in the range.
      include_end: Whether the end key should be included in the range.
      namespace: The namespace for this range. If None then the current
          namespace is used.

    NOTE: If NDB keys are passed in, they are converted to db.Key
    instances before being stored.
    """




    if direction is None:
      direction = KeyRange.ASC
    assert direction in (KeyRange.ASC, KeyRange.DESC)
    self.direction = direction


    if ndb is not None:
      if isinstance(key_start, ndb.Key):
        key_start = key_start.to_old_key()
      if isinstance(key_end, ndb.Key):
        key_end = key_end.to_old_key()
    self.key_start = key_start
    self.key_end = key_end
    self.include_start = include_start
    self.include_end = include_end
    if namespace is not None:
      self.namespace = namespace
    else:
      self.namespace = namespace_manager.get_namespace()
    self._app = _app


问题


面经


文章

微信
公众号

扫码关注公众号