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.

PythonTools.py 1.2KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import sys
  2. import time
  3. class Tools:
  4. _public_methods_ = ["reload", "adddir", "echo", "sleep"]
  5. def reload(self, module):
  6. if module in sys.modules:
  7. from importlib import reload
  8. reload(sys.modules[module])
  9. return "reload succeeded."
  10. return "no reload performed."
  11. def adddir(self, dir):
  12. if type(dir) == type(""):
  13. sys.path.append(dir)
  14. return str(sys.path)
  15. def echo(self, arg):
  16. return repr(arg)
  17. def sleep(self, t):
  18. time.sleep(t)
  19. if __name__ == "__main__":
  20. from win32com.server.register import RegisterServer, UnregisterServer
  21. clsid = "{06ce7630-1d81-11d0-ae37-c2fa70000000}"
  22. progid = "Python.Tools"
  23. verprogid = "Python.Tools.1"
  24. if "--unregister" in sys.argv:
  25. print("Unregistering...")
  26. UnregisterServer(clsid, progid, verprogid)
  27. print("Unregistered OK")
  28. else:
  29. print("Registering COM server...")
  30. RegisterServer(
  31. clsid,
  32. "win32com.servers.PythonTools.Tools",
  33. "Python Tools",
  34. progid,
  35. verprogid,
  36. )
  37. print("Class registered.")