gitc_delete.py 1.6 KB

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