Beispiel #1
0
    def install(self):
        """Installer"""
        binaries = self.get_binaries()
        if 'phantomjs' not in binaries:
            url = self.options.get('phantomjs-url', None)
            if not url:
                version = self.options.get('phantomjs-version', '1.7.0')
                if sys.platform == 'linux2':
                    url = ('https://phantomjs.googlecode.com/'
                           'files/phantomjs-%s-linux-i686.tar.bz2') % version
                elif sys.platform == 'darwin':
                    url = ('https://phantomjs.googlecode.com/'
                           'files/phantomjs-%s-macosx.zip') % version
                else:
                    raise RuntimeError('Please specify a phantomjs-url')
            self.download(url)
        if 'casperjs' not in binaries:
            self.download(
                self.options.get(
                    'casperjs-url',
                    'https://github.com/n1k0/casperjs/tarball/1.0.0-RC4'))

        binaries = self.get_binaries()
        for f in binaries.values():
            os.chmod(f, 0777)

        self.options['arguments'] = repr(binaries)
        self.options['eggs'] = 'gp.recipe.phantomjs'
        self.options['entry-points'] = '\n'.join(
            ['%s=gp.recipe.phantomjs.script:main' % s for s in binaries])
        from zc.recipe.egg import Scripts
        rscripts = Scripts(self.buildout, self.name, self.options)
        return rscripts.install()
Beispiel #2
0
    def install(self):
        """Installer"""
        binaries = self.get_binaries()
        if 'phantomjs' not in binaries:
            if self.options.get('phantomjs-url', None):
                url = self.options.get('phantomjs-url')
            elif self.options.get('phantomjs-url-base', None):
                url = self._get_url_from_base()
            else:
                url = self._get_url_from_template()
            self.download(url)
        if 'casperjs' not in binaries:
            url = self.options.get(
                'casperjs-url',
                'https://github.com/n1k0/casperjs/tarball/1.0.3')
            if url:
                self.download(url)

        binaries = self.get_binaries()
        for f in binaries.values():
            os.chmod(f, 0o777)

        if self.relative_paths:
            self.options['arguments'] = \
                self._get_relative_binary_dict(binaries)
        else:
            self.options['arguments'] = repr(binaries)
        self.options['eggs'] = 'gp.recipe.phantomjs'
        self.options['entry-points'] = '\n'.join(
            ['%s=gp.recipe.phantomjs.script:main' % s for s in binaries])
        from zc.recipe.egg import Scripts
        rscripts = Scripts(self.buildout, self.name, self.options)
        return rscripts.install()
Beispiel #3
0
 def write_appcfg_script(self, bin):
     """Generates the app configuration script in bin."""
     options = self.options.copy()
     options['eggs'] = ''
     run_file = self.options['appserver-run-file']
     options['entry-points'] = 'appcfg=appcfg:%s' % run_file
     options['arguments'] = '%r, locals()' % bin
     options = Options(self.buildout, self.name, options)
     scripts = Scripts(self.buildout, self.name, options)
     scripts.install()
Beispiel #4
0
    def write_server_script(self, name, bin):
        """Generates bin script with given name."""

        var = os.path.join(self.buildout['buildout']['parts-directory'], '%s_var' % self.name)
        if not os.path.isdir(var):
            os.makedirs(var)

        script_name = self.get_appserver_script_name().partition('.')[0]

        options = self.options.copy()
        options['eggs'] = ''
        run_file = '_' + self.options['appserver-run-file']
        options['entry-points'] = '%s=%s:%s' % (name, script_name, run_file)
        options['initialization'] = dev_appserver_initialization % dict(var=var, script_name=script_name)
        options['initialization'] += '\n' + self.options.get('initialization', '')
        options['arguments'] = '%r, locals()' % bin
        options = Options(self.buildout, self.name, options)
        scripts = Scripts(self.buildout, self.name, options)
        scripts.install()
Beispiel #5
0
 def write_extra_scripts(self):
     options = self.options.copy()
     options['eggs'] = ''
     options = Options(self.buildout, self.name, options)
     scripts = Scripts(self.buildout, self.name, options)
     scripts.install()
Beispiel #6
0
    def install(self):
        """Installer"""
        options = self.options
        parts = self.buildout['buildout']['parts-directory']
        name = options['url'].split('/')[-1].replace('.tar.gz', '')
        node_dir = os.path.join(parts, self.name)
        if not os.path.isdir(node_dir):
            os.makedirs(node_dir)
        node_binary = options.get('binary',
                                  os.path.join(parts, name, 'bin', 'node'))
        node_bin = os.path.dirname(node_binary)

        if not os.path.isfile(node_binary):
            from zc.recipe.cmmi import Recipe as Cmmi
            options['environment'] = 'PYTHONPATH=tools:deps/v8/tools'
            node = Cmmi(self.buildout, name, options)
            node.install()

        options['on_install'] = 'true'
        options['on_update'] = 'true'

        if not os.path.isfile(os.path.join(node_bin, 'npm')):
            p = subprocess.Popen((
                    'curl -sk https://npmjs.org/install.sh > install.sh&&'
                    'PATH=%s:$PATH '
                    'clean=yes sh install.sh&&rm install.sh'
                              ) % (node_bin,), shell=True)
            p.wait()

        scripts = [script.strip() for script in options['scripts'].split() \
                                                            if script.strip()]

        npms = options.get('npms', '')
        if npms:
            npms = ' '.join([npm.strip() for npm in npms.split() \
                                                            if npm.strip()])
            p = subprocess.Popen(('export HOME=%(node_dir)s;'
                               'export PATH=%(node_bin)s:$PATH;'
                               'echo "prefix=$HOME" > $HOME/.npmrc;'
                               '%(node_bin)s/npm install -g %(npms)s'
                              ) % locals(), shell=True)
            p.wait()

            for script in scripts:
                if script in ['node']:
                    continue
                filename = os.path.join(node_bin, script)
                if os.path.isfile(filename):
                    fd = open(filename)
                    data = fd.read()
                    fd.close()
                    fd = open(filename, 'w')
                    fd.seek(0)
                    data = data.split('\n')
                    data[0] = '#!%s' % node_binary
                    fd.write('\n'.join(data))
                    fd.close()

        if 'node' not in scripts:
            scripts.append('node')

        node_path = options.get('node-path', '').split()
        node_path.insert(0, os.path.join(node_dir, 'lib', 'node_modules'))
        node_path = ':'.join(node_path)
        options['initialization'] = \
                        'import os;\nos.environ["NODE_PATH"] = %r' % node_path

        options['eggs'] = 'gp.recipe.node'
        options['arguments'] = '%r, (%r, %r), sys.argv[0]' % (
                                node_binary,
                                os.path.join(node_dir, 'bin'),
                                node_bin,
                             )
        options['entry-points'] = '\n'.join([
            '%s=gp.recipe.node.script:main' % s for s in scripts
            ])
        from zc.recipe.egg import Scripts
        rscripts = Scripts(self.buildout, self.name, options)
        return rscripts.install()