Exemplo n.º 1
0
 def sanitize_str(value):
     if not value:
         return
     value = strip_spaces(value=value, join=False)
     value = [c.strip().strip("\\") for c in value if (c and c != "\\")]
     value = [c for c in value if (c and c != "\\")]
     return " ".join(value)
Exemplo n.º 2
0
def get_pod_command_args(run_config):
    if not run_config or not run_config.cmd:
        raise ValueError('The specification must contain a command.')

    cmd = strip_spaces(value=run_config.cmd, join=False)
    cmd = [c.strip().strip('\\') for c in cmd if (c and c != '\\')]
    cmd = [c for c in cmd if (c and c != '\\')]
    return ["/bin/bash", "-c"], [' '.join(cmd)]
Exemplo n.º 3
0
def render_mail_template(subject_template, body_template, context):
    """
    Renders both the subject and body templates in the given context.
    Returns a tuple (subject, body) of the result.
    """
    try:
        subject = strip_spaces(render_to_string(subject_template, context))
        body = render_to_string(body_template, context)
    finally:
        pass

    return subject, body
Exemplo n.º 4
0
    def _validate_config(cls, config):
        if not config:
            return {}

        recipients = config.get('recipients')
        if not recipients:
            return {}

        if isinstance(recipients, str):
            recipients = strip_spaces(recipients, sep=',', join=False)

        config['recipients'] = [email for email in recipients if email]
        return config
Exemplo n.º 5
0
    def get_ordering(self, request, queryset, view):
        """
        Ordering is set by a comma delimited ?ordering=... query parameter.

        The `ordering` query parameter can be overridden by setting
        the `ordering_param` value on the OrderingFilter or by
        specifying an `ORDERING_PARAM` value in the API settings.
        """
        params = request.query_params.get(self.ordering_param)
        if params:
            fields = strip_spaces(value=params, sep=',', join=False)
            ordering, annotations = self.remove_invalid_fields(queryset, fields, view, request)
            if ordering:
                return ordering, annotations

        # No ordering was included, or all the ordering fields were invalid
        return self.get_default_ordering(view), None
Exemplo n.º 6
0
 def sanitize_cmd(cmd):
     cmd = strip_spaces(value=cmd, join=False)
     cmd = [c.strip().strip('\\') for c in cmd if (c and c != '\\')]
     cmd = [c for c in cmd if (c and c != '\\')]
     return ' '.join(cmd)