Skip to content
Snippets Groups Projects
Commit 813940cf authored by Sebastian Lobinger's avatar Sebastian Lobinger
Browse files

initial commit

parent 09669027
No related branches found
No related tags found
No related merge requests found
# sams-hub-creator
Modul zum einfachen erstellen eines samsHUB basierend auf einer vorgegebenen
Verzeichnisstruktur unf Konfigurationsdateien im YAML-Format.
## Verwendung
Man kann das modul als python package z.B. in folgender Struktur Verwenden:
```
projekt
+-- config
| +-- config.yaml
+-- sams_hub_creator
| +-- __init__.py
| ...
+-- app_package
| +-- __init__.py
| ...
+-- app.py
```
Dabei liegt diesen Projekt im Verzeichnis `sams_hub_creator`.
Ein amsHub Objektlässt sich in der app.py dann sehr einfach Erzeugen:
```python
import sams_hub_creator
hub = sams_hub_creator.create(conf_part_hub = 'my_hub')
```
In diesem Fall muss in der config.yaml der key für die hub konfiguration 'my_hub'
lauten. Die namen der apps, die der hub einbinden soll müssen in der config unter
'apps' stehen. Eine Config für die oben genannte Struktur könnte also so aussehen:
```yaml
zib_hub:
default_language: de
main_app: 'app_package'
apps:
- name: 'app_package'
```
## Verweise
Zu den möglichkeiten der samsHub Konfiguration siehe
[sams-classes](https://git.imp.fu-berlin.de/coding-at-fu/sams-classes)
\ No newline at end of file
......@@ -2,7 +2,7 @@ import yaml, os, glob
from sams_classes import SAMSHub, SAMSApp
from flask import Flask
def create_hub(conf_part_hub, conf_part_apps = 'apps',
def create(conf_part_hub, conf_part_apps = 'apps',
config_file_path = 'config/config.yaml', dir_apps = '.'):
with open(config_file_path, 'r') as f:
hubConf = yaml.load(f.read())
......@@ -33,8 +33,3 @@ def search_yaml_files(path, exts = ['.yaml', '.yml']):
if os.path.isfile(path):
matchingFiles.append(path)
return matchingFiles
if __name__ == '__main__':
create_hub()
else:
hub = create_hub()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment