Example #1
0
    def save(self, profile, allow_overwrite=False, make_default=False):
        if "id" in profile and profile['id'] != '':
            identifier = profile["id"]
        elif "name" in profile:
            identifier = profile["name"]
        else:
            raise InvalidProfileError("profile must contain either id or name")

        identifier = self._sanitize(identifier)
        profile["id"] = identifier
        profile = dict_clean(profile, self.__class__.default)

        if identifier == "_default":
            default_profile = dict_merge(self._load_default(), profile)
            if not self._ensure_valid_profile(default_profile):
                raise InvalidProfileError()

            self.settings.set(self.SETTINGS_PATH_PROFILE_DEFAULT_PROFILE,
                              default_profile,
                              defaults=dict(lasercutterprofiles=dict(
                                  defaultProfile=self.__class__.default)))
            self.settings.save()
        else:
            self._save_to_path(self._get_profile_path(identifier),
                               profile,
                               allow_overwrite=allow_overwrite)

            if make_default:
                self.set_default(identifier)

        # Not sure if we want to sync to OP's PrinterprofileManager
        # _mrbeam_plugin_implementation._printer_profile_manager.save(profile, allow_overwrite, make_default)

        return self.get(identifier)
Example #2
0
    def save(self, profile, allow_overwrite=False, make_default=False):
        if "id" in profile:
            identifier = profile["id"]
        elif "name" in profile:
            identifier = profile["name"]
        else:
            raise InvalidProfileError("profile must contain either id or name")

        identifier = self._sanitize(identifier)
        profile["id"] = identifier
        profile = dict_clean(profile, self.__class__.default)

        if identifier == "_default":
            default_profile = dict_merge(self._load_default(), profile)
            if not self._ensure_valid_profile(default_profile):
                raise InvalidProfileError()

            settings().set(["printerProfiles", "defaultProfile"],
                           default_profile,
                           defaults=dict(printerProfiles=dict(
                               defaultProfile=self.__class__.default)))
            settings().save()
        else:
            self._save_to_path(self._get_profile_path(identifier),
                               profile,
                               allow_overwrite=allow_overwrite)

            if make_default:
                settings().set(["printerProfiles", "default"], identifier)

        if self._current is not None and self._current["id"] == identifier:
            self.select(identifier)
        return self.get(identifier)
Example #3
0
	def save(self, profile, allow_overwrite=False, make_default=False):
		if "id" in profile:
			identifier = profile["id"]
		elif "name" in profile:
			identifier = profile["name"]
		else:
			raise InvalidProfileError("profile must contain either id or name")

		identifier = self._sanitize(identifier)
		profile["id"] = identifier
		profile = dict_clean(profile, self.__class__.default)

		if identifier == "_default":
			default_profile = dict_merge(self._load_default(), profile)
			if not self._ensure_valid_profile(default_profile):
				raise InvalidProfileError()

			settings().set(["printerProfiles", "defaultProfile"], default_profile, defaults=dict(printerProfiles=dict(defaultProfile=self.__class__.default)))
			settings().save()
		else:
			self._save_to_path(self._get_profile_path(identifier), profile, allow_overwrite=allow_overwrite)

			if make_default:
				settings().set(["printerProfiles", "default"], identifier)

		return self.get(identifier)
Example #4
0
    def save(self, profile, allow_overwrite=False, make_default=False):
        if "id" in profile:
            identifier = profile["id"]
        elif "name" in profile:
            identifier = profile["name"]
        else:
            raise ValueError("profile must contain either id or name")

        identifier = self._sanitize(identifier)
        profile["id"] = identifier
        profile = dict_clean(profile, self.__class__.default)
        print("lkj save identifier:%s" % str(identifier))
        #lkj
        '''from octoprint.server import printer
		if printer.isOperational():
			cmds = self.__send_all_update_epprom(profile)
			printer.commands(cmds)
			cmd_eeprom = GcodeCommand("M500")
			printer.command(cmd_eeprom)			
			pass
		print("lkj save 2")
		'''
        self.sendPreferenctParameter(profile)
        self.saveToEEPROM()
        self.getBeforeAndAfterPrintParameter(profile)

        if identifier == "_default":
            default_profile = dict_merge(self._load_default(), profile)
            settings().set(["printerProfiles", "defaultProfile"],
                           default_profile,
                           defaults=dict(printerProfiles=dict(
                               defaultProfile=self.__class__.default)))
            settings().save()
        else:
            self._save_to_path(self._get_profile_path(identifier),
                               profile,
                               allow_overwrite=allow_overwrite)

            if make_default:
                settings().set(["printerProfiles", "default"], identifier)

        if self._current is not None and self._current["id"] == identifier:
            self.select(identifier)
        return self.get(identifier)
Example #5
0
	def save(self, profile, allow_overwrite=False, make_default=False):		
		if "id" in profile:
			identifier = profile["id"]
		elif "name" in profile:
			identifier = profile["name"]
		else:
			raise ValueError("profile must contain either id or name")

		identifier = self._sanitize(identifier)
		profile["id"] = identifier
		profile = dict_clean(profile, self.__class__.default)
		print("lkj save identifier:%s" % str(identifier))
		#lkj 
		'''from octoprint.server import printer
		if printer.isOperational():
			cmds = self.__send_all_update_epprom(profile)
			printer.commands(cmds)
			cmd_eeprom = GcodeCommand("M500")
			printer.command(cmd_eeprom)			
			pass
		print("lkj save 2")
		'''
		self.sendPreferenctParameter(profile)
		self.saveToEEPROM()
		self.getBeforeAndAfterPrintParameter(profile)
		
		if identifier == "_default":
			default_profile = dict_merge(self._load_default(), profile)
			settings().set(["printerProfiles", "defaultProfile"], default_profile, defaults=dict(printerProfiles=dict(defaultProfile=self.__class__.default)))
			settings().save()
		else:
			self._save_to_path(self._get_profile_path(identifier), profile, allow_overwrite=allow_overwrite)

			if make_default:
				settings().set(["printerProfiles", "default"], identifier)
		
		if self._current is not None and self._current["id"] == identifier:
			self.select(identifier)
		return self.get(identifier)