Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

execute.py 994 B

123456789101112131415161718192021222324252627
  1. import shlex
  2. import subprocess
  3. from typing import Any, List, Optional, Tuple, Union
  4. def execute(arguments: Union[str, List[str]],
  5. stdin_content: Optional[Union[str, bytes]] = None) -> Any:
  6. return subprocess.run(
  7. shlex.split(arguments) if isinstance(arguments, str) else arguments,
  8. input=stdin_content.encode() if isinstance(stdin_content, str) else stdin_content,
  9. stdout=subprocess.PIPE,
  10. stderr=subprocess.PIPE)
  11. def checked_execute(arguments: Union[str, List[str]],
  12. stdin_content: Optional[Union[str, bytes]] = None) -> Tuple[str, str]:
  13. result = execute(arguments, stdin_content)
  14. if result.returncode != 0:
  15. raise RuntimeError(
  16. f"Command failed (exit code: {result.returncode}) {' '.join(arguments)}:\n"
  17. f"STDOUT:\n"
  18. f"{result.stdout.decode()}"
  19. f"STDERR:\n"
  20. f"{result.stderr.decode()}")
  21. return result.stdout.decode(), result.stderr.decode()