def runtime_environment(self):
        # run service_environment on all extensions, pool the results
        #  into one dict, duplicates are grouped in a list and kept
        #  in the same order.
        all_extns_env = defaultdict(list)

        def process(env):
            for key, val in env.iteritems():
                if hasattr(val, 'append'):
                    all_extns_env[key].extend(val)
                else:
                    all_extns_env[key].append(val)

        process_extensions(self._builder._ctx, 'service_environment', process)
        # Write pool of environment items to disk, a single item is
        #  written in 'key=val' format, while lists are written as
        #  'key=val:val:val' where ':' is os.pathsep.
        profile_d_directory = os.path.join(self._builder._ctx['BUILD_DIR'],
                                           '.profile.d')
        if not os.path.exists(profile_d_directory):
            os.makedirs(profile_d_directory)
        envPath = os.path.join(profile_d_directory, 'bp_env_vars.sh')
        with open(envPath, 'at') as envFile:
            for key, val in all_extns_env.iteritems():
                if len(val) == 0:
                    val = ''
                elif len(val) == 1:
                    val = val[0]
                elif len(val) > 1:
                    val = os.pathsep.join(val)
                envFile.write("export %s=%s\n" % (key, val))
        return self
Esempio n. 2
0
    def runtime_environment(self):
        # run service_environment on all extensions, pool the results
        #  into one dict, duplicates are grouped in a list and kept
        #  in the same order.
        all_extns_env = defaultdict(list)

        def process(env):
            for key, val in env.iteritems():
                if hasattr(val, 'append'):
                    all_extns_env[key].extend(val)
                else:
                    all_extns_env[key].append(val)
        process_extensions(self._builder._ctx, 'service_environment', process)
        # Write pool of environment items to disk, a single item is
        #  written in 'key=val' format, while lists are written as
        #  'key=val:val:val' where ':' is os.pathsep.
        profile_d_directory = os.path.join(self._builder._ctx['BUILD_DIR'],
                                           '.profile.d')
        if not os.path.exists(profile_d_directory):
            os.makedirs(profile_d_directory)
        envPath = os.path.join(profile_d_directory, 'bp_env_vars.sh')
        with open(envPath, 'at') as envFile:
            for key, val in all_extns_env.iteritems():
                if len(val) == 0:
                    val = ''
                elif len(val) == 1:
                    val = val[0]
                elif len(val) > 1:
                    val = os.pathsep.join(val)
                envFile.write("export %s=%s\n" % (key, val))
        return self
Esempio n. 3
0
 def process_list(self):
     def process(cmds):
         procPath = os.path.join(self._builder._ctx['BUILD_DIR'], '.procs')
         with open(procPath, 'at') as procFile:
             for name, cmd in cmds.iteritems():
                 procFile.write("%s: %s\n" % (name, ' '.join(cmd)))
     process_extensions(self._builder._ctx, 'service_commands', process)
     return self
Esempio n. 4
0
 def process_list(self):
     def process(cmds):
         procPath = os.path.join(self._builder._ctx['BUILD_DIR'], '.procs')
         with open(procPath, 'at') as procFile:
             for name, cmd in cmds.iteritems():
                 procFile.write("%s: %s\n" % (name, ' '.join(cmd)))
     process_extensions(self._builder._ctx, 'service_commands', process)
     return self
Esempio n. 5
0
 def runtime_environment(self):
     def process(env):
         envPath = os.path.join(self._builder._ctx['BUILD_DIR'], '.env')
         with open(envPath, 'at') as envFile:
             for key, val in env.iteritems():
                 envFile.write("%s=%s\n" % (key, val))
     process_extensions(self._builder._ctx, 'service_environment', process)
     return self
Esempio n. 6
0
    def runtime_environment(self):
        def process(env):
            envPath = os.path.join(self._builder._ctx['BUILD_DIR'], '.env')
            with open(envPath, 'at') as envFile:
                for key, val in env.iteritems():
                    envFile.write("%s=%s\n" % (key, val))

        process_extensions(self._builder._ctx, 'service_environment', process)
        return self
Esempio n. 7
0
 def _process_extensions(self):
     def process(cmds):
         for cmd in cmds:
             self.content.append(' '.join(cmd))
     process_extensions(self.builder._ctx, 'preprocess_commands', process)
    def _process_extensions(self):
        def process(cmds):
            for cmd in cmds:
                self.content.append(' '.join(cmd))

        process_extensions(self.builder._ctx, 'preprocess_commands', process)