def get_special_placeholder(): from platform import system return { 'DAEMON_SOURCE_FILENAME': DOORPI.parse_string(DOORPI.CONST.DAEMON_FILE['source']), 'DAEMON_TARGET_FILENAME': DOORPI.parse_string(DOORPI.CONST.DAEMON_FILE['target']), 'DAEMON_INSTALL_COMMAND': DOORPI.parse_string(DOORPI.CONST.DAEMON_FILE['install_command']), 'DAEMON_UNINSTALL_COMMAND': DOORPI.parse_string(DOORPI.CONST.DAEMON_FILE['uninstall_command']), 'DAEMON_STDIN_PATH': DOORPI.CONST.DAEMON_STDIN_PATH, 'DAEMON_STDOUT_PATH': DOORPI.CONST.DAEMON_STDOUT_PATH, 'DAEMON_STDERR_PATH': DOORPI.CONST.DAEMON_STDERR_PATH, 'DAEMON_PIDFILE': DOORPI.CONST.DAEMON_PIDFILE, 'DAEMON_PIDFILE_TIMEOUT': DOORPI.CONST.DAEMON_PIDFILE_TIMEOUT, 'PROJECT': DOORPI.CONST.META.prog, 'PROJECT_VERSION': DOORPI.CONST.META.version, 'PROJECT_DESCRIPTION': DOORPI.CONST.META.description, 'DAEMON_DEFAULT_ARGUMENTS': DOORPI.CONST.DAEMON_DEFAULT_ARGUMENTS }
def write_parsed_daemon_file(): from os import stat as get_file_attributes, chmod from stat import S_IEXEC as ExecutableBit special_placeholder = get_special_placeholder() source_file = open(special_placeholder['DAEMON_SOURCE_FILENAME'], 'r') target_file = open(special_placeholder['DAEMON_TARGET_FILENAME'], 'w') logger.info( "write example daemonfile from %s to %s and replace the placeholder inside the examplefile", special_placeholder['DAEMON_SOURCE_FILENAME'], special_placeholder['DAEMON_TARGET_FILENAME']) for single_line in source_file.readlines(): target_file.write(DOORPI.parse_string(single_line, special_placeholder)) source_file.close() target_file.close() logger.info("make the daemonfile %s executable", special_placeholder['DAEMON_TARGET_FILENAME']) chmod( special_placeholder['DAEMON_TARGET_FILENAME'], get_file_attributes( special_placeholder['DAEMON_TARGET_FILENAME']).st_mode | ExecutableBit) return special_placeholder['DAEMON_TARGET_FILENAME']
def start(self, db_type, connection_string): connection_string = DOORPI.parse_string(connection_string) logger.info('open %s db for event history with connection string "%s"', db_type, connection_string) return self
def load_config_from_configfile(config_file=None): with open(DOORPI.parse_string(config_file)) as data_file: config_object = json.load(data_file) return config_object