def PrepareGCDDataDir(data_dir):
  """Prepares the given directory using gcd create.

  Raises:
    UnableToPrepareDataDir: If the gcd create execution fails.

  Args:
    data_dir: str, Path of data directy to be prepared.
  """
  if os.path.isdir(data_dir) and os.listdir(data_dir):
    log.warn('Reusing existing data in [{0}].'.format(data_dir))
    return

  gcd_create_args = ['create']
  project = properties.VALUES.core.project.Get(required=True)
  gcd_create_args.append('--project_id={0}'.format(project))
  gcd_create_args.append(data_dir)
  exec_args = ArgsForGCDEmulator(*gcd_create_args)

  log.status.Print('Executing: {0}'.format(' '.join(exec_args)))
  process = util.Exec(exec_args)
  util.PrefixOutput(process, DATASTORE)
  failed = process.poll()

  if failed:
    raise UnableToPrepareDataDir()
Beispiel #2
0
def Start(args):
    pubsub_args = BuildStartArgs(ToArgsList(args),
                                 platforms.OperatingSystem.Current())
    log.status.Print('Executing: {0}'.format(' '.join(pubsub_args)))
    pubsub_process = util.Exec(pubsub_args)
    util.WriteEnvYaml(GetEnv(args), args.data_dir)
    util.PrefixOutput(pubsub_process, PUBSUB)
def PrepareGCDDataDir(args):
    """Prepares the given directory using gcd create.

  Raises:
    UnableToPrepareDataDir: If the gcd create execution fails.

  Args:
    args: The arguments passed to the command.
  """
    data_dir = args.data_dir
    if os.path.isdir(data_dir) and os.listdir(data_dir):
        log.warn('Reusing existing data in [{0}].'.format(data_dir))
        return

    gcd_create_args = ['create']
    project = properties.VALUES.core.project.Get(required=True)
    gcd_create_args.append('--project_id={0}'.format(project))
    gcd_create_args.append(data_dir)
    exec_args = ArgsForGCDEmulator(gcd_create_args, args)

    log.status.Print('Executing: {0}'.format(' '.join(exec_args)))
    with util.Exec(exec_args) as process:
        util.PrefixOutput(process, DATASTORE)
        failed = process.poll()
        if failed:
            raise UnableToPrepareDataDir()
def StartGCDEmulator(args):
  """Starts the datastore emulator with the given arguments.

  Args:
    args: Arguments passed to the start command.

  Returns:
    process, The handle of the child process running the datastore emulator.
  """
  gcd_start_args = ['start']
  gcd_start_args.append('--host={0}'.format(args.host_port.host))
  gcd_start_args.append('--port={0}'.format(args.host_port.port))
  gcd_start_args.append('--store_on_disk={0}'.format(args.store_on_disk))
  gcd_start_args.append('--consistency={0}'.format(args.consistency))
  gcd_start_args.append('--allow_remote_shutdown')
  gcd_start_args.append(args.data_dir)
  exec_args = ArgsForGCDEmulator(*gcd_start_args)

  log.status.Print('Executing: {0}'.format(' '.join(exec_args)))
  return util.Exec(exec_args)
def Start(args):
    bigtable_args = BuildStartArgs(util.BuildArgsList(args))
    log.status.Print('Executing: {0}'.format(' '.join(bigtable_args)))
    with util.Exec(bigtable_args) as bigtable_process:
        util.WriteEnvYaml(GetEnv(args), GetDataDir())
        util.PrefixOutput(bigtable_process, BIGTABLE)
def Start(args, log_file=None):
  pubsub_args = BuildStartArgs(
      util.BuildArgsList(args), platforms.OperatingSystem.Current())
  log.status.Print('Executing: {0}'.format(' '.join(pubsub_args)))
  return util.Exec(pubsub_args, log_file=log_file)