Пример #1
0
	def update(self, cat, wa, site):
		if not wa.dpath:
			ending = ''
		elif wa.dpath.endswith('.tar.gz'):
			ending = '.tar.gz'
		elif wa.dpath.endswith('.tgz'):
			ending = '.tgz'
		elif wa.dpath.endswith('.tar.bz2'):
			ending = '.tar.bz2'
		elif wa.dpath.endswith('.zip'):
			ending = '.zip'
		elif wa.dpath.endswith('.git'):
			ending = '.git'
		else:
			raise InstallError('Only GIT repos, gzip, bzip, and zip packages supported for now')

		cat.statusmsg('Downloading package...')
		if wa.dpath and ending == '.git':
			pkg_path = wa.dpath 
		elif wa.dpath:
			pkg_path = os.path.join('/tmp', site.name+ending)
			try:
				download(wa.dpath, file=pkg_path, crit=True)
			except Exception, e:
				raise InstallError('Couldn\'t update - %s' % str(e))
Пример #2
0
class WABackend:
	def add(self, name, webapp, vars, enable=True):
		if webapp.dpath.endswith('.tar.gz'):
			ending = '.tar.gz'
		elif webapp.dpath.endswith('.tar.bz2'):
			ending = '.tar.bz2'
		else:
			raise InstallError('Only gzip and bzip packages supported for now')

		# Run webapp preconfig, if any
		try:
			webapp.pre_install(name, vars)
		except Exception, e:
			raise InstallError('Webapp config - '+str(e))

		# Make sure the target directory exists, but is empty
		# Testing for sites with the same name should have happened by now
		target_path = os.path.join('/srv/http/webapps', name)
		pkg_path = '/tmp/'+name+ending
		if os.path.isdir(target_path):
			shutil.rmtree(target_path)
		os.makedirs(target_path)

		# Download and extract the source package
		try:
			download(webapp.dpath, file=pkg_path)
		except Exception, e:
			raise InstallError('Couldn\'t download - %s' % str(e))
Пример #3
0
    def install(self, id, load=True):
        """
        Installs a plugin

        :param  id:     Plugin id
        :type   id:     str
        :param  load:   True if you want Genesis to load the plugin immediately
        :type   load:   bool
        """
        from genesis import generation, version
        dir = self.config.get('genesis', 'plugins')

        download('http://%s/genesis/plugin/%s' % (self.server, id),
            file='%s/plugin.tar.gz'%dir, crit=True)

        self.remove(id)
        self.install_tar(load=load)
Пример #4
0
 def update_list(self, crit=False):
     """
     Downloads fresh list of plugins and rebuilds installed/available lists
     """
     from genesis import generation, version
     if not os.path.exists('/var/lib/genesis'):
         os.mkdir('/var/lib/genesis')
     try:
         data = download('http://%s/genesis/list/%s' % (self.server, PluginLoader.platform), crit=crit)
     except urllib2.HTTPError, e:
         raise Exception('Application list retrieval failed with HTTP Error %s' % str(e.code))
Пример #5
0
	def update(self, cat, wa, site):
		if not wa.dpath:
			ending = ''
		elif wa.dpath.endswith('.tar.gz'):
			ending = '.tar.gz'
		elif wa.dpath.endswith('.tar.bz2'):
			ending = '.tar.bz2'
		elif wa.dpath.endswith('.zip'):
			ending = '.zip'
		elif wa.dpath.endswith('.git'):
			ending = '.git'
		else:
			raise InstallError('Only GIT repos, gzip, bzip, and zip packages supported for now')

		cat.statusmsg('Downloading package...')
		if wa.dpath and ending == '.git':
			pkg_path = wa.dpath 
		elif wa.dpath:
			pkg_path = os.path.join('/tmp', site.name+ending)
			try:
				download(wa.dpath, file=pkg_path, crit=True)
			except Exception, e:
				raise InstallError('Couldn\'t update - %s' % str(e))
Пример #6
0
 def update_list(self):
     """
     Downloads fresh list of plugins and rebuilds installed/available lists
     """
     from genesis import generation, version
     if not os.path.exists('/var/lib/genesis'):
         os.mkdir('/var/lib/genesis')
     data = download('http://%s/genesis/list/%s' % (self.server, PluginLoader.platform))
     try:
         open('/var/lib/genesis/plugins.list', 'w').write(data)
     except:
         pass
     self.update_installed()
     self.update_available()
     self.update_upgradable()
Пример #7
0
 def update_list(self, crit=False):
     """
     Downloads fresh list of plugins and rebuilds installed/available lists
     """
     from genesis import generation, version
     if not os.path.exists('/var/lib/genesis'):
         os.mkdir('/var/lib/genesis')
     try:
         data = download('http://%s/genesis/list/%s' %
                         (self.server, PluginLoader.platform),
                         crit=crit)
     except urllib2.HTTPError, e:
         raise Exception(
             'Application list retrieval failed with HTTP Error %s' %
             str(e.code))
Пример #8
0
class WebappControl(Plugin):
    def add(self, cat, name, wa, vars, enable=True):
        specialmsg = ''
        webapp = apis.webapps(self.app).get_interface(wa.wa_plugin)

        if not wa.dpath:
            ending = ''
        elif wa.dpath.endswith('.tar.gz'):
            ending = '.tar.gz'
        elif wa.dpath.endswith('.tar.bz2'):
            ending = '.tar.bz2'
        else:
            raise InstallError('Only gzip and bzip packages supported for now')

        # Run webapp preconfig, if any
        try:
            cat.put_statusmsg('Running pre-install configuration...')
            webapp.pre_install(name, vars)
        except Exception, e:
            raise InstallError('Webapp config - ' + str(e))

        # Make sure the target directory exists, but is empty
        # Testing for sites with the same name should have happened by now
        target_path = os.path.join('/srv/http/webapps', name)
        pkg_path = '/tmp/' + name + ending
        if os.path.isdir(target_path):
            shutil.rmtree(target_path)
        os.makedirs(target_path)

        # Download and extract the source package
        if wa.dpath:
            try:
                cat.put_statusmsg('Downloading webapp package...')
                download(wa.dpath, file=pkg_path, crit=True)
            except Exception, e:
                raise InstallError('Couldn\'t download - %s' % str(e))
            status = shell_cs(
                'tar ' + ('xzf' if ending is '.tar.gz' else 'xjf') + ' /tmp/' +
                name + ending + ' -C ' + target_path + ' --strip 1',
                stderr=True)
            if status[0] >= 1:
                raise InstallError(status[1])
            os.remove(pkg_path)
Пример #9
0
		# Testing for sites with the same name should have happened by now
		target_path = os.path.join('/srv/http/webapps', name)
		pkg_path = '/tmp/'+name+ending
		if os.path.isdir(target_path):
			shutil.rmtree(target_path)
		os.makedirs(target_path)

		# Download and extract the source package
		if wa.dpath and ending == '.git':
			status = shell_cs('git clone %s %s'%(wa.dpath,target_path), stderr=True)
			if status[0] >= 1:
				raise InstallError(status[1])
		elif wa.dpath:
			try:
				cat.statusmsg('Downloading webapp package...')
				download(wa.dpath, file=pkg_path, crit=True)
			except Exception, e:
				raise InstallError('Couldn\'t download - %s' % str(e))

			if ending in ['.tar.gz', '.tar.bz2']:
				extract_cmd = 'tar '
				extract_cmd += 'xzf' if ending is '.tar.gz' else 'xjf'
				extract_cmd += ' /tmp/%s -C %s --strip 1' % (name+ending, target_path)
			else:
				extract_cmd = 'unzip -d %s /tmp/%s' % (target_path, name+ending)

			status = shell_cs(extract_cmd, stderr=True)
			if status[0] >= 1:
				raise InstallError(status[1])
			os.remove(pkg_path)