Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

release.py 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (c) Twisted Matrix Laboratories.
  2. # See LICENSE for details.
  3. """
  4. A release-automation toolkit.
  5. Don't use this outside of Twisted.
  6. Maintainer: Christopher Armstrong
  7. """
  8. import os
  9. # errors
  10. class DirectoryExists(OSError):
  11. """
  12. Some directory exists when it shouldn't.
  13. """
  14. pass
  15. class DirectoryDoesntExist(OSError):
  16. """
  17. Some directory doesn't exist when it should.
  18. """
  19. pass
  20. class CommandFailed(OSError):
  21. pass
  22. # utilities
  23. def sh(command, null=True, prompt=False):
  24. """
  25. I'll try to execute C{command}, and if C{prompt} is true, I'll
  26. ask before running it. If the command returns something other
  27. than 0, I'll raise C{CommandFailed(command)}.
  28. """
  29. print("--$", command)
  30. if prompt:
  31. if input("run ?? ").startswith("n"):
  32. return
  33. if null:
  34. command = "%s > /dev/null" % command
  35. if os.system(command) != 0:
  36. raise CommandFailed(command)
  37. def runChdirSafe(f, *args, **kw):
  38. origdir = os.path.abspath(".")
  39. try:
  40. return f(*args, **kw)
  41. finally:
  42. os.chdir(origdir)