Browse Source

improved config loading, dropped exact Python version requirements, changed default urls, fixed bug with default values

master
Vašek Šraier 6 years ago
parent
commit
bc0d590e07
  1. 1
      .gitignore
  2. 2
      Makefile
  3. 2
      Pipfile
  4. 2
      README.md
  5. 5
      config.py
  6. 20
      register.py

1
.gitignore

@ -3,3 +3,4 @@ swagger_client/
tmp/ tmp/
.idea/ .idea/
.idea/ .idea/
.mypy_cache/

2
Makefile

@ -1,4 +1,4 @@
GITEA_URL=https://git.vakabus.cz/swagger.v1.json GITEA_URL=https://try.gitea.io/swagger.v1.json
BUILDDIR=tmp BUILDDIR=tmp
build: swagger_client clean_builddir pipenv_sync build: swagger_client clean_builddir pipenv_sync

2
Pipfile

@ -15,4 +15,4 @@ secrets = "*"
python2-secrets = "*" python2-secrets = "*"
[requires] [requires]
python_version = "3.5" python_version = "3"

2
README.md

@ -13,7 +13,7 @@ Spustí se prostým zavoláním `make`
## Spousteni ## Spousteni
Vyzaduje nejmene Pythonu 3.5 Vyzaduje presne Python 3.5
```sh ```sh
pipenv run python register.py --help pipenv run python register.py --help

5
config.py

@ -1,2 +1,3 @@
# Odkomentovanim radku nize je mozne nastavit vychozi server Gitei # Zde je mozne nastavit vychozi hodnoty
# HOST = 'https://gitea.url/api/v1' HOST = 'https://gitea.url/api/v1'
ADMIN_TOKEN = ''

20
register.py

@ -119,15 +119,9 @@ def reset_password(email: str):
raise ApiException(status=resp.status_code, reason=resp.reason, http_resp='Form submission failed.') raise ApiException(status=resp.status_code, reason=resp.reason, http_resp='Form submission failed.')
if __name__ == '__main__': import config
# default configuration HOST = config.HOST
HOST = "https://git.vakabus.cz/api/v1" ADMIN_TOKEN = config.ADMIN_TOKEN
try:
with open('config.py') as f:
conf = f.read()
exec(conf)
except Exception:
print(text_orange('Nepodarilo se nacist konfiguraci ze souboru \'config.py\''))
@click.command() @click.command()
@ -144,12 +138,14 @@ def register(username: str, seminar: str, fullname: str, email: str, host, admin
Prvni probehne kontrola stavu systemu, zda je mozne uzivatele bezpecne zalozit. Pote se provede pokus o zalozeni Prvni probehne kontrola stavu systemu, zda je mozne uzivatele bezpecne zalozit. Pote se provede pokus o zalozeni
nasledovan pridanim uzivatele do skupiny 'org' v pozadovane organizaci (jmeno dle seminare). nasledovan pridanim uzivatele do skupiny 'org' v pozadovane organizaci (jmeno dle seminare).
Vytvoreny uzivatel ma nastavene nahodne heslo. Zadny email o vytvoreni uctu neni zaslan. Vytvoreny uzivatel ma nastavene nahodne heslo. To je automaticky resetovano a o tom je odeslan email.
V souboru config.py je mozne nastavit token a URL perzistentne.
""" """
api_client = ApiClient() api_client = ApiClient()
api_client.configuration.host = HOST api_client.configuration.host = host if host is not None else HOST
api_client.configuration.api_key = {'token': admin_token} api_client.configuration.api_key = {'token': admin_token if admin_token is not None else ADMIN_TOKEN}
admin_api = AdminApi(api_client) admin_api = AdminApi(api_client)
user_api = UserApi(api_client) user_api = UserApi(api_client)

Loading…
Cancel
Save