gitc_delete.py 1.6 KB

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