Skip to content

Commit

Permalink
Fix config file locating code in blah.py. HTCONDOR-521
Browse files Browse the repository at this point in the history
Use the same location logic as the C and shell code.
  • Loading branch information
JaimeFrey committed Jul 26, 2021
1 parent 45a8ad2 commit 4cfbc7b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/scripts/blah.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
"""Common functions for BLAH python scripts"""

import os
from configparser import RawConfigParser
from io import StringIO

class BlahConfigParser(RawConfigParser, object):

def __init__(self, path='/etc/blah.config', defaults=None):
def __init__(self, path=None, defaults=None):
if path is None:
if "BLAHPD_CONFIG_LOCATION" in os.environ:
path = os.environ['BLAHPD_CONFIG_LOCATION']
elif "BLAHPD_LOCATION" in os.environ and os.path.isfile("%s/etc/blah.config" % os.environ['BLAHPD_LOCATION']):
path = "%s/etc/blah.config" % os.environ['BLAHPD_LOCATION']
elif "GLITE_LOCATION" in os.environ and os.path.isfile("%s/etc/blah.config" % os.environ['GLITE_LOCATION']):
path = "%s/etc/blah.config" % os.environ['GLITE_LOCATION']
else:
path = "/etc/blah.config"
# RawConfigParser requires ini-style [section headers] but since
# blah.config is also used as a shell script we need to fake one
self.header = 'blahp'
Expand Down

0 comments on commit 4cfbc7b

Please sign in to comment.