def on_after_startup(self):
        # Use a different log file for DiscordRemote, as it is very noisy.
        self._logger = logging.getLogger("octoprint.plugins.discordremote")
        from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
        hdlr = CleaningTimedRotatingFileHandler(
            self._settings.get_plugin_logfile_path(), when="D", backupCount=3)

        formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
        hdlr.setFormatter(formatter)
        self._logger.addHandler(hdlr)

        # Initialise DiscordRemote
        self._logger.info("DiscordRemote is started !")
        self.configure_discord(False)

        self.configure_presence()

        # Transition settings
        allowed_users = self._settings.get(['allowedusers'], merged=True)
        if allowed_users:
            self._settings.set(["allowedusers"], None, True)
            self._settings.set(['permissions'], {'1': {'users': allowed_users, 'commands': ''}}, True)

            self.send_message(None, "⚠️⚠️⚠️ Allowed users has been changed to a more granular system. "
                                    "Check the DiscordRemote settings and check that it is suitable⚠️⚠️⚠️")
Exemple #2
0
	def on_startup(self, host, port):
		# setup our custom logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		cura_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="engine"), when="D", backupCount=3)
		cura_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		cura_logging_handler.setLevel(logging.DEBUG)

		self._cura_logger.addHandler(cura_logging_handler)
		self._cura_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.CRITICAL)
		self._cura_logger.propagate = False
	def on_startup(self, host, port):
		# setup customized logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		tasmota_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="debug"), when="D", backupCount=3)
		tasmota_logging_handler.setFormatter(logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s"))
		tasmota_logging_handler.setLevel(logging.DEBUG)

		self._tasmota_logger.addHandler(tasmota_logging_handler)
		self._tasmota_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.INFO)
		self._tasmota_logger.propagate = False
Exemple #4
0
	def on_startup(self, host, port):
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		console_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="console"), when="D", backupCount=3)
		console_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		console_logging_handler.setLevel(logging.DEBUG)

		self._console_logger.addHandler(console_logging_handler)
		self._console_logger.setLevel(logging.DEBUG)
		self._console_logger.propagate = False

		self._repository_available = self._fetch_repository_from_disk()
Exemple #5
0
	def on_after_startup(self):
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		console_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="console"), when="D", backupCount=3)
		console_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		console_logging_handler.setLevel(logging.DEBUG)

		self._console_logger.addHandler(console_logging_handler)
		self._console_logger.setLevel(logging.DEBUG)
		self._console_logger.propagate = False

		# decouple repository fetching from server startup
		self._fetch_all_data(async=True)
Exemple #6
0
	def on_startup(self, host, port):
		# setup our custom logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		cura_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="engine"), when="D", backupCount=3)
		cura_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		cura_logging_handler.setLevel(logging.DEBUG)

		self._cura_logger.addHandler(cura_logging_handler)
		self._cura_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.CRITICAL)
		self._cura_logger.propagate = False

		engine = self._settings.get(["cura_engine"])
		if not self._is_engine_configured(cura_engine=engine):
			self._logger.info(u"Path to CuraEngine has not been configured or does not exist (currently set to %r), "
			                  u"Cura will not be selectable for slicing" % engine)
    def initialize(self):
        # setup our custom logger
        logPostfix = "events"
        self._event_file_logger = logging.getLogger("octoprint.plugins." +
                                                    self._settings.plugin_key +
                                                    "." + logPostfix)

        from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
        event_logging_handler = CleaningTimedRotatingFileHandler(
            self._settings.get_plugin_logfile_path(postfix=logPostfix),
            when="D",
            backupCount=3)
        event_logging_handler.setFormatter(
            logging.Formatter("%(asctime)s %(message)s"))
        event_logging_handler.setLevel(logging.DEBUG)

        self._event_file_logger.addHandler(event_logging_handler)
        self._event_file_logger.setLevel(logging.DEBUG)
        self._event_file_logger.propagate = False

        self._layerDurationDeque = deque(maxlen=self._settings.get_int(
            [SETTINGS_KEY_LAYER_AVARAGE_DURATION_COUNT]))

        # prepare expression-settings
        self._evaluatePrinterMessagePattern()
        self._parseLayerExpressions(
            self._settings.get([SETTINGS_KEY_LAYER_EXPRESSIONS]))
Exemple #8
0
  def on_startup(self, host, port):
    # setup our custom logger
    from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
    logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="engine"), when="D", backupCount=3)
    logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
    logging_handler.setLevel(logging.DEBUG)

    self._logger.addHandler(logging_handler)
    self._logger.propagate = False
    # TODO: Remove the below after https://github.com/foosel/OctoPrint/pull/2723 is merged.
    self._file_manager.original_add_file = self._file_manager.add_file
    def new_add_file(destination, path, file_object, links=None, allow_overwrite=False, printer_profile=None, analysis=None, display=None):
      return self._file_manager.original_add_file(destination, path, file_object, links, allow_overwrite, printer_profile, None, display)
    self._file_manager.add_file = new_add_file
    # Work around for broken rc2
    if pkg_resources.parse_version(octoprint._version.get_versions()['version']) == pkg_resources.parse_version("1.3.9rc2"):
      self._printer.old_on_comm = self._printer.on_comm_file_selected
      def new_on_comm(self, *args, **kwargs):
        self.old_on_comm(*args, **kwargs)
        self._create_estimator()
      self._printer.on_comm_file_selected = types.MethodType(new_on_comm, self._printer)

    def fixCompletion(self):
      currentProgress = dict(**self._updateProgressDataCallback())

      if currentProgress.get("printTime") is not None and currentProgress.get("printTimeLeft") is not None:
          currentProgress["completion"] = currentProgress["printTime"] * 100.00 / (currentProgress["printTime"] + currentProgress["printTimeLeft"])

      return self._dict(**currentProgress)

    self._printer._stateMonitor._on_get_progress = types.MethodType(fixCompletion, self._printer)

    for line in self._settings.get(["printer_config"]):
      self._current_config += line
Exemple #9
0
    def virtual_printer_factory(self, comm_instance, port, baudrate,
                                read_timeout):
        if not port == "VIRTUAL1":
            return None

        if not self._settings.get_boolean(["enabled"]):
            return None

        import logging.handlers

        from octoprint.logging.handlers import CleaningTimedRotatingFileHandler

        seriallog_handler = CleaningTimedRotatingFileHandler(
            self._settings.get_plugin_logfile_path(postfix="serial"),
            when="D",
            backupCount=3,
        )
        seriallog_handler.setFormatter(
            logging.Formatter("%(asctime)s %(message)s"))
        seriallog_handler.setLevel(logging.DEBUG)

        from . import virtual

        serial_obj = virtual.TR_VirtualPrinter(
            self._settings,
            data_folder=self.get_plugin_data_folder(),
            seriallog_handler=seriallog_handler,
            read_timeout=float(read_timeout),
            faked_baudrate=baudrate,
        )
        return serial_obj
	def on_startup(self, host, port):
		# setup customized logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		tasmota_mqtt_logging_hnadler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="debug"), when="D", backupCount=3)
		tasmota_mqtt_logging_hnadler.setFormatter(logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s"))
		tasmota_mqtt_logging_hnadler.setLevel(logging.DEBUG)

		self._tasmota_mqtt_logger.addHandler(tasmota_mqtt_logging_hnadler)
		self._tasmota_mqtt_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.INFO)
		self._tasmota_mqtt_logger.propagate = False
		self.abortTimeout = self._settings.get_int(["abortTimeout"])
		self._tasmota_mqtt_logger.debug("abortTimeout: %s" % self.abortTimeout)

		self.powerOffWhenIdle = self._settings.get_boolean(["powerOffWhenIdle"])
		self._tasmota_mqtt_logger.debug("powerOffWhenIdle: %s" % self.powerOffWhenIdle)

		self.idleTimeout = self._settings.get_int(["idleTimeout"])
		self._tasmota_mqtt_logger.debug("idleTimeout: %s" % self.idleTimeout)
		self.idleIgnoreCommands = self._settings.get(["idleIgnoreCommands"])
		self._idleIgnoreCommandsArray = self.idleIgnoreCommands.split(',')
		self._tasmota_mqtt_logger.debug("idleIgnoreCommands: %s" % self.idleIgnoreCommands)
		self.idleTimeoutWaitTemp = self._settings.get_int(["idleTimeoutWaitTemp"])
		self._tasmota_mqtt_logger.debug("idleTimeoutWaitTemp: %s" % self.idleTimeoutWaitTemp)

		self._start_idle_timer()
Exemple #11
0
	def on_startup(self, host, port):
		# setup customized logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		tplinksmartplug_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="debug"), when="D", backupCount=3)
		tplinksmartplug_logging_handler.setFormatter(logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s"))
		tplinksmartplug_logging_handler.setLevel(logging.DEBUG)

		self._tplinksmartplug_logger.addHandler(tplinksmartplug_logging_handler)
		self._tplinksmartplug_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.INFO)
		self._tplinksmartplug_logger.propagate = False

		self.db_path = os.path.join(self.get_plugin_data_folder(),"energy_data.db")
		if not os.path.exists(self.db_path):
			db = sqlite3.connect(self.db_path)
			cursor = db.cursor()
			cursor.execute('''CREATE TABLE energy_data(id INTEGER PRIMARY KEY, ip TEXT, timestamp TEXT, current REAL, power REAL, total REAL, voltage REAL)''')
			db.commit()
			db.close()

		self.abortTimeout = self._settings.get_int(["abortTimeout"])
		self._tplinksmartplug_logger.debug("abortTimeout: %s" % self.abortTimeout)

		self.powerOffWhenIdle = self._settings.get_boolean(["powerOffWhenIdle"])
		self._tplinksmartplug_logger.debug("powerOffWhenIdle: %s" % self.powerOffWhenIdle)

		self.idleTimeout = self._settings.get_int(["idleTimeout"])
		self._tplinksmartplug_logger.debug("idleTimeout: %s" % self.idleTimeout)
		self.idleIgnoreCommands = self._settings.get(["idleIgnoreCommands"])
		self._idleIgnoreCommandsArray = self.idleIgnoreCommands.split(',')
		self._tplinksmartplug_logger.debug("idleIgnoreCommands: %s" % self.idleIgnoreCommands)
		self.idleTimeoutWaitTemp = self._settings.get_int(["idleTimeoutWaitTemp"])
		self._tplinksmartplug_logger.debug("idleTimeoutWaitTemp: %s" % self.idleTimeoutWaitTemp)

		self._start_idle_timer()
  def on_startup(self, host, port):
     # setup our custom logger
    from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
    logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="engine"), when="D", backupCount=3)
    logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
    logging_handler.setLevel(logging.DEBUG)

    self._logger.addHandler(logging_handler)
    self._logger.propagate = False
Exemple #13
0
	def on_startup(self, host, port):
		# setup customized logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		tplinksmartplug_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="debug"), when="D", backupCount=3)
		tplinksmartplug_logging_handler.setFormatter(logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s"))
		tplinksmartplug_logging_handler.setLevel(logging.DEBUG)

		self._tplinksmartplug_logger.addHandler(tplinksmartplug_logging_handler)
		self._tplinksmartplug_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.INFO)
		self._tplinksmartplug_logger.propagate = False
Exemple #14
0
	def on_startup(self, host, port):
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		console_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="console"), when="D", backupCount=3)
		console_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		console_logging_handler.setLevel(logging.DEBUG)

		self._console_logger.addHandler(console_logging_handler)
		self._console_logger.setLevel(logging.DEBUG)
		self._console_logger.propagate = False

		self._repository_available = self._fetch_repository_from_disk()
Exemple #15
0
	def on_after_startup(self):
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		console_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="console"), when="D", backupCount=3)
		console_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		console_logging_handler.setLevel(logging.DEBUG)

		self._console_logger.addHandler(console_logging_handler)
		self._console_logger.setLevel(logging.DEBUG)
		self._console_logger.propagate = False

		# decouple repository fetching from server startup
		self._fetch_all_data(do_async=True)
    def setup_custom_logger(self, path, debug):
        # Cleaning handler will remove old logs, defined by 'backupCount'
        # 'D' specifies to roll over each day
        effect_runner_handler = CleaningTimedRotatingFileHandler(path,
                                                                 when="D",
                                                                 backupCount=2)
        effect_runner_handler.setFormatter(
            logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s"))
        effect_runner_handler.setLevel(logging.DEBUG)

        self._logger.addHandler(effect_runner_handler)
        self._logger.setLevel(logging.DEBUG if debug else logging.INFO)
        self._logger.propagate = False
Exemple #17
0
    def on_startup(self, host, port):
        # setup our custom logger
        from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
        logging_handler = CleaningTimedRotatingFileHandler(
            self._settings.get_plugin_logfile_path(postfix="engine"),
            when="D",
            backupCount=3)
        logging_handler.setFormatter(
            logging.Formatter("%(asctime)s %(message)s"))
        logging_handler.setLevel(logging.DEBUG)

        self._logger.addHandler(logging_handler)
        self._logger.propagate = False

        self._logger.info("Starting PrintTimeGenius")
        # Unmark all pending analyses.
        all_files = self._file_manager.list_files()
        for dest in all_files.keys():
            self.unmark_all_pending(dest, all_files[dest])

        # TODO: Remove the below after https://github.com/foosel/OctoPrint/pull/2723 is merged.
        self._file_manager.original_add_file = self._file_manager.add_file

        def new_add_file(destination,
                         path,
                         file_object,
                         links=None,
                         allow_overwrite=False,
                         printer_profile=None,
                         analysis=None,
                         display=None):
            return self._file_manager.original_add_file(
                destination, path, file_object, links, allow_overwrite,
                printer_profile, None, display)

        self._file_manager.add_file = new_add_file
        # Work around for broken rc2
        if pkg_resources.parse_version(
                octoprint._version.get_versions()
            ['version']) == pkg_resources.parse_version("1.3.9rc2"):
            self._printer.old_on_comm = self._printer.on_comm_file_selected

            def new_on_comm(self, *args, **kwargs):
                self.old_on_comm(*args, **kwargs)
                self._create_estimator()

            self._printer.on_comm_file_selected = types.MethodType(
                new_on_comm, self._printer)
        for line in self._settings.get(["printer_config"]):
            self._current_config += line
Exemple #18
0
    def on_startup(self, host, port):
        # setup customized logger
        from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
        tasmota_logging_handler = CleaningTimedRotatingFileHandler(
            self._settings.get_plugin_logfile_path(postfix="debug"),
            when="D",
            backupCount=3)
        tasmota_logging_handler.setFormatter(
            logging.Formatter("[%(asctime)s] %(levelname)s: %(message)s"))
        tasmota_logging_handler.setLevel(logging.DEBUG)

        self._tasmota_logger.addHandler(tasmota_logging_handler)
        self._tasmota_logger.setLevel(
            logging.DEBUG if self._settings.get_boolean(["debug_logging"]
                                                        ) else logging.INFO)
        self._tasmota_logger.propagate = False

        self.energy_db_path = os.path.join(self.get_plugin_data_folder(),
                                           "energy_data.db")
        if not os.path.exists(self.energy_db_path):
            db = sqlite3.connect(self.energy_db_path)
            cursor = db.cursor()
            cursor.execute(
                '''CREATE TABLE energy_data(id INTEGER PRIMARY KEY, ip TEXT, idx TEXT, timestamp TEXT, current REAL, power REAL, total REAL, voltage REAL)'''
            )
            db.commit()
            db.close()

        self.sensor_db_path = os.path.join(self.get_plugin_data_folder(),
                                           "sensor_data.db")
        if not os.path.exists(self.sensor_db_path):
            db = sqlite3.connect(self.sensor_db_path)
            cursor = db.cursor()
            cursor.execute(
                '''CREATE TABLE sensor_data(id INTEGER PRIMARY KEY, ip TEXT, idx TEXT, timestamp TEXT, temperature REAL, humidity REAL)'''
            )
            db.commit()
            db.close()

        self.abortTimeout = self._settings.get_int(["abortTimeout"])
        self._tasmota_logger.debug("abortTimeout: %s" % self.abortTimeout)

        self.automatic_power_off = self._settings.get_boolean(
            ["automatic_power_off"])
        self._tasmota_logger.debug("automatic_power_off: %s" %
                                   self.automatic_power_off)

        if self.automatic_power_off:
            self._automatic_shutdown_enabled = True
	def on_startup(self, host, port):
		# setup our custom logger
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		cura_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="engine"), when="D", backupCount=3)
		cura_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		cura_logging_handler.setLevel(logging.DEBUG)

		self._cura_logger.addHandler(cura_logging_handler)
		self._cura_logger.setLevel(logging.DEBUG if self._settings.get_boolean(["debug_logging"]) else logging.CRITICAL)
		self._cura_logger.propagate = False

		engine = self._settings.get(["cura_engine"])
		if not self._is_engine_configured(cura_engine=engine):
			self._logger.info(u"Path to CuraEngine has not been configured or does not exist (currently set to %r), "
			                  u"Cura will not be selectable for slicing" % engine)
Exemple #20
0
	def on_after_startup(self):
		from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
		console_logging_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="console"), when="D", backupCount=3)
		console_logging_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
		console_logging_handler.setLevel(logging.DEBUG)

		self._console_logger.addHandler(console_logging_handler)
		self._console_logger.setLevel(logging.DEBUG)
		self._console_logger.propagate = False

		# decouple repository fetching from server startup
		def fetch_data():
			self._repository_available = self._fetch_repository_from_disk()
			self._notices_available = self._fetch_notices_from_disk()

		thread = threading.Thread(target=fetch_data)
		thread.daemon = True
		thread.start()
Exemple #21
0
 def serial_factory(self, comm_instance, port, baudrate,
 	                            read_timeout):
                               
         if not port == settings().getBaseFolder("base")+"/xyz":
 			return None
                         
         import logging.handlers 
         from octoprint.logging.handlers import CleaningTimedRotatingFileHandler
 
         seriallog_handler = CleaningTimedRotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="serial"),
 		                                                     when="D",
 		                                                     backupCount=3)
         seriallog_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
         seriallog_handler.setLevel(logging.DEBUG)
         from . import virtual_xyz
 
         serial_obj = virtual_xyz.VirtualPrinter(seriallog_handler=None,
 		                                    read_timeout=float(read_timeout))
         return serial_obj