1
0
Fork 0
mirror of synced 2024-11-16 13:35:35 -05:00

Added the ability to use environment variables in link paths, and setup the HOSTNAME environment variable if it isn't already set. This makes linking host specific configs very easy

This commit is contained in:
Brian Knobbs 2015-05-06 18:02:31 -04:00
parent eeab507d15
commit dd144a2044
2 changed files with 5 additions and 1 deletions

View file

@ -1,3 +1,5 @@
import os
import socket
from argparse import ArgumentParser
from .config import ConfigReader, ReadingError
from .dispatcher import Dispatcher, DispatchError
@ -24,6 +26,8 @@ def read_config(config_file):
def main():
log = Messenger()
os.environ.setdefault("HOSTNAME", socket.gethostname())
try:
parser = ArgumentParser()
add_options(parser)

View file

@ -107,7 +107,7 @@ class Linker(Executor):
Returns true if successfully linked files.
'''
success = False
source = os.path.join(self._base_directory, source)
source = os.path.expandvars(os.path.join(self._base_directory, source))
if (not self._exists(link_name) and self._is_link(link_name) and
self._link_destination(link_name) != source):
self._log.warning('Invalid link %s -> %s' %