1
0

tox-helper.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # This script exists so that path handling when running tox works for both Linux and Windows
  4. # Import Python Libs
  5. from __future__ import absolute_import, unicode_literals
  6. import os
  7. import shutil
  8. import argparse
  9. import tempfile
  10. def main():
  11. parser = argparse.ArgumentParser()
  12. parser.add_argument(
  13. '--rootdir',
  14. default=os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
  15. )
  16. subparsers = parser.add_subparsers(help='sub-command help', dest='subparser')
  17. subparsers.add_parser('create-dirs')
  18. subparsers.add_parser('move-artifacts')
  19. options = parser.parse_args()
  20. if options.subparser == 'create-dirs':
  21. for dirname in ('logs', 'coverage', 'xml-unittests-output'):
  22. path = os.path.join(options.rootdir, 'artifacts', dirname)
  23. if not os.path.exists(path):
  24. os.makedirs(path)
  25. if options.subparser == 'move-artifacts':
  26. tmp_artifacts_dir = os.path.join(tempfile.gettempdir(), 'artifacts')
  27. if not os.path.exists(tmp_artifacts_dir):
  28. os.makedirs(tmp_artifacts_dir)
  29. for dirname in ('logs', 'coverage', 'xml-unittests-output'):
  30. src = os.path.join(options.rootdir, 'artifacts', dirname)
  31. dst = os.path.join(tmp_artifacts_dir, dirname)
  32. shutil.copytree(src, dst)
  33. if __name__ == '__main__':
  34. main()