gitc_delete.py 1.7 KB

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