From f4c14b9811b3847e242004c5aadc13fc71777e3c Mon Sep 17 00:00:00 2001 From: Romain Courteaud Date: Thu, 5 Apr 2012 18:26:27 +0200 Subject: [PATCH] Add xvfb recipe. It allows to start a X server inside a slapos instance. Provide an hook to do a screenshot of the X session. --- setup.py | 2 ++ slapos/recipe/xvfb/__init__.py | 56 +++++++++++++++++++++++++++++++++ slapos/recipe/xvfb/template/xvfb_run.in | 6 ++++ slapos/recipe/xvfb/template/xwd_run.in | 6 ++++ 4 files changed, 70 insertions(+) create mode 100644 slapos/recipe/xvfb/__init__.py create mode 100644 slapos/recipe/xvfb/template/xvfb_run.in create mode 100644 slapos/recipe/xvfb/template/xwd_run.in diff --git a/setup.py b/setup.py index e5b009a..fd89d90 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,7 @@ setup(name=name, 'generic.onetimeupload = slapos.recipe.generic_onetimeupload:Recipe', 'helloworld = slapos.recipe.helloworld:Recipe', 'generic.cloudooo = slapos.recipe.generic_cloudooo:Recipe', + 'firefox = slapos.recipe.firefox:Recipe', 'fontconfig = slapos.recipe.fontconfig:Recipe', 'java = slapos.recipe.java:Recipe', 'kumofs = slapos.recipe.kumofs:Recipe', @@ -112,6 +113,7 @@ setup(name=name, 'urlparse = slapos.recipe._urlparse:Recipe', 'vifib = slapos.recipe.vifib:Recipe', 'waitfor = slapos.recipe.waitfor:Recipe', + 'xvfb = slapos.recipe.xvfb:Recipe', 'xwiki = slapos.recipe.xwiki:Recipe', 'zabbixagent = slapos.recipe.zabbixagent:Recipe', 'generic.zope = slapos.recipe.generic_zope:Recipe', diff --git a/slapos/recipe/xvfb/__init__.py b/slapos/recipe/xvfb/__init__.py new file mode 100644 index 0000000..1272a62 --- /dev/null +++ b/slapos/recipe/xvfb/__init__.py @@ -0,0 +1,56 @@ +############################################################################## +# +# Copyright (c) 2012 Vifib SARL and Contributors. All Rights Reserved. +# +# WARNING: This program as such is intended to be used by professional +# programmers who take the whole responsibility of assessing all potential +# consequences resulting from its eventual inadequacies and bugs +# End users who are looking for a ready-to-use solution with commercial +# guarantees and support are strongly adviced to contract a Free Software +# Service Company +# +# This program is Free Software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################# + +from slapos.recipe.librecipe import GenericBaseRecipe + +class Recipe(GenericBaseRecipe): + def install(self): + + config = { + 'xvfb_binary': self.options['xvfb-path'], + 'shell_path': self.options['shell-path'], + 'fbdir_path': self.options['fbdir-path'], + 'tmp_path': self.options['tmp-path'], + } + + xvfb_path = self.createExecutable( + self.options['runner-path'], + self.substituteTemplate(self.getTemplateFilename('xvfb_run.in'), + config)) + result = [xvfb_path] + + # Allow to take screenshot if needed + if ('xwd-path' in self.options) and ('xwd-hook-path' in self.options): + + config['xwd_binary'] = self.options['xwd-path'] + result.append(self.createExecutable( + self.options['xwd-hook-path'], + self.substituteTemplate(self.getTemplateFilename('xwd_run.in'), + config))) + + return result + diff --git a/slapos/recipe/xvfb/template/xvfb_run.in b/slapos/recipe/xvfb/template/xvfb_run.in new file mode 100644 index 0000000..ab66817 --- /dev/null +++ b/slapos/recipe/xvfb/template/xvfb_run.in @@ -0,0 +1,6 @@ +#!%(shell_path)s +# BEWARE: This file is operated by slapgrid +# BEWARE: It will be overwritten automatically + +export TMPDIR=%(tmp_path)s +exec %(xvfb_binary)s -screen 0 1024x768x24 -fbdir %(fbdir_path)s diff --git a/slapos/recipe/xvfb/template/xwd_run.in b/slapos/recipe/xvfb/template/xwd_run.in new file mode 100644 index 0000000..dac8410 --- /dev/null +++ b/slapos/recipe/xvfb/template/xwd_run.in @@ -0,0 +1,6 @@ +#!%(shell_path)s +# BEWARE: This file is operated by slapgrid +# BEWARE: It will be overwritten automatically + +export TMPDIR=%(tmp_path)s +exec %(xwd_binary)s -root -out $1 -- 2.1.4