Пример #1
0
 def __init__(self, data):
     self.settings = Settings(
         target=data['settings']['target'],
         scaner_port=data['settings']['scaner_port'],
         scaner_boundrate=data['settings']['scaner_boundrate'],
         have_cassa=data['settings']['have_cassa'])
     self.data = data['data']
     self.app = None
Пример #2
0
 def set_object_data(self, data):
     self.log.add_log(type_message='INFO', message='start add data')
     self.settings = Settings(
         target=data.settings.target,
         scaner_port=data.settings.scaner_port,
         scaner_boundrate=data.settings.scaner_boundrate,
         have_cassa=data.settings.have_cassa)
     self.data = data.data
     self.app = None
     self.log.add_log(type_message='INFO', message='finish enter data')
Пример #3
0
    def generate_ssh_command(self):
        # Get the settings
        # Check if uses key
        if self.use_key is True:
            command = "/usr/bin/ssh {}@{} -i {}"
            command = command.format(self.user, self.host, self.key_path)
        else:
            command = "/usr/bin/sshpass -p{} /usr/bin/ssh {}@{}"
            command = command.format(self.password, self.user, self.host)

        # Format other parameters
        command += " -p {}"
        command = command.format(self.port)

        # Strict key checking
        command += " -o StrictHostKeyChecking=no"

        # Get the settings and apply here
        settings = Settings()
        settings.load()

        # X11 forwarding
        if settings.x11_forward == 1:
            command += " -X"

        if settings.request_compression == 1:
            command += " -C"

        if settings.force_ipv4 == 1:
            command += " -4"

        if settings.force_ipv6 == 1:
            command += " -6"

        # Get the tunnels
        self.load_tunnels()
        for tunnel in self.tunnels.get_tunnels():
            command += " -L {}:{}:{}"
            command = command.format(tunnel.local_port, tunnel.address,
                                     tunnel.remote_port)

        # At the end, return the command
        return command
Пример #4
0
    def generate_ssh_command(self):
        # Get the settings
        # Check if uses key
        if self.use_key is True:
            command = "/usr/bin/ssh {}@{} -i {}"
            command = command.format(self.user, self.host, self.key_path)
        else:
            command = "/usr/bin/sshpass -p{} /usr/bin/ssh {}@{}"
            command = command.format(self.password, self.user, self.host)

        # Format other parameters
        command += " -p {}"
        command = command.format(self.port)

        # Strict key checking
        command += " -o StrictHostKeyChecking=no"

        # Get the settings and apply here
        settings = Settings()
        settings.load()

        # X11 forwarding
        if settings.x11_forward == 1:
            command += " -X"

        if settings.request_compression == 1:
            command += " -C"

        if settings.force_ipv4 == 1:
            command += " -4"

        if settings.force_ipv6 == 1:
            command += " -6"

        # Get the tunnels
        self.load_tunnels()
        for tunnel in self.tunnels.get_tunnels():
            command += " -L {}:{}:{}"
            command = command.format(tunnel.local_port, tunnel.address, tunnel.remote_port)

        # At the end, return the command
        return command
Пример #5
0
    def set_properties(self):
        # Load the settings
        settings = Settings()
        settings.load()

        # Get the checkboxes
        x11_forward = self.builder.get_object("chk_enable_x11")
        request_compression = self.builder.get_object("chk_request_compress")
        force_ipv4 = self.builder.get_object("radio_force_ipv4")
        force_ipv6 = self.builder.get_object("radio_force_ipv6")

        # Set the config
        x11_forward.set_active(bool(settings.x11_forward))
        request_compression.set_active(bool(settings.request_compression))
        force_ipv4.set_active(bool(settings.force_ipv4))
        force_ipv6.set_active(bool(settings.force_ipv6))
Пример #6
0
 def convert_to_test_model(self, file):
     data = self.convert_documents_to_test_model(file=file)
     if data != -1:
         try:
             self.data = Data(settings=Settings(
                 target=file['settings']['target'],
                 scaner_port=file['settings']['scaner_port'],
                 scaner_boundrate=file['settings']['scaner_boundrate'],
                 have_cassa=file['settings']['have_cassa']),
                              data=data)
             return 0
         except:
             self.err.append('There is exception')
             return -1
     else:
         return -1
Пример #7
0
    def on_btn_save_clicked(self, btn):
        # Get the properties
        x11_forward = self.builder.get_object("chk_enable_x11")
        request_compression = self.builder.get_object("chk_request_compress")
        force_ipv4 = self.builder.get_object("radio_force_ipv4")
        force_ipv6 = self.builder.get_object("radio_force_ipv6")

        # Set the config on Settings
        app_settings = Settings()
        app_settings.x11_forward = int(x11_forward.get_active())
        app_settings.request_compression = int(
            request_compression.get_active())
        app_settings.force_ipv4 = int(force_ipv4.get_active())
        app_settings.force_ipv6 = int(force_ipv6.get_active())

        # Now, save
        if app_settings.save():
            self.window.destroy()
        else:
            # Show message box about error
            MessageBox("Error while saving the settings, please try again.")
Пример #8
0
    def on_btn_save_clicked(self, btn):
        # Get the properties
        x11_forward = self.builder.get_object("chk_enable_x11")
        request_compression = self.builder.get_object("chk_request_compress")
        force_ipv4 = self.builder.get_object("radio_force_ipv4")
        force_ipv6 = self.builder.get_object("radio_force_ipv6")

        # Set the config on Settings
        app_settings = Settings()
        app_settings.x11_forward = int(x11_forward.get_active())
        app_settings.request_compression = int(request_compression.get_active())
        app_settings.force_ipv4 = int(force_ipv4.get_active())
        app_settings.force_ipv6 = int(force_ipv6.get_active())

        # Now, save
        if app_settings.save():
            self.window.destroy()
        else:
            # Show message box about error
            MessageBox("Error while saving the settings, please try again.")
Пример #9
0
def settings():
    if request.method == "GET":
        return render_template("admin/settings.html", title=_("Administration") + ": " + _("Einstellungen"), thispage="admin", S=S)
    elif request.method == "POST":
        S.set(request.json["key"], request.json["value"])
        return "true"
Пример #10
0
def courses_propose():
    cuser = muser.getCurrentUser()
    if not cuser.isLoggedIn() or cuser.isDisabled(): abort(403)
    if S.get("limit-course-creation") == "yes" and not cuser.isTeam():
        abort(403)
    if request.method == "GET":
        if S.get("limit-course-creation") == "yes":
            return render_template('courses/propose.html',
                                   title="Kurs erstellen",
                                   thispage="courses",
                                   topic=mcourses.Topic)
        return render_template('courses/propose.html',
                               title="Kurs vorschlagen",
                               thispage="courses",
                               topic=mcourses.Topic)
    elif request.method == "POST":
        if cuser.may("course_propose"):
            data = request.json
            topic = data["topic"]
            title = data["title"].strip()
            shortdesc = data["shortdesc"].strip()
            longdesc = data["longdesc"].strip()
            requirements = data["requirements"].strip()

            topic = mcourses.Topic(topic)
            if not topic.isGiveable():
                return jsonify({
                    "result":
                    "error",
                    "error":
                    "Das Thema " + topic.getTitle() +
                    " kann nicht vergeben werden."
                })

            errors = _validateCourse(title, shortdesc, longdesc, requirements)

            if len(errors) != 0:
                return jsonify({"result": "errors", "errors": errors})

            p = mproposal.Proposal.createNew(topic.id, title, shortdesc,
                                             longdesc, requirements, cuser)

            if S.get("limit-course-creation") == "yes":
                p.createCourse()
                p = mproposal.Proposal(p.id)
                p.setDetail("deleted", 1)
                return jsonify({
                    "result":
                    "success",
                    "url":
                    url_for("course_info", id=p.getDetail("courseid"))
                })

            if p:
                return jsonify({
                    "result": "success",
                    "url": url_for("proposal.single", id=p.id)
                })
            return jsonify({
                "result": "error",
                "error": "Ein Fehler ist aufgetreten."
            })
        else:
            abort(405)
Пример #11
0
 def global_settings(self):
     return self.__get_data('global_settings', Settings(), 'data')
Пример #12
0
 def read_file(self, file_src):
     """
     Loads the content from a file and scans for certain words. If one of these words is found the string after the
     word will be stored into a grammar or settings object.
     :param file_src: String contains the path to a file
     :return: list which contains the grammar and settings object
     """
     with open(file_src, "r") as fobj:
         grammar = Grammar()
         settings = Settings()
         for line in fobj:
             rhs = None  #right-hand-side of a rule
             lhs = None  #left-hand-side of a rule
             state = "lhs"
             words = line.rstrip().split()
             for word in words:
                 if (words.index(word) == 0 and word == "axiom:"):
                     words.remove(word)
                     grammar.axiom = ' '.join(words)
                 elif (words.index(word) > 0 and words[0] == "angle_z:"):
                     settings.angle_z_min = int(words[1])
                     settings.angle_z_max = int(words[3])
                 elif (words.index(word) > 0 and words[0] == "angle_y:"):
                     settings.angle_y_min = int(words[1])
                     settings.angle_y_max = int(words[3])
                 elif (words.index(word) > 0 and words[0] == "angle_x:"):
                     settings.angle_x_min = int(words[1])
                     settings.angle_x_max = int(words[3])
                 elif (words.index(word) > 0
                       and words[0] == "branch-shortening:"):
                     settings.branch_min = float(words[1])
                     settings.branch_max = float(words[3])
                 #elif (words.index(word) > 0 and words[0] == "num_sides:"):
                 #grammar.num_sides = int(words[1])
                 elif (words.index(word) > 0
                       and words[0] == "base_radius:"):
                     settings.base_radius = float(words[1])
                 elif (words.index(word) > 0 and words[0] == "rules:"):
                     if (state == "lhs"):
                         lhs = word
                         if (lhs not in grammar.variables):
                             grammar.variables.add(lhs)
                         state = "rhs"
                         continue
                     if (state == "rhs" and word != "->"):
                         rhs = word
                         if ("," in rhs):
                             rhs = rhs.replace(",", "")
                         grammar.rules.add(Rule(lhs, rhs))
                         state = "lhs"
                 elif (words.index(word) > 0
                       and words[0] == "generations:"):
                     settings.generations = int(words[1])
                 elif (words.index(word) > 0
                       and words[0] == "base_length:"):
                     settings.base_length = float(words[1])
                 elif (words.index(word) > 0
                       and words[0] == "bark_texture:"):
                     settings.bark_path = words[1]
                 elif (words.index(word) > 0
                       and words[0] == "leaf_texture:"):
                     settings.leaf_path = words[1]
         return [grammar, settings]
Пример #13
0
# -*- coding: utf-8 -*-
from model.data import Data
from model.settings import Settings
from model.positions_in_check import *
import jsonpickle
import os.path


settings = Settings(target='C:\\Users\\авы\\Desktop\\frontol\\releaseCandidat\\Frontol.exe',
                    scaner_port='COM258',
                    scaner_boundrate=9600,
                    have_cassa=True)

positions = [PositionsInCheck(place_in_list=1, cout=1, need_mark=False, mark=None),
             PositionsInCheck(place_in_list=1, cout=1, need_mark=False, mark=None)]

documents = [Checks(check_number=1,
                    document_type='registration',
                    report_type=1,
                    check_type=None,
                    help_setting=None,
                    sale=False,
                    type_close=1,
                    positions=positions),
             Checks(check_number=1,
                    document_type='report',
                    report_type=7,
                    check_type=None,
                    help_setting=None,
                    sale=False,
                    type_close=1,