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.

tryconnection.py 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. remote = False # automatic testing of remote access has been removed here
  2. def try_connection(verbose, *args, **kwargs):
  3. import adodbapi
  4. dbconnect = adodbapi.connect
  5. try:
  6. s = dbconnect(*args, **kwargs) # connect to server
  7. if verbose:
  8. print("Connected to:", s.connection_string)
  9. print("which has tables:", s.get_table_names())
  10. s.close() # thanks, it worked, goodbye
  11. except adodbapi.DatabaseError as inst:
  12. print(inst.args[0]) # should be the error message
  13. print("***Failed getting connection using=", repr(args), repr(kwargs))
  14. return False, (args, kwargs), None
  15. print(" (successful)")
  16. return True, (args, kwargs, remote), dbconnect
  17. def try_operation_with_expected_exception(
  18. expected_exception_list, some_function, *args, **kwargs
  19. ):
  20. try:
  21. some_function(*args, **kwargs)
  22. except expected_exception_list as e:
  23. return True, e
  24. except:
  25. raise # an exception other than the expected occurred
  26. return False, "The expected exception did not occur"