emayecs | 5966a53 | 2021-07-29 10:07:02 -0400 | [diff] [blame] | 1 | # Configuration values for the OpenGalaxy machines |
| 2 | # Select config-file directed by OPTIONAL (INI file): /etc/sysconfig/ef-config ef_variant= line. |
| 3 | # File should: have no [section] header, use "# " comments, var="val" (no spaces around =), |
| 4 | # no dash in var-names, for good compatibility between python and bash. |
| 5 | # |
| 6 | # default if fail to read/parse the etc file is STAGING. These values: |
| 7 | # ef_variant=DEV ef_variant=STAGING ef_variant=PROD |
| 8 | # yield respectively: |
| 9 | # import og_config_DEV import og_config_STAGING import og_config_PROD |
| 10 | # |
| 11 | # Survive (try:) missing,improper,unreadable /etc/sysconfig/ef-config. |
| 12 | # DO NOT survive (no try:) failed imports (non-existent file, bad syntax, etc.). |
| 13 | |
| 14 | # |
| 15 | # look-up ef_variant=... in optional etc file, default to STAGING |
| 16 | # |
| 17 | import configparser |
| 18 | #TODO: replace path with PREFIX |
| 19 | apps_path="/usr/share/pdk/bin" |
| 20 | #apps_path="PREFIX/pdk/bin" |
| 21 | |
| 22 | config = configparser.ConfigParser(strict=False, allow_no_value=True) |
| 23 | try: |
| 24 | config.read_string("[null]\n"+open("/etc/sysconfig/ef-config").read()) |
| 25 | except: |
| 26 | pass |
| 27 | ef_variant = config.get('null','ef_variant', fallback='STAGING').strip('\'"') |
| 28 | |
| 29 | # |
| 30 | # emulate: import og_config_<ef_variant> |
| 31 | # |
| 32 | #cfgModule = __import__("og_config_"+ef_variant) |
| 33 | #globals().update(vars(cfgModule)) |