def generate_config(self): CONFIG_TEMPLATE = """# Generated file, do not edit! [program:{program_name}] user=synthese command={command} # Quotes are required due to a bug in 3.0a8: # http://lists.supervisord.org/pipermail/supervisor-users/2010-March/000539.html environment=HOME='/home/synthese',USER='******' """ config = self.project.config format_config = config.__dict__.copy() # NOTE: supervisor doesn't seem to like underscores in names. Use # dashes instead. format_config['program_name'] = self.get_config_name().replace('_', '-') format_config['command'] = self.get_command() log_file = self.get_log_file() if log_file: CONFIG_TEMPLATE += """ redirect_stderr=true stdout_logfile={stdout_logfile} stdout_logfile_maxbytes={stdout_logfile_maxbytes} stdout_logfile_backups={stdout_logfile_backups} """ format_config['stdout_logfile'] = os.path.abspath(log_file) format_config.setdefault('stdout_logfile_maxbytes', '500MB') format_config.setdefault('stdout_logfile_backups', '4') supervisor_config = CONFIG_TEMPLATE.format(**format_config) utils.maybe_makedirs(os.path.dirname(self.config_path)) with open(self.config_path, 'wb') as f: f.write(supervisor_config) log.info('Supervisor config written to %s', self.config_path)
def generate_config(self): WSGI_APP_TEMPLATE = """# Generated file, do not edit! import os from os.path import join import sys bootstrap_config = {bootstrap_config} activate_this = join(bootstrap_config['env_bin_dir'], 'activate_this.py') execfile(activate_this, dict(__file__=activate_this)) sys.path.append(bootstrap_config['tools_dir']) import synthesepy.web application = synthesepy.web.get_application(bootstrap_config) """ wsgi_path = join( self.project.config.project_path, 'conf', 'generated', 'wsgi', 'app.wsgi') utils.maybe_makedirs(os.path.dirname(wsgi_path)) env = self.project.env config = self.project.config wsgi_app_content = WSGI_APP_TEMPLATE.format( bootstrap_config=repr({ 'env_bin_dir': self.project.env.pyenv_bin_path, 'tools_dir': self.project.env.tools_path, 'env_type': env.type, 'env_path': env.env_path, 'mode': env.mode, 'project_path': self.project.path})) with open(wsgi_path, 'wb') as f: f.write(wsgi_app_content) log.info('WSGI config written to %s', wsgi_path)
def import_update(template_id, import_id): import_ = _get_import(template_id, import_id) f = request.form for param in import_.params.itervalues(): if param.type == 'file': file = request.files[param.id] filename = werkzeug.secure_filename(file.filename) if not filename: continue relative_path = u'files/{0}'.format(filename) target_path = join(import_.path, 'files', filename) utils.maybe_makedirs(os.path.dirname(target_path)) file.save(target_path) param.value = relative_path else: value = f.get(param.id) if value is not None: param.value = value # TODO: bool type: convert checkbox values to 0 or 1. import_.save_params(session['username'], f.get('no_mail')) flash(i18n.import_updated) return redirect( url_for('.import_', template_id=template_id, import_id=import_id))
def __init__(self, env): self.env = env self.config = env.config self.download_cache_dir = join( self.env.c.thirdparty_dir, 'download_cache') utils.maybe_makedirs(self.download_cache_dir) PLATFORM_TO_TOOL = { 'win': 'vs', 'lin': 'make', } self.tool = PLATFORM_TO_TOOL[self.env.platform]
def generate_config(self): apache_config = '# Generated file, do not edit.\n\n' # Admin site is special: an admin alias is added to every sites. # NOTE: this expects the site called 'admin' may contain an 'admin' # package. admin_site = self.project.get_site('admin') admin_package = None if admin_site and not admin_site.generate_apache_compat_config: admin_package = admin_site.get_package('admin') for site in self.project.sites: apache_config += self._get_site_config(site, admin_package) utils.maybe_makedirs(os.path.dirname(self.config_path)) with open(self.config_path, 'wb') as f: f.write(apache_config) log.info('Apache config written to %s', self.config_path)
def put_file(path, content): utils.maybe_makedirs(os.path.dirname(path)) with open(path, 'wb') as f: f.write(content)