'Recover environment variables dumped out on compute server and filter
out specific variables if needed.'

def job_properties(self, job_id, job_directory):

    variables = self.variables
    properties = {}
    env_string = ''.join(open(self.__env_file(job_directory)).readlines())
    while env_string:
        m = re.match('([^=]+)=(\\(\\)    \\{.+?\n\\})\n', env_string, re.DOTALL)
        if (m is None):
            m = re.match('([^=]+)=(.*)\n', env_string)
        if (m is None):
            message_template = 'Problem    parsing    env    metric    output    for    job    %s    -    properties    will    be    incomplete'
            message = (message_template % job_id)
            log.debug(message)
            break
        (var, value) = m.groups()
        if ((not variables) or (var in variables)):
            properties[var] = value
        env_string = env_string[m.end():]
    return properties
