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()
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 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))