Beispiel #1
0
    def load(self, filename=None):
        info = []
        self.discover_config_files(info)

        files = []
        for (conf_dir, namespace) in info:
            prefix = join_path(conf_dir, '%s%s.conf' % (namespace, '%s'))

            short = (self.hostname != self.shortname)
            upper = namespace.upper()

            files += [
                f for f in [
                    prefix % '',
                    prefix % ('-' + self.hostname),
                    prefix % ('-' + self.shortname) if short else None,
                    os.environ.get('%s_CONF' % upper) or None,
                ] if f
            ]

        if filename:
            files.append(filename)

        with open(files[0], 'r') as f:
            self.readfp(f, files[0])

        self.read(files[1:])

        self.files = files
        self.filename = filename

        self.post_load()
Beispiel #2
0
    def load(self, filename=None):
        info = []
        self.discover_config_files(info)

        files = []
        for (conf_dir, namespace) in info:
            prefix = join_path(conf_dir, '%s%s.conf' % (namespace, '%s'))

            short = (self.hostname != self.shortname)
            upper = namespace.upper()

            files += [
                f for f in [
                    prefix % '',
                    prefix % ('-' + self.hostname),
                    prefix % ('-' + self.shortname) if short else None,
                    os.environ.get('%s_CONF' % upper) or None,
                ] if f
            ]

        if filename:
            files.append(filename)

        with open(files[0], 'r') as f:
            self.readfp(f, files[0])

        self.read(files[1:])

        self.files = files
        self.filename = filename

        self.post_load()
Beispiel #3
0
def find_all_files_ending_with(dirname, suffix):
    results = []
    from ctk.path import join_path
    for (root, dirs, files) in os.walk(dirname):
        results += [
            join_path(root, file) for file in files if file.endswith(suffix)
        ]
    return results
Beispiel #4
0
def find_all_files_ending_with(dirname, suffix):
    results = []
    from ctk.path import join_path
    for (root, dirs, files) in os.walk(dirname):
        results += [
            join_path(root, file)
                for file in files
                    if file.endswith(suffix)
        ]
    return results
Beispiel #5
0
 def get_gnuwin32_exe(self, name):
     if not name.endswith('.exe'):
         name = name + '.exe'
     return join_path(self.gnuwin32_bin, name)
Beispiel #6
0
 def gnuwin32_bin(self):
     return join_path(self.gnuwin32_dir, 'bin')
Beispiel #7
0
 def _resolve_dir(cls, name):
     path = inspect.getsourcefile(cls)
     base = dirname(join_path(path, '../..'))
     return join_path(base, name)
Beispiel #8
0
#===============================================================================
# Globals
#===============================================================================

CONFIG = None
CONFIG_CLASS = None

PROGRAM_NAME = None
COMMAND_NAME = None
COMMAND_MODULES = None

PATH = dirname(abspath(__file__))

NAMESPACE = basename(PATH)

LIB_DIR = join_path(PATH, '..')
BIN_DIR = join_path(LIB_DIR, '../bin')
CONF_DIR = join_path(LIB_DIR, '../conf')
LOGS_DIR = join_path(LIB_DIR, '../logs')
DATA_DIR = join_path(LIB_DIR, '../data')

#fixme: revisit these assertions
#assert LIB_DIR.endswith('lib'), LIB_DIR
#
#for d in (LIB_DIR, BIN_DIR, CONF_DIR, LOGS_DIR):
#    assert isdir(d), d

# HOSTFQDN may have the FQDN or it may not; HOSTNAME will always be the
# shortest representation of the hostname.
HOSTFQDN = subprocess.check_output('hostname')[:-len(os.linesep)].lower()
try:
Beispiel #9
0
 def get_gnuwin32_exe(self, name):
     if not name.endswith('.exe'):
         name = name + '.exe'
     return join_path(self.gnuwin32_bin, name)
Beispiel #10
0
 def gnuwin32_bin(self):
     return join_path(self.gnuwin32_dir, 'bin')
Beispiel #11
0
 def _resolve_dir(cls, name):
     path = inspect.getsourcefile(cls)
     base = dirname(join_path(path, '../..'))
     return join_path(base, name)
Beispiel #12
0
#===============================================================================
# Globals
#===============================================================================

CONFIG = None
CONFIG_CLASS = None

PROGRAM_NAME = None
COMMAND_NAME = None
COMMAND_MODULES = None

PATH = dirname(abspath(__file__))

NAMESPACE = basename(PATH)

LIB_DIR  = join_path(PATH, '..')
BIN_DIR  = join_path(LIB_DIR, '../bin')
CONF_DIR = join_path(LIB_DIR, '../conf')
LOGS_DIR = join_path(LIB_DIR, '../logs')
DATA_DIR = join_path(LIB_DIR, '../data')

#fixme: revisit these assertions
#assert LIB_DIR.endswith('lib'), LIB_DIR
#
#for d in (LIB_DIR, BIN_DIR, CONF_DIR, LOGS_DIR):
#    assert isdir(d), d

# HOSTFQDN may have the FQDN or it may not; HOSTNAME will always be the
# shortest representation of the hostname.
HOSTFQDN = subprocess.check_output('hostname')[:-len(os.linesep)].lower()
try: