native_client_sdk/src/tools/oshelpers.py
def Remove(args):
  """A Unix style rm.

  Removes the list of paths.  Because of possible temporary failures do to locks
  (such as anti-virus software on Windows), the function will retry up to five
  times.
  """
  parser = argparse.ArgumentParser(usage='rm [Options] PATHS...',
                                   description=Remove.__doc__)
  parser.add_argument(
      '-R', '-r', '--recursive', dest='recursive', action='store_true',
      default=False,
      help='remove directories recursively.')
  parser.add_argument(
      '-v', '--verbose', dest='verbose', action='store_true',
      default=False,
      help='verbose output.')
  parser.add_argument(
      '-f', '--force', dest='force', action='store_true',
      default=False,
      help='force, do not error it files does not exist.')
  parser.add_argument('files', nargs='+')
  options = parser.parse_args(args)

  try:
    for pattern in options.files:
      dst_files = glob.glob(pattern)
      if not dst_files:
        # Ignore non existing files when using force
        if options.force:
          continue
        raise OSError('rm: no such file or directory: ' + pattern)

      for dst in dst_files:
        if options.verbose:
          print('rm ' + dst)

        if os.path.isfile(dst) or os.path.islink(dst):
          for _ in range(5):
            try:
              # Check every time, since it may have been deleted after the
              # previous failed attempt.
              if os.path.isfile(dst) or os.path.islink(dst):
                os.remove(dst)
              break
            except OSError as error:
              print('Failed remove with %s, retrying' % error)
              time.sleep(5)
          else:
            print('Gave up.')
            raise OSError('rm: ' + str(error))

        if options.recursive:
          for _ in range(5):
            try:
              if os.path.isdir(dst):
                if sys.platform == 'win32':
                  # shutil.rmtree doesn't handle junctions properly. Let's just
                  # shell out to rd for this.
                  subprocess.check_call([
                      'rd', '/s', '/q', os.path.normpath(dst)], shell=True)
                else:
                  shutil.rmtree(dst)
              break
            except OSError as error:
              print('Failed rmtree with %s, retrying' % error)
              time.sleep(5)
          else:
            print('Gave up.')
            raise OSError('rm: ' + str(error))

  except OSError as error:
    print(error)

  return 0
A Unix style rm.

  Removes the list of paths.  Because of possible temporary failures do to locks
  (such as anti-virus software on Windows), the function will retry up to five
  times.
  
A Unix style rm.
Removes the list of paths.  Because of possible temporary failures do to locks
(such as anti-virus software on Windows), the function will retry up to five
times.
A Unix style rm . Removes the list of paths . Because of possible temporary failures do to locks ( such as anti - virus software on Windows ) the function will retry up to five times .
def Remove(args):
  parser = argparse.ArgumentParser(usage='rm [Options] PATHS...',
                                   description=Remove.__doc__)
  parser.add_argument(
      '-R', '-r', '--recursive', dest='recursive', action='store_true',
      default=False,
      help='remove directories recursively.')
  parser.add_argument(
      '-v', '--verbose', dest='verbose', action='store_true',
      default=False,
      help='verbose output.')
  parser.add_argument(
      '-f', '--force', dest='force', action='store_true',
      default=False,
      help='force, do not error it files does not exist.')
  parser.add_argument('files', nargs='+')
  options = parser.parse_args(args)
  try:
    for pattern in options.files:
      dst_files = glob.glob(pattern)
      if not dst_files:
        if options.force:
          continue
        raise OSError('rm: no such file or directory: ' + pattern)
      for dst in dst_files:
        if options.verbose:
          print('rm ' + dst)
        if os.path.isfile(dst) or os.path.islink(dst):
          for _ in range(5):
            try:
              if os.path.isfile(dst) or os.path.islink(dst):
                os.remove(dst)
              break
            except OSError as error:
              print('Failed remove with %s, retrying' % error)
              time.sleep(5)
          else:
            print('Gave up.')
            raise OSError('rm: ' + str(error))
        if options.recursive:
          for _ in range(5):
            try:
              if os.path.isdir(dst):
                if sys.platform == 'win32':
                  subprocess.check_call([
                      'rd', '/s', '/q', os.path.normpath(dst)], shell=True)
                else:
                  shutil.rmtree(dst)
              break
            except OSError as error:
              print('Failed rmtree with %s, retrying' % error)
              time.sleep(5)
          else:
            print('Gave up.')
            raise OSError('rm: ' + str(error))
  except OSError as error:
    print(error)
  return 0
def Remove ( args ) : parser = argparse . ArgumentParser ( usage = 'rm [Options] PATHS...' , description = Remove . __doc__ ) parser . add_argument ( '-R' , '-r' , '--recursive' , dest = 'recursive' , action = 'store_true' , default = False , help = 'remove directories recursively.' ) parser . add_argument ( '-v' , '--verbose' , dest = 'verbose' , action = 'store_true' , default = False , help = 'verbose output.' ) parser . add_argument ( '-f' , '--force' , dest = 'force' , action = 'store_true' , default = False , help = 'force, do not error it files does not exist.' ) parser . add_argument ( 'files' , nargs = '+' ) options = parser . parse_args ( args ) try : for pattern in options . files : dst_files = glob . glob ( pattern ) if not dst_files : if options . force : continue raise OSError ( 'rm: no such file or directory: ' + pattern ) for dst in dst_files : if options . verbose : print ( 'rm ' + dst ) if os . path . isfile ( dst ) or os . path . islink ( dst ) : for _ in range ( 5 ) : try : if os . path . isfile ( dst ) or os . path . islink ( dst ) : os . remove ( dst ) break except OSError as error : print ( 'Failed remove with %s, retrying' % error ) time . sleep ( 5 ) else : print ( 'Gave up.' ) raise OSError ( 'rm: ' + str ( error ) ) if options . recursive : for _ in range ( 5 ) : try : if os . path . isdir ( dst ) : if sys . platform == 'win32' : subprocess . check_call ( [ 'rd' , '/s' , '/q' , os . path . normpath ( dst ) ] , shell = True ) else : shutil . rmtree ( dst ) break except OSError as error : print ( 'Failed rmtree with %s, retrying' % error ) time . sleep ( 5 ) else : print ( 'Gave up.' ) raise OSError ( 'rm: ' + str ( error ) ) except OSError as error : print ( error ) return 0
A Unix style rm.
A Unix style rm .
"""A Unix style rm.

  Removes the list of paths.  Because of possible temporary failures do to locks
  (such as anti-virus software on Windows), the function will retry up to five
  times.
  """ # Ignore non existing files when using force # Check every time, since it may have been deleted after the # previous failed attempt. # shutil.rmtree doesn't handle junctions properly. Let's just # shell out to rd for this.
args