gitc_delete.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright (C) 2015 The Android Open Source Project
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. import sys
  15. from command import Command, GitcClientCommand
  16. import platform_utils
  17. class GitcDelete(Command, GitcClientCommand):
  18. common = True
  19. visible_everywhere = False
  20. helpSummary = "Delete a GITC Client."
  21. helpUsage = """
  22. %prog
  23. """
  24. helpDescription = """
  25. This subcommand deletes the current GITC client, deleting the GITC manifest
  26. and all locally downloaded sources.
  27. """
  28. def _Options(self, p):
  29. p.add_option('-f', '--force',
  30. dest='force', action='store_true',
  31. help='Force the deletion (no prompt).')
  32. def Execute(self, opt, args):
  33. if not opt.force:
  34. prompt = ('This will delete GITC client: %s\nAre you sure? (yes/no) ' %
  35. self.gitc_manifest.gitc_client_name)
  36. response = input(prompt).lower()
  37. if not response == 'yes':
  38. print('Response was not "yes"\n Exiting...')
  39. sys.exit(1)
  40. platform_utils.rmtree(self.gitc_manifest.gitc_client_dir)