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: |
emayecs | b2487ae | 2021-08-05 10:30:13 -0400 | [diff] [blame] | 9 | # import config_DEV import config_STAGING import config_PROD |
emayecs | 5966a53 | 2021-07-29 10:07:02 -0400 | [diff] [blame] | 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 |
emayecs | 4c80645 | 2021-09-01 20:00:51 -0400 | [diff] [blame] | 19 | apps_path="PREFIX/pdk/bin" |
emayecs | 5966a53 | 2021-07-29 10:07:02 -0400 | [diff] [blame] | 20 | |
| 21 | config = configparser.ConfigParser(strict=False, allow_no_value=True) |
| 22 | try: |
| 23 | config.read_string("[null]\n"+open("/etc/sysconfig/ef-config").read()) |
| 24 | except: |
| 25 | pass |
| 26 | ef_variant = config.get('null','ef_variant', fallback='STAGING').strip('\'"') |
| 27 | |
| 28 | # |
emayecs | b2487ae | 2021-08-05 10:30:13 -0400 | [diff] [blame] | 29 | # emulate: import config_<ef_variant> |
emayecs | 5966a53 | 2021-07-29 10:07:02 -0400 | [diff] [blame] | 30 | # |
emayecs | b2487ae | 2021-08-05 10:30:13 -0400 | [diff] [blame] | 31 | #cfgModule = __import__("config_"+ef_variant) |
emayecs | 5966a53 | 2021-07-29 10:07:02 -0400 | [diff] [blame] | 32 | #globals().update(vars(cfgModule)) |