gitc_delete.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # pylint:disable=W0622
  22. input = raw_input
  23. # pylint:enable=W0622
  24. class GitcDelete(Command, GitcClientCommand):
  25. common = True
  26. visible_everywhere = False
  27. helpSummary = "Delete a GITC Client."
  28. helpUsage = """
  29. %prog
  30. """
  31. helpDescription = """
  32. This subcommand deletes the current GITC client, deleting the GITC manifest
  33. and all locally downloaded sources.
  34. """
  35. def _Options(self, p):
  36. p.add_option('-f', '--force',
  37. dest='force', action='store_true',
  38. help='Force the deletion (no prompt).')
  39. def Execute(self, opt, args):
  40. if not opt.force:
  41. prompt = ('This will delete GITC client: %s\nAre you sure? (yes/no) ' %
  42. self.gitc_manifest.gitc_client_name)
  43. response = input(prompt).lower()
  44. if not response == 'yes':
  45. print('Response was not "yes"\n Exiting...')
  46. sys.exit(1)
  47. platform_utils.rmtree(self.gitc_manifest.gitc_client_dir)