class MokshaMasterTemplate(Template): summary = 'Moksha Master Quickstart Template' _template_dir = 'templates/moksha/master' template_renderer = staticmethod(paste_script_template_renderer) vars = [ var('livewidget', 'Include an example live widget', default=False), var('widget_name', 'The name of the widget', default=None), var('stream', 'Include an example stream', default=False), var('stream_name', 'The name of the stream', default=None), var('consumer', 'Include an exmaple consumer', default=False), var('consumer_name', 'The name of the consumer', default=None), var('connector', 'Include an example connector', default=None), var('connector_name', 'The name of the connector', default=None), var('controller', 'Include an example controller', default=None), var('controller_name', 'The name of the controller', default=None), ] def pre(self, command, output_dir, vars): """Called before template is applied.""" package_logger = vars['package'] if package_logger == 'root': # Rename the app logger in the rare case a project is named 'root' package_logger = 'app' vars['package_logger'] = package_logger for key, value in vars.items(): if value == 'None': vars[key] = None elif value == 'True': vars[key] = True elif value == 'False': vars[key] = False
def config_content(self, command, vars): """ Called by ``self.write_config``, this returns the text content for the config file, given the provided variables. """ settable_vars = [ var('db_url', 'Database url for sqlite, postgres or mysql', default='sqlite:///%(here)s/studio.db'), var('ms_url', 'Url to the mapserv CGI', default='http://localhost/cgi-bin/mapserv'), var('admin_password', 'Password for default admin user', default=secret.secret_string(length=8)) ] for svar in settable_vars: if command.interactive: prompt = 'Enter %s' % svar.full_description() response = command.challenge(prompt, svar.default, svar.should_echo) vars[svar.name] = response else: if not vars.has_key(svar.name): vars[svar.name] = svar.default vars['cookie_secret'] = secret.secret_string() # call default pylons install return super(StudioInstaller, self).config_content(command, vars)
def __init__(self, name): super(DrupalModuleTemplate, self).__init__(name) self.vars = [ var('name', 'Human-readabale name'), var('description', 'Description of the module'), var('core_version', 'Core version', default=self.defaults['core_version']), var('version', 'Version of the module', default=self.defaults['version']), var('package', 'Package', default=self.defaults['package']), ]
def __init__(self, name): super(OdeskAppTemplate, self).__init__(name) secret_key = ''.join([random.choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) self.vars += [ var('secret_key', 'Secret key for Django settings', default=secret_key), var('media_dir', 'Name of the media directory', default='media'), var('templates_dir', 'Directory to hold base templates', default='templates'), var('odesk_admin', 'Enter your oDesk username, so you could access the admin', default=NoDefault), ]
class MinimalProjectTemplate(Template): summary = 'Template for creating a minimal blazeweb project' _template_dir = ('blazeweb', 'paster_tpls/minimal-project') template_renderer = staticmethod(paste_script_template_renderer) vars = [ var('description', 'One-line description of the package'), var('author', 'Your name'), var('programmer_email', 'Your email'), ]
class DjangoAppTemplate(Template): _template_dir = 'templates/app_package' summary = 'template for a distributable django app' vars = [ var('version', 'Version (like 0.1)', default='0.1'), var('description', 'One-line description of the package'), var('long_description', 'Multi-line description (in reST)'), var('keywords', 'Space-separated keywords/tags'), var('author', 'Author name', default=sh('git config --get user.name').strip()), var('author_email', 'Author email', default=sh('git config --get user.email').strip()), var('url', 'URL of homepage'), var('license_name', 'License name', default="BSD"), var('current_year', 'Copyright year', default=date.today().year) # var('zip_safe', 'True/False: if the package can be distributed as a .zip file', # default=False), ] template_renderer = staticmethod(paste_script_template_renderer) use_cheetah = False required_templates = [] def check_vars(self, vars, command): if not command.options.no_interactive and \ not hasattr(command, '_deleted_once'): del vars['package'] command._deleted_once = True return super(DjangoAppTemplate, self).check_vars(vars, command)
class CementPluginTemplate(templates.Template): """ Cement plugin default paste template class. """ _template_dir = 'templates/cementplugin' template_renderer = staticmethod(paste_script_template_renderer) summary = 'Cement Plugin Standard Template' egg_plugins = ['PasteScript', 'cement'] vars = [ templates.var("plugin", "cement plugin name", default=None), templates.var("project", "Parent application this plugin is for", default=None), templates.var("package", "Package module name", default=''), templates.var("cement_version", "Cement version", default=CEMENT_VERSION), templates.var("cement_next_version", "Cement Next Version", default=CEMENT_NEXT_VERSION), templates.var("creator", "Creator", default=''), templates.var("creator_email", "Creator Email", default=''), templates.var("url", "URL", default=''), templates.var("license", "License", default=''), ] def pre(self, command, output_dir, vars): """Called before template is applied.""" pass
class NewModule(templates.Template): egg_plugins = ['openerp_newmodule'] summary = 'Template for creating a basic openerp package skeleton' required_templates = [] _template_dir = 'templates/newmodule' use_cheetah = True vars = [ var('module_name', 'Module name (like "Project Issue")', default='My Module'), var('description', 'One-line description of the module'), var('version', 'Version', default='1.0'), var('author', 'Author name'), var('author_email', 'Author email'), var('category', 'Category'), var('website', 'Website'), var('depends', 'Dependencies [space-separated module names]',default=''), var('is_web', 'Is web addon? [yes/no]', default='no'), ] def pre(self, command, output_dir, vars): """ Called before template is applied. """ # import pdb;pdb.set_trace() depends = vars['depends'].split(' ') vars['is_web'] = vars['is_web'] == 'yes' and True or False if vars['is_web'] and not 'web' in depends: depends.append('web') vars['depends'] = [x for x in depends if x]
def __init__(self, *args, **kwargs): self.vars = common.Template.vars + [\ templates.var( 'tomcat_instance', 'tomcat instance to drop the instance inside', default = ''), templates.var('webapp_name', 'tomcat instance to drop the instance inside', default = self.webapp_type), ] common.Template.__init__(self, *args, **kwargs)
class MokshaLiveWidgetTemplate(Template): _template_dir = 'templates/moksha/livewidget' template_renderer = staticmethod(paste_script_template_renderer) summary = 'Moksha Live Widget Quickstart Template' egg_plugins = ['Moksha'] vars = [ var('topic', 'The moksha topic to utilize', default='moksha.test'), var('livewidget', 'Include an example live widget', default=False), var('widget_name', 'The name of the widget', default=None), ] def pre(self, command, output_dir, vars): """Called before template is applied.""" if 'widget_name' not in vars: vars['widget_name'] = vars['package'].title() + 'Widget'
class ProjectTemplate(Template): summary = 'Template for creating a blazeweb project' _template_dir = ('blazeweb', 'paster_tpls/project') template_renderer = staticmethod(paste_script_template_renderer) vars = [ var('description', 'One-line description of the package'), var('author', 'Your name'), var('programmer_email', 'Your email'), ] def pre(self, command, output_dir, vars): # convert user's name into a username var author = vars['author'] vars['username'] = author.split(' ')[0].capitalize()
class PySUITTemplate(Template): """Based on `pylons.util.PylonsTemplate`.""" _template_dir = 'templates/suit' summary = 'Pylons default_project with SUIT as the templating engine.' template_renderer = staticmethod(paste_script_template_renderer) vars = [ var('sqlalchemy', 'True/False: Include SQLAlchemy 0.5 configuration', default=False) ] ensure_names = ['description', 'author', 'author_email', 'url'] def pre(self, command, output_dir, vars): """Called before template is applied.""" package_logger = vars['package'] if package_logger == 'root': # Rename the app logger in the rare case a project is named 'root' package_logger = 'app' vars['package_logger'] = package_logger vars['babel_templates_extractor'] = '' # No PySUIT support yet. # Ensure these exist in the namespace for name in self.ensure_names: vars.setdefault(name, '') vars['version'] = vars.get('version', '0.1') vars['zip_safe'] = asbool(vars.get('zip_safe', 'false')) vars['sqlalchemy'] = asbool(vars.get('sqlalchemy', 'false'))
class SkinTemplate(Template): _template_dir = 'template' summary = 'Skin skeleton' vars = [ var('author', 'Author name', default='Think Thanks'), ]
class TurboGearsExtTemplate(templates.Template): """ TurboGears 2 extension paster template class """ summary = 'TurboGears 2 extension template' _template_dir = 'templates/tgext' template_renderer = staticmethod(paste_script_template_renderer) egg_plugins = ['TurboGears2', 'Pylons', 'PasteScript'] required_templates = [] vars = [templates.var('description', 'Short description of the extension')] def pre(self, command, output_dir, vars): # FIXME: for the moment we have to do a copy/paste from the Turbogears # template so that we have defined the variables from setup.py_tmpl # which is very similar to the one found in the Turbogears quickstart # template. template_engine = vars.setdefault('template_engine', 'genshi') vars['sqlalchemy'] = True if template_engine == 'mako': # Support a Babel extractor default for Mako vars['babel_templates_extractor'] = \ "('templates/**.mako', 'mako', None),\n%s#%s" % (' ' * 4, ' ' * 8) else: vars['babel_templates_extractor'] = ''
class MinimalPylonsTemplate(PylonsTemplate): _template_dir = ('pylons', 'templates/minimal_project') summary = 'Pylons minimal application template' vars = [ var('template_engine', 'mako/genshi/jinja2/etc: Template language', default='mako'), ]
def append_db_password(vars): default_key = ''.join([ choice( 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for i in range(10) ]) vars.append(var('db_password', 'DB Password', default=default_key))
class ZopeDeploy(Template): _template_dir = 'zope_deploy' summary = "(Paste) deployment of a Zope application" vars = [ var('user', 'Name of an initial administrator user', default=NoDefault), var('passwd', 'Password for the initial administrator user', default=NoDefault), var('eggs_dir', 'Location where zc.buildout will look for and place ' 'packages', default=os.path.join(HOME, 'buildout-eggs')) ] def check_vars(self, vars, cmd): vars = super(ZopeDeploy, self).check_vars(vars, cmd) vars['eggs_dir'] = os.path.expanduser(vars['eggs_dir']) return vars
class OpenblockTemplate(templates.Template): required_templates = [] use_cheetah = False summary = "Basic OpenBlock project template" _template_dir = 'project_templates/openblock' vars = [ var('password_salt', 'Salt used to hash passwords', default=_random_string()), var('reset_salt', 'Salt used to hash password resets', default=_random_string()), var('staff_cookie_val', 'Secret cookie value used to identify staff', default=_random_string()) ]
class MySQL(DatabaseSetup): """MySQL database""" prefix = 'trac_' # prefix to prepend database names with options = [ var('database_user', 'name of the database user', default='trac'), var('database_password', 'user password for the database'), var('database_admin', 'name of database root user (admin)', default='root'), var('database_admin_password', 'password for the admin user'), var('mysql_port', 'port where MySQL is served', default='3306') ] def enabled(self): try: subprocess.call(['mysql', '--help'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) except OSError: return False try: import MySQLdb except ImportError: return False return True def db_string(self): return 'mysql://${database_user}:${database_password}@localhost:${mysql_port}/%s${project}' % self.prefix def setup(self, **vars): """create and grant priveleges on a MySQL db""" vars = vars.copy() vars['database'] = self.prefix + vars['project'] sql = """create database %(database)s; grant all privileges on %(database)s.* to %(database_user)s@localhost identified by '%(database_password)s'; """ % vars command = ['mysql', '-u', vars['database_admin']] password = vars['database_admin_password'] if password: command.append('--password=%s' % password) process = subprocess.Popen(command, stdin=subprocess.PIPE) process.communicate(input=sql)
class PloneTemplate(Template): _template_dir = 'paster-templates/plone' required_templates = ['deliverance'] template_renderer = staticmethod(paste_script_template_renderer) summary = 'Plone-specific template for deliverance-proxy' vars = [ var('site_name', "The name of your Plone site (no /'s)"), ]
class AttributeServiceTemplate(TemplateBase): """Paster template for the SAML attribute service""" DEFAULT_PORT = 5443 DEFAULT_MOUNT_PATH = '/attribute-service' DEFAULT_ISSUER_NAME = 'O=NDG, OU=Security, CN=localhost' DEFAULT_ISSUER_FORMAT = Issuer.X509_SUBJECT _template_dir = 'attributeservice' summary = 'NDG Security SAML Attribute Service template' vars = [ var('portNumber', 'Port number for service to listen on [applies to running with ' 'paster ONLY]', default=DEFAULT_PORT), var('mountPath', ('URI path to mount service i.e. "https://myhost/<mountPath>" [' 'Nb. for mod_wsgi path may be e.g. "https://myhost/<script alias ' 'path><mountPath>" !]'), default=DEFAULT_MOUNT_PATH), var('issuerName', ('ID of this service used in SAML queries and responses'), default=DEFAULT_ISSUER_NAME), var('issuerFormat', ('Format of issuerName string; if using the default, ensure that ' 'the issuerName value is a correctly formatted X.509 Subject ' 'Name'), default=DEFAULT_ISSUER_FORMAT) ] def pre(self, command, output_dir, vars_): '''Extend to fix log file path setting and check mount point setting @param command: command to create template @type command: @param output_dir: output directory for template file(s) @type output_dir: string @param vars_: variables to be substituted into template @type vars_: dict ''' # Fix for mount point in case leading slash was omitted. if not vars_['mountPath'].startswith('/'): vars_['mountPath'] = '/' + vars_['mountPath'] super(AttributeServiceTemplate, self).pre(command, output_dir, vars_)
class TurboGearsTemplate(templates.Template): """ TurboGears 2 default paste template class """ _template_dir = 'templates/turbogears' template_renderer = staticmethod(paste_script_template_renderer) summary = 'TurboGears 2. Standard Quickstart Template' egg_plugins = ['PasteScript', 'Pylons', 'TurboGears2'] vars = [ templates.var('sqlalchemy', 'use SQLAlchemy as ORM', default=True), templates.var('auth', 'use authentication and authorization support', default="sqlalchemy"), templates.var('geo', 'Include GIS support (True/False)', default='False'), templates.var('mako', 'Include Mako support (True/False)', default='False'), ] def pre(self, command, output_dir, vars): """Called before template is applied.""" package_logger = vars['package'] if package_logger == 'root': # Rename the app logger in the rare case a project is named 'root' package_logger = 'app' vars['package_logger'] = package_logger template_engine = \ vars.setdefault('template_engine', 'genshi') if template_engine == 'mako': # Support a Babel extractor default for Mako vars['babel_templates_extractor'] = \ "('templates/**.mako', 'mako', None),\n%s#%s" % (' ' * 4, ' ' * 8) else: vars['babel_templates_extractor'] = '' if vars['geo'] == 'True': # Add tgext.geo as paster plugin vars['egg_plugins'].append('tgext.geo')
class ExistingSVN(RepositorySetup): """Use an existing repository""" options = [ var('repository_dir', 'location of SVN repository') ] def enabled(self): return True def config(self): return { 'trac': { 'repository_dir': '${repository_dir}', 'repository_type': 'svn' } }
class PylonsTemplate(Template): _template_dir = ('pylons', 'templates/default_project') template_renderer = staticmethod(paste_script_template_renderer) summary = 'Pylons application template' egg_plugins = ['PasteScript', 'Pylons'] vars = [ var('template_engine', 'mako/genshi/jinja2/etc: Template language', default='mako'), var('sqlalchemy', 'True/False: Include SQLAlchemy 0.5 configuration', default=False), ] ensure_names = ['description', 'author', 'author_email', 'url'] def pre(self, command, output_dir, vars): """Called before template is applied.""" package_logger = vars['package'] if package_logger == 'root': # Rename the app logger in the rare case a project is named 'root' package_logger = 'app' vars['package_logger'] = package_logger template_engine = \ vars.setdefault('template_engine', pylons.configuration.default_template_engine) if template_engine == 'mako': # Support a Babel extractor default for Mako vars['babel_templates_extractor'] = \ ("('templates/**.mako', 'mako', {'input_encoding': 'utf-8'})" ",\n%s#%s" % (' ' * 4, ' ' * 8)) else: vars['babel_templates_extractor'] = '' # Ensure these exist in the namespace for name in self.ensure_names: vars.setdefault(name, '') vars['version'] = vars.get('version', '0.1') vars['zip_safe'] = asbool(vars.get('zip_safe', 'false')) vars['sqlalchemy'] = asbool(vars.get('sqlalchemy', 'false'))
class CIRProjectTemplate(DjangoTemplate): _template_dir = 'templates/cir_project' summary = 'Template for a CIR Django news application' vars = [ var('staging_domain', 'Parent domain for your staging site.', default="beta.example.com"), var('production_domain', 'Parent domain for your production site.', default="example.com"), var('repository_url', 'Git URL for the account your project will be deployed from', default="[email protected]:cirlabs"), ] def __init__(self, name): append_secret_key(self.vars) append_db_password(self.vars) super(CIRProjectTemplate, self).__init__(name)
class NewsAppsProjectTemplate(DjangoTemplate): _template_dir = 'templates/newsapps_project' summary = 'Template for a News Applications Django project' vars = [ var('staging_domain', 'Parent domain for your staging site.', default="beta.example.com"), var('production_domain', 'Parent domain for your production site.', default="example.com"), var('repository_url', 'Git repo where your project will be deployed from.', default="[email protected]:example/project_name.git"), ] def __init__(self, name): append_secret_key(self.vars) append_db_password(self.vars) super(NewsAppsProjectTemplate, self).__init__(name)
def __init__(self, *args, **kwargs): tomcat.TomcatAppBaseTemplate.__init__(self, *args, **kwargs) self.vars += [templates.var('hudson_irc_support', 'hudson irc support (true or false)', default = 'true'), templates.var('hudson_irc_server', 'hudson irc server to join', default = 'irc.freenode.net'), templates.var('hudson_irc_port', 'hudson irc server port', default = '6667'), templates.var('hudson_irc_nick', 'hudson irc nickname', default = 'hudson'), templates.var('hudson_irc_channels', 'comma separated list of channels to join ', default = '#hudson-test'), templates.var('hudson_email_from', 'comma separated list of channels to join ', default = 'hudson <foo@localhost>'), templates.var('hudson_url', 'Hudson accessible url for notificiation (mails, irc)', default = 'http://foo:8080/hudson') ]
def append_secret_key(vars): default_key = "".join([choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]) vars.append(var("secret_key", "Secret key", default=default_key))
""" This provides the set up need to provide EvasionWeb specific commands in paster. This module provides customer Project and App template creation as well as other useful commands. Oisin Mulvihill 2010-08-03 """ # http://pythonpaste.org/script/developer.html # from paste.script.command import Command from paste.script.templates import Template, var vars = [ var('version', 'Version (like 0.1)', default='0.1'), var('description', 'One-line description of the package'), var('long_description', 'Multi-line description (in reST)'), var('keywords', 'Space-separated keywords/tags'), var('author', 'Author name'), var('author_email', 'Author email'), var('url', 'URL of homepage'), var('license_name', 'License name', 'Commercial, All rights reserved.'), var('zip_safe', 'True/False: if the package can be distributed as a .zip file', default=False), var('dollar', 'template hack to generate mako ${} expression (please ignore)','$'), ] class ProjectTemplate(Template): """Set up to create an EvasionWeb project. This is simply a configuration file, some
from paste.script.templates import Template, var import os vars = [ var("type", "What type of project do you want? [plone|pyramid|django|pycms]"), ] class BuildoutSkel(Template): _template_dir = './skel/common' summary = 'Buildout config files' vars = vars def write_files(self, command, output_dir, vars): """ Override so as to put the files in '.' """ type_dir = os.path.join(self.module_dir(), "./skel/%s" % vars['type']) assert os.path.isdir(type_dir) # First write generic stuff, then specific # Template.write_files(self, command, ".", vars) self._template_dir = type_dir Template.write_files(self, command, ".", vars)
def append_secret_key(vars): default_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) vars.append( var('secret_key', 'Secret key', default=default_key) )
from paste.util.template import paste_script_template_renderer from paste.script.templates import Template, var vars = [ var('version', 'Version (like 0.1)', default="0.1"), var('description', 'One-line description of the plugin'), var('long_description', 'Multi-line description (in reST)'), var('keywords', 'Space-separated keywords/tags'), var('author', 'Author name'), var('author_email', 'Author email'), var('url', 'URL of homepage'), var('license_name', 'License name'), ] class NinfoPluginTemplate(Template): _template_dir = 'templates' summary = 'nInfo Plugin template' vars = vars def pre(self, command, output_dir, vars): vars['plugin'] = vars['package'].replace("-","").replace("ninfoplugin", "") vars['project_dir'] = vars['project'].replace("-","_")
# (at your option) any later version. # # pystraps 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 pystraps. If not, see <http://www.gnu.org/licenses/>. __version__ = (0, 0, 0, "final", 0) from paste.script import templates from datetime import datetime TEMPLATE_VARIABLES = [ templates.var("description", "Gives a one-line description of the package", default="(TODO: Missing description)"), templates.var("keywords", "Defines keywords (tags) for the package", default="(TODO: Missing keywords)"), templates.var("author", "Defines the author name of the package", default="(TODO: Missing author name)"), templates.var("author_email", "Defines the author email of the package", default="(TODO: Missing author email)"), templates.var("url", "Defines the URL of homepage for the package", default="(TODO: Missing homepage URL)"), templates.var("year", "Defines the year which copyright is valid since", default="(TODO: Missing copyright year)"), templates.var("zip_safe", "Either of True/False: " "Indicates if the package can be distributed as a .zip file", default=False), ]
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # from paste.script.templates import Template from paste.script.templates import var import duende DUENDE_VERSION = duende.__version__ TEMPLATES_DIR = '../resources/paste_templates/' VARS = [ var('version', '0.0.1', default='0.0.1'), var('description', 'One-line description of the package'), var('author', 'Author name'), var('author_email', 'Author email'), var('zip_safe', 'True/False: package can be distributed as a .zip file', default=False), var('duende_version', DUENDE_VERSION, default=DUENDE_VERSION), ] class DuendeProjectTemplate(Template): """Class to handle creation of duende applications""" _template_dir = TEMPLATES_DIR + 'duende' summary = 'Template for creating a Duende application' required_templates = []
from paste.script.templates import Template, var from paste.util.template import paste_script_template_renderer as renderer vars = [ var('project_name', 'Name of the project (like "My Project")'), var('package_name', 'Name of the project package (like "my_project")'), var('description', 'Description of the project'), var('version', 'Project Version (like 0.1)', default='0.1'), var('django_version', 'Django Version (like 1.3)', default='1.3'), var('author', 'Author name'), var('author_email', 'Author email'), ] class DjangoProjectBuildoutTemplate(Template): egg_plugins = ['DjangoProjectBuildout'] summary = 'Template for creating a Django project with zc.buildout' # required_templates = [] _template_dir = 'template' vars = vars template_renderer = staticmethod(renderer) def pre(self, command, output_dir, vars): # Generate secret_key from random import choice chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' secret_key = ''.join([choice(chars) for i in range(50)]) vars['secret_key'] = secret_key
if config.endswith('/'): config = config[:-1] path_elems = config.split('/')[-1].split('.') if len(path_elems) > 1: vars['config'] = '.'.join(path_elems[:-1]) else: vars['config'] = path_elems[0] def post(self, command, output_dir, vars): sys = vars['sys'] dirs = [os.path.join(sys, 'etc', 'init.d')] for directory in dirs: for filep in os.listdir(directory): p = os.path.join(directory, filep) os.chmod(p, stat.S_IRGRP|stat.S_IXGRP|stat.S_IRWXU) Template.required_templates = ['minitage.instances.env'] from minitage.paste.common import running_user, gid, group Template.vars = common.Template.vars + \ [ templates.var('config', 'The configuration file to use as a base for the init script', default = 'prod.ini'), templates.var('with_reload', 'Enable auto reloading of the' 'server on code changes. [y/n]', default= 'n'), templates.var('user', 'Default user', default = running_user), templates.var('group', 'Default group', default = group), ] # vim:set et sts=4 ts=4 tw=80:
# either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** from paste.script.templates import Template, var vars = [ var("appname", 'Application repository name (like "server-core")'), var("version", "Version (like 0.1)"), var("description", "One-line description of the project"), var("author", "Author name"), var("author_email", "Author email"), var("url", "URL of homepage (or Repository root)"), ] class AppTemplate(Template): _template_dir = "services_base" summary = "A Mozilla Services application" vars = vars def post(self, command, output_dir, vars):
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. __docformat__ = 'restructuredtext en' import os import sys from minitage.paste.instances import varnish as common from paste.script import templates class Template(common.Template): """A Varnish2 template""" summary = 'Template for creating a varnish2 instance' Template.vars = common.common_vars + [ templates.var('backend', 'Backend', default = 'localhost:8080'), templates.var( 'vp', 'Daemon prefix', default = os.path.join(sys.prefix, 'dependencies', 'varnish-2.0.3', 'parts', 'part') ), ] # vim:set et sts=4 ts=4 tw=80:
s_cert.set_serial_number(2) s_cert.set_pubkey(s_key) s_cert.set_issuer(cert.get_subject()) s_cert.sign(ca_key,"MD5") dump_write(dump_certificate(FILETYPE_PEM, s_cert), server_crt_path) print "Generated Server certificate in %s" % server_crt_path for p in [ca_key_path, server_key_path]: os.chmod(p, 0600) SSL_VARS = [ templates.var('ssl_ca_C', 'SSL Ca Country', default = 'FR'), templates.var('ssl_ca_L', 'SSL Ca town', default = 'Paris'), templates.var('ssl_ca_ST', 'SSL Ca state', default = 'CaState'), templates.var('ssl_ca_O', 'SSL Ca Organization', default = 'organizationCorp'), templates.var('ssl_ca_OU', 'SSL Ca Unit', default = 'SpecialUnit'), templates.var('ssl_ca_emailAddress', 'SSL Ca email', default = '%s@localhost'%running_user), templates.var('ssl_server_C', 'SSL Server Country', default = 'FR'), templates.var('ssl_server_L', 'SSL Server town', default = 'Paris'), templates.var('ssl_server_ST', 'SSL Server state', default = 'ServerState'), templates.var('ssl_server_O', 'SSL Server Organization', default = 'organizationCorp'), templates.var('ssl_server_OU', 'SSL Server Unit', default = 'SpecialUnit'), templates.var('ssl_server_emailAddress', 'SSL Server email', default = '%s@localhost' % ( running_user) ), ]
def create_project(self, project, templates, vars=None, database=None, repository=None, return_missing=False): """ * project: path name of project * templates: templates to be applied on project creation * vars: variables for interpolation * database: type of database to use * repository: type of repository to use """ ### set variables dirname = os.path.join(self.directory, project) if os.path.isdir(dirname) and os.listdir(dirname): raise ValueError("Project directory %r already exists, " "cowardly refusing to create anything" % dirname) _vars = vars or {} vars = self.vars.copy() vars.update(_vars) vars['project'] = project permissions = dict([(key, value[:]) for key, value in self.permissions.items()]) wiki = self.wiki[:] ### munge configuration # get templates # XXX hack to get the specified DB out of pastescript templates if not database: if isinstance(templates, ProjectTemplates): pastescript_templates = templates.pastescript_templates else: pastescript_templates = ProjectTemplates(*(templates + self.site_templates)).pastescript_templates databases = set([ template.database() for template in pastescript_templates if template.db is not None]) if databases: assert len(databases) == 1 database = databases.pop() if not database: database = SQLite() _templates = [] _templates.append(database.config()) if repository: _templates.append(repository.config()) if isinstance(templates, ProjectTemplates): if _templates: templates.append(*_templates) else: templates += _templates templates = self.project_templates(templates) # determine the vars/options optdict = templates.vars(self.options) repo_fields = {} if database: vars2dict(optdict, *database.options) if repository: vars2dict(optdict, *repository.options) repo_fields = self.repository_fields(project).get(repository.name, {}) ### interpolate configuration command = create_distro_command(interactive=self.interactive) # check for missing variables missing = templates.missing(vars) missing.update(set(optdict.keys()).difference(vars.keys())) if return_missing: return missing if missing: # use default repo fields if they are missing for field in repo_fields: if field in missing: vars[field] = repo_fields[field] missing.remove(field) # add missing variables to the optdict for missed in missing: if missed not in optdict: optdict[missed] = var(missed, '') if missing: paste_template = Template(project) paste_template._read_vars = dict2vars(optdict) # XXX bad touch paste_template.check_vars(vars, command) # run the pre method of the pastescript templates # XXX should this be done here? command.interactive = False for paste_template in templates.pastescript_templates: paste_template.pre(command, dirname, vars) ### create the database if database: database.setup(**vars) ### create the trac environment options = templates.options_tuples(vars) options.append(('project', 'name', project)) # XXX needed? if self.inherit: options.append(('inherit', 'file', self.inherit)) env = Environment(dirname, create=True, options=options) ### repository setup if repository: repository.setup(**vars) try: repos = env.get_repository() repos.sync() except TracError: pass ### read the generated configuration _conf_file = os.path.join(dirname, 'conf', 'trac.ini') fp = file(_conf_file) _conf = fp.read() fp.close() ### run pastescript templates for paste_template in templates.pastescript_templates: paste_template.write_files(command, dirname, vars) paste_template.post(command, dirname, vars) # read permissions for agent, perm in paste_template.permissions.items(): permissions.setdefault(agent, []).extend(perm) # read wiki directories wiki_dir = paste_template.wiki_dir() if wiki_dir is not None: wiki.append(wiki_dir) # write back munged configuration munger = ConfigMunger(_conf, options) fp = file(_conf_file, 'w') munger.write(fp) fp.close() # TODO: update the inherited file: # * intertrac # trac-admin upgrade the project env = Environment(dirname) if env.needs_upgrade(): env.upgrade() ### trac-admin operations admin = TracLegosAdmin(dirname) # remove the default items admin.delete_all() # load wiki pages admin.load_pages() # default wiki pages for page_dir in wiki: admin.load_pages(page_dir) # add permissions if permissions: admin.add_permissions(permissions)
from paste.script.templates import Template, var q = [ var('version', 'Version (like 0.1)'), var('description', 'One-line description of the package'), var('long_description', 'Multi-line description (in reST)'), var('keywords', 'Space-separated keywords/tags'), var('author', 'Author name'), var('author_email', 'Author email'), var('url', 'URL of homepage'), var('license_name', 'License name'), var('zip_safe', 'True/False: if the package can be distributed as a .zip file', default=False), var('deferred', 'True/False: if you want to activate deferrer builtin', default=True), var('remote_api', 'True/False: if you want to activate remote_api builtin', default=True), var('appstats', 'True/False: if you want to activate appstats builtin', default=True), var('bootstrap_version', 'The Bootstrap version you desire, something like: `3.2.0`.', default='3.2.0'), var('jquery_version', 'The jQuery version you desire, something like: `1.11.1`.', default='1.11.1') ] class GaeProjectTemplate(Template): _template_dir = 'templates' summary = 'Google Appengine Project template' vars = q
from paste.script.templates import Template, var vars = [var("pycms_project_path", "Path to your PyCMS project")] class PyCMSBuildoutTemplate(Template): _template_dir = "./buildout_skel" summary = "PyCMS buildout template" vars = vars def write_files(self, command, output_dir, vars): """ Override so as to put the files in '.' """ Template.write_files(self, command, ".", vars)
sys = vars['sys'] dirs = [os.path.join(sys, 'bin'), os.path.join(sys, 'etc', 'init.d')] for directory in dirs: for filep in os.listdir(directory): p = os.path.join(directory, filep) os.chmod(p, stat.S_IRGRP|stat.S_IXGRP|stat.S_IRWXU) Template.required_templates = ['minitage.instances.env'] from minitage.paste.common import running_user, gid, group common_vars = common.Template.vars + [ templates.var('config', 'You can precise a custom config file ' 'to use instead of the default one. ' 'The content of this file will be copied into ' 'the varnish configuration file (in $sys/etc/varnish).', default = ''), templates.var('purge_ips', 'IPs allowed to purge separated by whitespaces', default = 'localhost'), templates.var('cache_size', 'Cache size', default = '1G'), templates.var('min_ttl', 'Default minimum ttl', default = '3600'), templates.var('host_address', 'Host and port to listen on', default = 'localhost:9002'), templates.var('telnet_address', 'Telnet interface to listen on', default = 'localhost:9004'), templates.var('user', 'Default user', default = running_user), templates.var('vhost_vhm', 'Virtualhost name if any', default = 'www.host.tld:80'), templates.var('zope_path', 'Site Path in zope', default = '/plone'), templates.var('worker_t', """[int][,int[,int]] # Number of worker threads -w <fixed_count> -w min,max -w min,max,timeout [default: 1,1000,120]""", default="1,1000,120"),
) ), db_path, ) ) README = os.path.join(vars['path'], 'README.mysql.%s-%s' % ( vars['project'], vars['db_name'] ) ) open(README, 'w').write(infos) print "Installation is now finished." print infos print "Those informations have been saved in %s." % README Template.required_templates = ['minitage.instances.env'] from minitage.paste.common import running_user, gid, group #group = grp.getgrgid(gid)[0] Template.vars = common.Template.vars + \ [ templates.var('mysql_ver', 'Mysql major version (50|51)', default = '55'), templates.var('db_name', 'Database name', default = 'minitagedb'), templates.var('db_user', 'Default user', default = running_user), templates.var('db_host', 'Host to listen on', default = 'localhost'), templates.var('db_port', 'Port to listen to', default = '3306'), templates.var('root_password', 'Mysql root password', default = 'secret'), templates.var('password', 'Database password', default = 'secret'), ] # vim:set et sts=4 ts=4 tw=80:
'README.postgresql.%s-%s' % ( vars['project'], vars['db_name'] ) ) open(README, 'w').write(infos) print "Installation is now finished." print infos print "Those informations have been saved in %s." % README def read_vars(self, command=None): vars = templates.Template.read_vars(self, command) myname = special_chars_re.sub('', command.args[0]) for i, var in enumerate(vars[:]): if var.name in ['db_user', 'db_name']: vars[i].default = myname return vars Template.required_templates = ['minitage.instances.env'] gid = pwd.getpwnam(running_user)[3] #group = grp.getgrgid(gid)[0] Template.vars = common.Template.vars + \ [ templates.var('db_name', 'Database name', default = 'minitagedb'), templates.var('db_user', 'Default user', default = 'minitageuser'), templates.var('db_password', 'Default user password', default = 'secret'), templates.var('db_host', 'Host to listen on', default = 'localhost'), templates.var('db_port', 'Port to listen to', default = '5432'), ] # vim:set et sts=4 ts=4 tw=80:
from paste.script import templates from random import choice default_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)]) vars = [ templates.var('secret_key', 'Secret key', default=default_key), ] class BasicProjectTemplate(templates.Template): _template_dir = 'templates/basic_project' summary = 'Basic skeleton for Consumer Tools projects' vars=vars
'README.openldap.%s-%s.%s' % ( vars['project'], vars['db_orga'], vars['db_suffix'] ) ) open(README, 'w').write(infos) print "Installation is now finished." print infos print "Those informations have been saved in %s." % README Template.required_templates = ['minitage.instances.env'] gid = pwd.getpwnam(running_user)[3] #group = grp.getgrgid(gid)[0] Template.vars = common.Template.vars + \ [ templates.var('db_host', 'Host to listen on', default = 'localhost'), templates.var('db_suffix', 'Suffix for the organization to create', default = 'org'), templates.var('db_orga', 'Organization node name to create', default='domain'), templates.var('db_port', 'Port to listen to', default = '389'), templates.var('ssl_port', 'Port to listen to for SSL connections', default = '636'), templates.var('db_user', 'LDAP Super user', default = running_user), templates.var('db_password', 'LDAP Super user password', default = running_user), templates.var('ol_version', 'OPENLDAP version', default = '2.4'), ] + ssl.SSL_VARS # vim:set et sts=4 ts=4 tw=80:
from paste.script.templates import Template, var vars = [ var('version', 'Version (like 0.1)'), var('description', 'One-line description of the package'), var('keywords', 'Space-separated keywords/tags'), var('author', 'Author name'), var('author_email', 'Author email'), var('url', 'URL of homepage'), var('license_name', 'License name'), var('zip_safe', 'True/False: if the package can be distributed as a .zip file', default=False), ] class PyCMSProjectTemplate(Template): _template_dir = './skel' summary = 'PyCMS project template' vars = vars
def append_secret_key(self): default_key = ''.join(choice(CHARSET) for i in range(50)) self.vars.append(var('secret_key', 'Secret key', default=default_key))
def append_db_password(vars): default_key = ''.join([choice('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') for i in range(10)]) vars.append( var('db_password', 'DB Password', default=default_key) )
from paste.script import templates from minitage.paste.instances import common from minitage.paste.common import running_user, gid, group class Template(common.Template): """A nginx template""" summary = 'Template for creating a nginx instance' def post(self, command, output_dir, vars): sys = vars['sys'] dirs = [os.path.join(sys, 'bin'), os.path.join(sys, 'etc', 'init.d')] for directory in dirs: for filep in os.listdir(directory): p = os.path.join(directory, filep) os.chmod(p, stat.S_IRGRP|stat.S_IXGRP|stat.S_IRWXU) common.Template.post(self, command, output_dir, vars) Template.vars = common.Template.vars + \ [templates.var('http_address', 'HTTP address to listen on', default = '0.0.0.0'), templates.var('http_port', 'HTTP port to listen on', default = '9080'), templates.var('https_address', 'HTTPS address to listen on', default = '0.0.0.0'), templates.var('https_port', 'HTTPS port to listen on', default = '9443'), templates.var('server_name', 'Default servername', default = 'localhost'), templates.var('user', 'Default user', default = running_user), ] # vim:set et sts=4 ts=4 tw=80:
from paste.script.templates import Template, var vars = [ var('appname', 'Application name'), var('description', 'One-line description of the project'), var('author', 'Author name')] class AppTemplate(Template): _template_dir = 'cornice' summary = "A Cornice application" vars = vars def post(self, command, output_dir, vars): if command.verbose: print('Generating Application...')
from paste.script.templates import Template, var vars = [ var('version', '0.1'), var('description', 'ETL Project'), var('long_description', 'This project was autogenerated by {0}.'.format(__package__)), var('keywords', 'Space-separated keywords/tags'), var('author', 'Author name'), var('author_email', 'Author email'), var('url', 'URL of homepage'), var('license_name', 'License name'), var('zip_safe', 'True/False: if the package can be distributed as a .zip file', default=False), ] class ETLProjectTemplate(Template): _template_dir = 'templates/project' summary = 'ETL Project' vars = vars