Example #1
0
def manipulate_output(action, output_id):
    """
    Add, delete, and modify output settings while the daemon is active

    :param output_id: output ID in the SQL database
    :type output_id: str
    :param action: "add", "del", or "mod"
    :type action: str
    """
    try:
        control = DaemonControl()
        return_values = control.output_setup(action, output_id)
        if return_values and len(return_values) > 1:
            if return_values[0]:
                flash(gettext("%(err)s",
                              err='{action} Output: Daemon response: {msg}'.format(
                                  action=action,
                                  msg=return_values[1])),
                      "error")
            else:
                flash(gettext("%(err)s",
                              err='{action} Output: Daemon response: {msg}'.format(
                                  action=gettext(action),
                                  msg=return_values[1])),
                      "success")
    except Exception as msg:
        flash(gettext("%(err)s",
                      err='{action} Output: Could not connect to Daemon: {error}'.format(
                          action=action, error=msg)),
              "error")
Example #2
0
def manipulate_output(action, output_id):
    """
    Add, delete, and modify output settings while the daemon is active

    :param output_id: output ID in the SQL database
    :type output_id: str
    :param action: "add", "del", or "mod"
    :type action: str
    """
    try:
        control = DaemonControl()
        return_values = control.output_setup(action, output_id)
        if return_values and len(return_values) > 1:
            if return_values[0]:
                flash(
                    gettext(
                        "%(err)s",
                        err='{action} Output: Daemon response: {msg}'.format(
                            action=action, msg=return_values[1])), "error")
            else:
                flash(
                    gettext(
                        "%(err)s",
                        err='{action} Output: Daemon response: {msg}'.format(
                            action=gettext(action), msg=return_values[1])),
                    "success")
    except Exception as msg:
        flash(
            gettext(
                "%(err)s",
                err='{action} Output: Could not connect to Daemon: {error}'.
                format(action=action, error=msg)), "error")
Example #3
0
def manipulate_output(action, output_id):
    """
    Add, delete, and modify output settings while the daemon is active

    :param output_id: output ID in the SQL database
    :type output_id: str
    :param action: "Add", "Delete", or "Modify"
    :type action: str
    """
    messages = {"success": [], "info": [], "warning": [], "error": []}

    try:
        control = DaemonControl()
        return_values = control.output_setup(action, output_id)
        if return_values and len(return_values) > 1:
            if return_values[0]:
                messages["error"].append(
                    gettext(
                        "%(err)s",
                        err='{action} Output: Daemon response: {msg}'.format(
                            action=action, msg=return_values[1])))
            else:
                messages["success"].append(
                    gettext(
                        "%(err)s",
                        err='{action} Output: Daemon response: {msg}'.format(
                            action=gettext(action), msg=return_values[1])))
    except Exception as msg:
        messages["error"].append(
            gettext(
                "%(err)s",
                err='{action} Output: Could not connect to Daemon: {error}'.
                format(action=action, error=msg)))

    return messages