コード例 #1
0
 def post(self):
     """Handler for post requests to datastore_admin/backup.create."""
     try:
         backup_prefix = self.request.get('name')
         if not backup_prefix:
             if self.request.headers.get('X-AppEngine-Cron'):
                 backup_prefix = 'cron-'
             else:
                 backup_prefix = 'link-'
         backup_prefix_with_date = backup_prefix + time.strftime('%Y_%m_%d')
         backup_name = backup_prefix_with_date
         backup_suffix_counter = 1
         while BackupInformation.name_exists(backup_name):
             backup_suffix_counter += 1
             backup_name = backup_prefix_with_date + '-' + str(
                 backup_suffix_counter)
         kinds = self.request.get_all('kind')
         if not kinds:
             self.errorResponse('Backup must include at least one kind.')
             return
         for kind in kinds:
             if not utils.IsKindNameVisible(kind):
                 self.errorResponse('Invalid kind %s.' % kind)
                 return
         mapper_params = {'namespace': None}
         _perform_backup(kinds, self.request.get('filesystem'),
                         self.request.get('gs_bucket_name'), backup_name,
                         self.request.get('queue'), mapper_params, 1000000)
     except Exception, e:
         self.errorResponse(e.message)
コード例 #2
0
ファイル: main.py プロジェクト: s27flanker/webProject
  def GetKindsForCurrentNamespace(self, deadline):
    """Obtain a list of all kind names from the datastore.

    Pulls kinds from the current namespace only. The result is alphabetized.

    Args:
      deadline: maximum number of seconds to spend getting kinds.

    Returns:
      kinds: an alphabetized list of kinds for the specified namespace(s).
      more_kinds: a boolean indicating whether there may be additional kinds
          not included in 'kinds' (e.g. because the query limit was reached).
    """
    more_kinds = False
    kind_names = []
    try:
      kinds = metadata.Kind.all().order('__key__').run(batch_size=1000,
                                                       deadline=deadline)
      for kind in kinds:
        kind_name = kind.kind_name
        if utils.IsKindNameVisible(kind_name):
          kind_names.append(kind_name)
    except datastore_errors.Timeout:
      more_kinds = True
      logging.warning('Failed to retrieve all kinds within deadline.')
    return kind_names, more_kinds
コード例 #3
0
 def GetKindsForCurrentNamespace(self):
   """Obtain a list of all kind names from the datastore for the
   current namespace.  The result is alphabetized."""
   kinds = metadata.Kind.all().order('__key__').fetch(99999999)
   kind_names = []
   for kind in kinds:
     kind_name = kind.kind_name
     if utils.IsKindNameVisible(kind_name):
       kind_names.append(kind_name)
   return kind_names
コード例 #4
0
ファイル: main.py プロジェクト: s27flanker/webProject
    def ReadFromKindIters(kind_iter_list):
      """Read kinds from a list of iterators.

      Reads a kind from each iterator in kind_iter_list, adds it to
      kind_name_set, and removes any completed iterators.

      Args:
        kind_iter_list: a list of iterators of kinds.
      """
      completed = []
      for kind_iter in kind_iter_list:
        try:
          kind_name = kind_iter.next().kind_name
          if utils.IsKindNameVisible(kind_name):
            kind_name_set.add(kind_name)
        except StopIteration:
          completed.append(kind_iter)
      for kind_iter in completed:
        kind_iter_list.remove(kind_iter)
コード例 #5
0
  def GetKindsForAllNamespaces(self):
    """Obtain a list of all kind names from the datastore, *regardless*
    of namespace.  The result is alphabetized and deduped."""


    namespace_list = [ns.namespace_name
                      for ns in metadata.Namespace.all().run(limit=99999999)]
    kind_itr_list = [metadata.Kind.all(namespace=ns).run(limit=99999999,
                                                         batch_size=99999999)
                     for ns in namespace_list]


    kind_name_set = set()
    for kind_itr in kind_itr_list:
      for kind in kind_itr:
        kind_name = kind.kind_name
        if utils.IsKindNameVisible(kind_name):
          kind_name_set.add(kind.kind_name)

    kind_name_list = sorted(kind_name_set)
    return kind_name_list