def restore_configs(json):
    for config in json:
        Config(key=config["key"],
               value=config["value"],
               config_type=config["type"])
    arr = Config.select()[:]
    print("===RESTORED {0} {1}===".format(len(arr), "Configs"))
Beispiel #2
0
def write_state(name):
    # if not auth.username() != name:
    #   print(auth.username(), name)
    #   return '', 401
    st = Config(data=request.get_data(), cluster=get_cluster(name))
    if st.save():
        return jsonify(json.loads(st.data))
Beispiel #3
0
 def __init__(self):
     '''
     Constructor
     '''
     self.config_ = Config.Config()
     self.chasmDB_ = self.config_.getWDefault("chasmDB", "SNVBox")
     self.conn = self._connect(self.chasmDB_)
Beispiel #4
0
    def save_settings(self):
        try:
            chromepath = self.lineEdit_chromepath.text()
            timeout = self.spinBox_timeout.value()
            timeout_confirm = self.spinBox_timeout_confirm.value()
            sheduled = self.checkBox_sheduled.isChecked()
            stop_datetime = self.dateTime_stop.dateTime().toPyDateTime()
            start_datetime = self.dateTime_start.dateTime().toPyDateTime()
            refresh_count = self.spinBox_refresh_count.value()

            config = Config.select().get()
            config.chrome_path = chromepath
            config.timeout = timeout
            config.timeout_confirm = timeout_confirm
            config.sheduled = sheduled
            config.start_data_time = start_datetime
            config.stop_data_time = stop_datetime
            config.refresh_count = refresh_count
            config.save()

        except peewee.DoesNotExist:
            config = Config(chrome_path=chromepath,
                            timeout=timeout,
                            sheduled=sheduled,
                            start_data_time=start_datetime,
                            stop_data_time=stop_datetime,
                            timeout_confirm=timeout_confirm,
                            refresh_count=refresh_count)
            config.save()
Beispiel #5
0
    def __init__(self):
        # Это здесь нужно для доступа к переменным, методам
        # и т.д. в файле design.py
        super().__init__()
        if not os.path.exists(REPORTS_DIRECTORY_NAME):
            os.makedirs(REPORTS_DIRECTORY_NAME)
        self.setupUi(self)
        self.setWindowTitle('Instagram auto follow confirm v.1.5')
        self.pushButton_start.clicked.connect(self.btn_start)
        self.pushButton_stop.clicked.connect(self.btn_stop)
        self.pushButton_config.clicked.connect(self.btn_settings)
        self.pushButton_pause.clicked.connect(self.btn_pause)
        finish = QAction("Quit", self)
        finish.triggered.connect(self.closeEvent)

        # таймер для вывода времени работы
        self.timer = QTimer()
        self.timer.timeout.connect(self.handleTimer)
        self.timer.setInterval(1000)

        # таймер для старта планировщика
        self.timer_start = QTimer()
        self.timer_start.timeout.connect(self.handleTimerstart)
        self.is_startet_sheduler = False

        self.lg = logging.getLogger('insta')
        self.threadpool = QThreadPool()
        self.stop_thread = False
        self.pause_thread = False
        self.is_sheduled = False  # программа запустилась по расписанию

        try:
            config = Config.select().get()
            if config.start_data_time:
                # если врямя запуска уже прошло  - устанавливаем насильно ручной режим
                if datetime.datetime.now() > config.start_data_time:
                    config.sheduled = False
                    config.save()
                # настраиваем внешний вид в зависимости от  config.sheduled
                if config.sheduled:
                    # запуск по планировщику
                    self.set_shedule_mode(config)
                else:
                    # запуск в ручном режиме
                    self.set_manual_mode(config)

        except peewee.DoesNotExist:
            self.log.append('Внимание! необходимо настроить путь к браузеру')
            config = Config(chrome_path='',
                            timeout=10,
                            timeout_confirm=3,
                            refresh_count=5,
                            auto_start=False)
            config.save()

        self.update_ui()
def setup_general_config():
    '''
    Is used to populate the database if it has been reset.
    :return:
    '''

    long_string = ConfigType.get(type="long_string")
    long_string = ConfigType(
        type="long_string") if long_string is None else long_string

    string = ConfigType.get(type="string")
    string = ConfigType(type="string") if string is None else string

    number = ConfigType.get(type="number")
    number = ConfigType(type="number") if number is None else number

    config_list = [{
        "key":
        "frontend_url",
        "value":
        "localhost:3001",
        "config_type":
        string,
        "description":
        "The url to this frontend page (used for links in the emails)"
    }, {
        "key":
        "archive_base_url",
        "value":
        "localhost:3001/api/archive/download",
        "config_type":
        string,
        "description":
        "The base url to download archives from (used in emails to the board)"
    }, {
        "key":
        "document_template_url",
        "value":
        "https://www.overleaf.com/read/ddjdhxnkxttj",
        "config_type":
        string,
        "description":
        "The template overleaf document for the different reports (used in the emails)"
    }, {
        "key": "gotify_url",
        "value": "http://*****:*****@chalmers.it",
        "config_type": string,
        "description": "The email to the secretary"
    }, {
        "key": "board_email",
        "value": "*****@*****.**",
        "config_type": string,
        "description": "The email to the board"
    }, {
        "key": "group_email_domain",
        "value": "@chalmers.it",
        "config_type": string,
        "description": "The domain to send emails to"
    }, {
        "key": "from_email_address",
        "value": "*****@*****.**",
        "config_type": string,
        "description": "The email to send from"
    }, {
        "key":
        "mail_to_groups_subject",
        "value":
        "Dokument till sektionsmöte den {day}/{month}",
        "config_type":
        string,
        "description":
        """
The subject for "regular" email sendout (that goes out to all active groups that have documents to turn in for the meeting). \n
Description of the formatting values:  \n
 - {group_name} = The display name of the group \n
 - {meeting_day} = The day of month for the meeting \n
 - {meeting_month} = The month (number) of the meeting \n
 - {deadline_time} = The deadline time (hh:mm) \n
 - {deadline_date} = The deadline date (dd/mm) \n
 - {task_list} = A list of the tasks that the group should upload \n
 - {frontend_url} = The url to the website \n
 - {group_code} = Their unique code \n
 - {template_url} = The document (overleaf) template url \n
 - {secretary_email} = The email to the secretary \n
 - {board_display_name} = The display name of the board \n
 - {board_email} = The email to the board
 """
    }, {
        "key":
        "mail_to_groups_message",
        "value":
        "\nHej {group_name}!\n\nDen {meeting_day}/{meeting_month} är det dags för sektionsmöte och senast {deadline_time} den {deadline_date} behöver ni lämna in "
        "följande dokument: {task_list}\nDetta görs på sidan: {frontend_url}\nAnge koden: {group_code}\n\nMall för vissa "
        "dokument finns här: {template_url}\nGör en kopia av projektet (Menu -> Copy Project) och fyll i.\n\nOm ni har "
        "några frågor eller stöter på några problem kan kan ni kontakta mig på {secretary_email} eller hela {board_display_name} på {board_email} "
        ": ).",
        "config_type":
        long_string,
        "description":
        """
The body of the "regular" emails (the ones that are sent to all the active groups that should turn in documents for the meeting).  \n
Description of the formatting values:  \n
 - {group_name} = The display name of the group \n
 - {meeting_day} = The day of month for the meeting \n
 - {meeting_month} = The month (number) of the meeting \n
 - {deadline_time} = The deadline time (hh:mm) \n
 - {deadline_date} = The deadline date (dd/mm) \n
 - {task_list} = A list of the tasks that the group should upload \n
 - {frontend_url} = The url to the website \n
 - {group_code} = Their unique code \n
 - {template_url} = The document (overleaf) template url \n
 - {secretary_email} = The email to the secretary \n
 - {board_display_name} = The display name of the board \n
 - {board_email} = The email to the board
             """
    }, {
        "key":
        "mail_to_board_subject",
        "value":
        "Dokument för sektionsmöte {meeting_number} lp {meeting_lp}",
        "config_type":
        string,
        "description":
        """
The subject of the email that is sent to the board upon reaching the deadline.  \n
Description of the formatting values:  \n
 - {board_name} = The display name of the board \n
 - {meeting_number} = The number of the meeting (usually 0) \n
 - {meeting_lp} = The study period of the meeting \n
 - {meeting_archive_url} = A link to the archive download \n
 - {secretary_email} = The email to the secretary
             """
    }, {
        "key":
        "mail_to_board_message",
        "value":
        "\nHej {board_name}!\n\nDeadlinen för dokumentinsamling till sektionsmöte {meeting_number} i lp {meeting_lp} är nu nådd.\nFör "
        "nedladdning av dessa dokument klicka på denna länk: {meeting_archive_url}\n\nVid frågor, kontakta sekreteraren på {secretary_email}",
        "config_type":
        long_string,
        "description":
        """
The contents of the email that is sent out to the board upon reaching the deadline. \n
Description of the formatting values:  \n
 - {board_name} = The display name of the board \n
 - {meeting_number} = The number of the meeting (usually 0) \n
 - {meeting_lp} = The study period of the meeting \n
 - {meeting_archive_url} = A link to the archive download \n
 - {secretary_email} = The email to the secretary
             """
    }, {
        "key":
        "mail_for_stories_subject",
        "value":
        "Dokument för sektionsmöte {meeting_number} lp {meeting_lp}",
        "config_type":
        string,
        "description":
        """ 
The subject of the email that is sent to the "story groups" (i.e. the groups that needs to turn in eberattelser / vberattelser. \n
Description of the formatting values:  \n
 - {group_name_year} = Display name of the group. \n
 - {meeting_day} = The day of month that the meeting will take place \n
 - {meeting_month} = The month (number) of the meeting \n
 - {deadline_time} = The deadline time \n
 - {deadline_date} = The deadline date \n
 - {task_list} = A list of the tasks that the group will have to turn in. \n
 - {frontend_url} = A url to the frontend (upload page) \n
 - {group_code} = Their unique code \n
 - {template_url} = A link the overleaf template for the documents. \n
 - {secretary_email} = The email to the secretary \n
 - {board_display_name} = The display name of the board \n
 - {board_email} = The email to the board \n
 - {meeting_number} = The number of the meeting that study period (usually 0) \n
 - {meeting_lp} = The study period
             """
    }, {
        "key":
        "mail_for_stories",
        "value":
        "\nHej {group_name_year}!\n\nDen {meeting_day}/{meeting_month} är det dags för sektionsmöte och senast {deadline_time} den {deadline_date} behöver ni lämna in "
        "följande dokument: {task_list}\nDetta görs på sidan: {frontend_url}\nAnge koden: {group_code}\n\nMall för vissa "
        "dokument finns här: {template_url}\nGör en kopia av projektet (Menu -> Copy Project) och fyll i.\n "
        "Kontakta revisorerna på [email protected] för mer information om vad som behövs göras innan ni "
        "kan bli rekomenderade att bli ansvarsbefriade.\n\nOm ni har "
        "några frågor eller stöter på några problem kan kan ni kontakta mig på {secretary_email} eller hela {board_display_name} på {board_email} "
        ": ).",
        "config_type":
        long_string,
        "description":
        """
The body of the email that is sent to the "story groups" (i.e. the groups that needs to turn in eberattelser / vberattelser) \n
Description of the formatting values:  \n
 - {group_name_year} = Display name of the group. \n
 - {meeting_day} = The day of month that the meeting will take place \n
 - {meeting_month} = The month (number) of the meeting \n
 - {deadline_time} = The deadline time \n
 - {deadline_date} = The deadline date \n
 - {task_list} = A list of the tasks that the group will have to turn in. \n
 - {frontend_url} = A url to the frontend (upload page) \n
 - {group_code} = Their unique code \n
 - {template_url} = A link the overleaf template for the documents. \n
 - {secretary_email} = The email to the secretary \n
 - {board_display_name} = The display name of the board \n
 - {board_email} = The email to the board \n
 - {meeting_number} = The number of the meeting that study period (usually 0) \n
 - {meeting_lp} = The study period
             """
    }, {
        "key": "board_display_name",
        "value": "styrIT",
        "config_type": string,
        "description": "The display name of the board"
    }, {
        "key":
        "minutes_after_deadline_to_mail",
        "value":
        "5",
        "config_type":
        number,
        "description":
        "The amount of minutes to wait extra after the deadline before sending the email to the board"
    }, {
        "key":
        "check_for_deadline_frequency",
        "value":
        "5",
        "config_type":
        number,
        "description":
        "The frequence (in minutes) to check if any deadlines have been reached"
    }, {
        "key":
        "possible_years_back_for_stories",
        "value":
        "5",
        "config_type":
        number,
        "description":
        "The number of years back that one should be able to select story groups for (usually 5 due to tax reasons)"
    }]

    for config in config_list:
        conf = Config.get(key=config["key"])
        if conf is None:
            Config(key=config["key"],
                   value=config["value"],
                   config_type=config["config_type"],
                   description=config["description"])
        else:
            # Since the only way to change the description is here,
            # we always want the db version to be up to date with this list on application restart.
            conf.description = config["description"]

    # Setup groups and tasks
    groups = [{
        "codeName": "armit",
        "displayName": "ArmIT"
    }, {
        "codeName": "digit",
        "displayName": "digIT"
    }, {
        "codeName": "fanbarerit",
        "displayName": "FanbärerIT"
    }, {
        "codeName": "fritid",
        "displayName": "frITid"
    }, {
        "codeName": "mrcit",
        "displayName": "MRCIT"
    }, {
        "codeName": "nollkit",
        "displayName": "NollKIT"
    }, {
        "codeName": "prit",
        "displayName": "P.R.I.T."
    }, {
        "codeName": "sexit",
        "displayName": "sexIT"
    }, {
        "codeName": "snit",
        "displayName": "snIT"
    }, {
        "codeName": "styrit",
        "displayName": "styrIT"
    }, {
        "codeName": "equalit",
        "displayName": "EqualIT"
    }, {
        "codeName": "flashit",
        "displayName": "FlashIT"
    }]

    tasks = [{
        "codeName": "vplan",
        "displayName": "Verksamhetsplan / Operational plan"
    }, {
        "codeName": "budget",
        "displayName": "Budget"
    }, {
        "codeName": "vrapport",
        "displayName": "Verksamhetsrapport / Operational report"
    }, {
        "codeName": "vberattelse",
        "displayName": "Verksamhetsberättelse / Operational story"
    }, {
        "codeName": "eberattelse",
        "displayName": "Ekonomisk Berättelse / Economic story"
    }]

    for group in groups:
        if Group.get(name=group["codeName"]) is None:
            new_group = Group(name=group["codeName"],
                              display_name=group["displayName"])

            if GroupYear.get(group=new_group, year="active") is None:
                GroupYear(group=new_group, year="active", finished=False)

    for task in tasks:
        if Task.get(name=task["codeName"]) is None:
            Task(name=task["codeName"], display_name=task["displayName"])

    commit()
    print("Finished loading database data from general config file.")