コード例 #1
0
def _RunGsutilCommand(command_name, command_arg_str, run_concurrent=False):
    """Runs the specified gsutil command and returns the command's exit code.

  Args:
    command_name: The gsutil command to run.
    command_arg_str: Arguments to pass to the command.
    run_concurrent: Whether concurrent uploads should be enabled while running
      the command.

  Returns:
    The exit code of the call to the gsutil command.
  """
    command_path = _GetGsutilPath()

    if run_concurrent:
        command_args = ['-m', command_name]
    else:
        command_args = [command_name]

    command_args += command_arg_str.split(' ')
    env = None

    if platforms.OperatingSystem.Current(
    ) == platforms.OperatingSystem.WINDOWS:
        gsutil_args = execution_utils.ArgsForCMDTool(command_path + '.cmd',
                                                     *command_args)
    else:
        gsutil_args = execution_utils.ArgsForShellTool(command_path,
                                                       *command_args)
    log.debug('Running command: [{args}], Env: [{env}]'.format(
        args=' '.join(gsutil_args), env=env))
    return execution_utils.Exec(gsutil_args, no_exit=True, env=env)
コード例 #2
0
def ExecuteCMDTool(tool_dir, exec_name, *args):
    """Execute the given batch file with the given args.

  Args:
    tool_dir: the directory the tool is located in
    exec_name: additional path to the executable under the tool_dir
    *args: args for the command
  """
    _ExecuteTool(
        execution_utils.ArgsForCMDTool(_FullPath(tool_dir, exec_name), *args))
コード例 #3
0
def ArgsForGCDEmulator(*args):
    """Constucts an argument list for calling the GCD emulator.

  Args:
    *args: args for the emulator.

  Returns:
    An argument list to execute the GCD emulator.
  """
    current_os = platforms.OperatingSystem.Current()
    if current_os is platforms.OperatingSystem.WINDOWS:
        gcd_executable = os.path.join(GetGCDRoot(), 'gcd.cmd')
        return execution_utils.ArgsForCMDTool(gcd_executable, *args)
    else:
        gcd_executable = os.path.join(GetGCDRoot(), 'gcd.sh')
        return execution_utils.ArgsForShellTool(gcd_executable, *args)