How to use the orchestra.contrib.webapps.settings function in orchestra

To help you get started, we’ve selected a few orchestra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glic3rinu / django-orchestra / orchestra / contrib / webapps / types / php.py View on Github external
# Disable functions
        if self.PHP_DISABLED_FUNCTIONS:
            enable_functions = init_vars.pop('enable_functions', None)
            enable_functions = OrderedSet(enable_functions.split(',') if enable_functions else ())
            disable_functions = init_vars.pop('disable_functions', None)
            disable_functions = OrderedSet(disable_functions.split(',') if disable_functions else ())
            if disable_functions or enable_functions or self.is_fpm:
                # FPM: Defining 'disable_functions' or 'disable_classes' will not overwrite previously
                #      defined php.ini values, but will append the new value
                for function in self.PHP_DISABLED_FUNCTIONS:
                    if function not in enable_functions:
                        disable_functions.add(function)
                init_vars['disable_functions'] = ','.join(disable_functions)
        # Process timeout
        if timeout:
            timeout = max(settings.WEBAPPS_PYTHON_DEFAULT_TIMEOUT, int(timeout))
            # Give a little slack here
            timeout = str(timeout-2)
            init_vars['max_execution_time'] = timeout
        # Custom error log
        if self.PHP_ERROR_LOG_PATH and 'error_log' not in init_vars:
            context = self.get_directive_context()
            error_log_path = os.path.normpath(self.PHP_ERROR_LOG_PATH % context)
            init_vars['error_log'] = error_log_path
        # Auto update max_post_size
        if 'upload_max_filesize' in init_vars:
            upload_max_filesize = init_vars['upload_max_filesize']
            post_max_size = init_vars.get('post_max_size', '0')
            upload_max_filesize_value = eval(upload_max_filesize.replace('M', '*1024'))
            post_max_size_value = eval(post_max_size.replace('M', '*1024'))
            init_vars['post_max_size'] = post_max_size
            if upload_max_filesize_value > post_max_size_value:
github glic3rinu / django-orchestra / orchestra / contrib / webapps / options.py View on Github external
class Processes(AppOption):
    name = 'processes'
    # FCGID MaxProcesses
    # FPM pm.max_children
    verbose_name = _("Number of processes")
    help_text = _("Maximum number of children that can be alive at the same time (a number between 0 and 9).")
    regex = r'^[0-9]{1,2}$'
    group = AppOption.PROCESS


class PHPEnableFunctions(PHPAppOption):
    name = 'enable_functions'
    verbose_name = _("Enable functions")
    help_text = '<tt>%s</tt>' % ',<br>'.join([
            ','.join(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS[i:i+10])
                for i in range(0, len(settings.WEBAPPS_PHP_DISABLED_FUNCTIONS), 10)
        ])
    regex = r'^[\w\.,-]+$'
    comma_separated = True
    
    def validate(self):
        # Clean value removing spaces
        self.instance.value = self.instance.value.replace(' ', '')
        super().validate()


class PHPDisableFunctions(PHPAppOption):
    name = 'disable_functions'
    verbose_name = _("Disable functions")
    help_text = _("This directive allows you to disable certain functions for security reasons. "
                  "It takes on a comma-delimited list of function names. disable_functions is not "
github glic3rinu / django-orchestra / orchestra / contrib / webapps / models.py View on Github external
def get_base_path(self):
        context = {
            'home': self.get_user().get_home(),
            'app_name': self.name,
        }
        return settings.WEBAPPS_BASE_DIR % context
github glic3rinu / django-orchestra / orchestra / contrib / webapps / backends / moodle.py View on Github external
def get_context(self, webapp):
        context = super(MoodleController, self).get_context(webapp)
        contents = webapp.content_set.all()
        context.update({
            'db_type': 'mysqli',
            'db_name': webapp.data['db_name'],
            'db_user': webapp.data['db_user'],
            'password': webapp.data['password'],
            'db_host': settings.WEBAPPS_DEFAULT_MYSQL_DATABASE_HOST,
            'email': webapp.account.email,
            'site_name': "%s Courses" % webapp.account.get_full_name(),
            'cms_cache_dir': os.path.normpath(settings.WEBAPPS_CMS_CACHE_DIR),
            'www_root': contents[0].website.get_absolute_url() if contents else 'http://empty'
        })
        return replace(context, '"', "'")
github glic3rinu / django-orchestra / orchestra / contrib / webapps / types / php.py View on Github external
help_text=help_message)


class PHPApp(AppType):
    name = 'php'
    verbose_name = "PHP"
    help_text = _("This creates a PHP application under ~/webapps/&lt;app_name&gt;<br>")
    form = PHPAppForm
    serializer = PHPAppSerializer
    icon = 'orchestra/icons/apps/PHP.png'
    
    DEFAULT_PHP_VERSION = settings.WEBAPPS_DEFAULT_PHP_VERSION
    PHP_DISABLED_FUNCTIONS = settings.WEBAPPS_PHP_DISABLED_FUNCTIONS
    PHP_ERROR_LOG_PATH = settings.WEBAPPS_PHP_ERROR_LOG_PATH
    FPM_LISTEN = settings.WEBAPPS_FPM_LISTEN
    FCGID_WRAPPER_PATH = settings.WEBAPPS_FCGID_WRAPPER_PATH
    
    @property
    def is_fpm(self):
        return self.get_php_version().endswith('-fpm')
    
    @property
    def is_fcgid(self):
        return self.get_php_version().endswith('-cgi')
    
    def get_detail(self):
        return self.instance.data.get('php_version', '')
    
    @classmethod
    def get_detail_lookups(cls):
        return {
            'php_version': settings.WEBAPPS_PHP_VERSIONS,
github glic3rinu / django-orchestra / orchestra / contrib / webapps / backends / wordpress.py View on Github external
def get_context(self, webapp):
        context = super(WordPressController, self).get_context(webapp)
        context.update({
            'db_name': webapp.data['db_name'],
            'db_user': webapp.data['db_user'],
            'password': webapp.data['password'],
            'db_host': settings.WEBAPPS_DEFAULT_MYSQL_DATABASE_HOST,
            'email': webapp.account.email,
            'title': "%s blog's" % webapp.account.get_full_name(),
            'cms_cache_dir': os.path.normpath(settings.WEBAPPS_CMS_CACHE_DIR)
        })
        return replace(context, '"', "'")
github glic3rinu / django-orchestra / orchestra / contrib / webapps / backends / php.py View on Github external
def get_context(self, webapp):
        context = super().get_context(webapp)
        context.update({
            'max_requests': settings.WEBAPPS_PHP_MAX_REQUESTS,
        })
        self.update_fpm_context(webapp, context)
        self.update_fcgid_context(webapp, context)
        return context
github glic3rinu / django-orchestra / orchestra / contrib / webapps / backends / python.py View on Github external
def get_context(self, webapp):
        context = super(PHPController, self).get_context(webapp)
        options = webapp.get_options()
        context.update({
            'python_version': webapp.type_instance.get_python_version(),
            'python_version_number': webapp.type_instance.get_python_version_number(),
            'max_requests': settings.WEBAPPS_PYTHON_MAX_REQUESTS,
            'workers': options.get('processes', settings.WEBAPPS_PYTHON_DEFAULT_MAX_WORKERS),
            'timeout': options.get('timeout', settings.WEBAPPS_PYTHON_DEFAULT_TIMEOUT),
        })
        self.update_uwsgi_context(webapp, context)
        replace(context, "'", '"')
        return context
github glic3rinu / django-orchestra / orchestra / contrib / webapps / backends / php.py View on Github external
def update_fcgid_context(self, webapp, context):
        wrapper_path = settings.WEBAPPS_FCGID_WRAPPER_PATH % context
        context.update({
            'wrapper': self.get_fcgid_wrapper(webapp, context),
            'wrapper_path': wrapper_path,
            'wrapper_dir': os.path.dirname(wrapper_path),
        })
        context.update({
            'cmd_options': self.get_fcgid_cmd_options(webapp, context),
            'cmd_options_path': settings.WEBAPPS_FCGID_CMD_OPTIONS_PATH % context,
        })
        return context