From cf7599c8a97880bf0e8597030cbc5935a24b5c44 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Mon, 22 Feb 2021 17:23:42 +0100 Subject: [PATCH] monthly forderungen --- .gitlab-ci.yml | 37 +++++++++++++++++++++++++++++++ monatliche-forderung-eintragen.py | 24 +++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..74b20e0 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,37 @@ +stages: + - check + - dockerize + +variables: + IMAGE_NAME: $CI_REGISTRY/$CI_PROJECT_PATH + + +check: + image: registry.hottis.de/dockerized/base-build-env:latest + stage: check + tags: + - hottis + - linux + - docker + rules: + - if: $CI_COMMIT_TAG + script: + - checksemver.py -v + --versionToValidate "$CI_COMMIT_TAG" + --validateMessage + --messageToValidate "$CI_COMMIT_MESSAGE" + +dockerize: + image: registry.hottis.de/dockerized/docker-bash:latest + stage: dockerize + tags: + - hottis + - linux + - docker + rules: + - if: $CI_COMMIT_TAG + script: + - docker build --tag $IMAGE_NAME:latest --tag $IMAGE_NAME:$CI_COMMIT_TAG . + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker push $IMAGE_NAME:latest + - docker push $IMAGE_NAME:$CI_COMMIT_TAG diff --git a/monatliche-forderung-eintragen.py b/monatliche-forderung-eintragen.py index 94c6d3d..3c29a25 100755 --- a/monatliche-forderung-eintragen.py +++ b/monatliche-forderung-eintragen.py @@ -1,3 +1,25 @@ #!/usr/bin/python3 -print("Monatliche Forderung eintragen") +import requests +import datetime + +class ResourceNotFoundException(Exception): pass + +def postJson(url): + resp = requests.post(url) + if resp.status_code != 202: + raise ResourceNotFoundException("URL: {}, Code: {}".format(url, resp.status_code)) + return resp.json() + + +BASE_URL = "http://172.16.10.29:5000/hv" +URL_INSERT_FORDERUNGEN = "{base}/forderung/insertAllForMonth" + +TEMPLATE_FILE = "inserted.tmpl" + + +try: + postJson(URL_INSERT_FORDERUNGEN.format(base=BASE_URL)) + print("Monatliche Mietforderungen erfolgreich eintragen") +except Exception as e: + print("ERROR: {}".format(e))