

def startup_script(self, overrides=None, debug=False):
    from ploy import template
    config = self.get_config(overrides)
    startup_script_path = config.get('startup_script', None)
    if (startup_script_path is None):
        if debug:
            return dict(original='', raw='')
        else:
            return ''
    try:
        startup_script = template.Template(startup_script_path['path'], pre_filter=strip_hashcomments)
    except IOError as e:
        if (e.args[0] == 2):
            log.error("Startup script '%s' not found.", startup_script_path['path'])
            sys.exit(1)
        raise
    self.hooks.startup_script_options(config)
    result = dict(original=startup_script(**config))
    if startup_script_path.get('gzip', False):
        shebang = b'#!/bin/sh'
        if result['original'].startswith('#!'):
            shebang = result['original'].splitlines()[0].encode('ascii')
        result['raw'] = b'\n'.join([b'#!/bin/sh', (b'tail -n+4 $0 | gunzip -c | ' + shebang[2:]), b'exit $?', gzip_string(result['original'])])
    else:
        result['raw'] = result['original']
    max_size = getattr(self, 'max_startup_script_size', None)
    if ((max_size is not None) and (len(result['raw']) >= max_size)):
        log.error('Startup script too big (%s > %s).', len(result['raw']), max_size)
        if (not debug):
            sys.exit(1)
    if debug:
        return result
    else:
        return result['raw']

dataset/ETHPy150Open ployground/ploy/ploy/common.py StartupScriptMixin.startup_script/original