def _refresh_repository(self, repo_data=None): if repo_data is None: repo_data = self._fetch_repository_from_url() if repo_data is None: return False current_os = get_os() octoprint_version = get_octoprint_version(base=True) def map_repository_entry(entry): result = copy.deepcopy(entry) if not "follow_dependency_links" in result: result["follow_dependency_links"] = False result["is_compatible"] = dict( octoprint=True, os=True ) if "compatibility" in entry: if "octoprint" in entry["compatibility"] and entry["compatibility"]["octoprint"] is not None and isinstance(entry["compatibility"]["octoprint"], (list, tuple)) and len(entry["compatibility"]["octoprint"]): result["is_compatible"]["octoprint"] = is_octoprint_compatible(*entry["compatibility"]["octoprint"], octoprint_version=octoprint_version) if "os" in entry["compatibility"] and entry["compatibility"]["os"] is not None and isinstance(entry["compatibility"]["os"], (list, tuple)) and len(entry["compatibility"]["os"]): result["is_compatible"]["os"] = self._is_os_compatible(current_os, entry["compatibility"]["os"]) return result self._repository_plugins = map(map_repository_entry, repo_data) return True
def view(): return jsonify( plugins=self._get_plugins(), repository=dict(available=self._repository_available, plugins=self._repository_plugins), os=get_os(), octoprint=get_octoprint_version_string(), pip=dict(available=self._pip_caller.available, version=self._pip_caller.version_string, install_dir=self._pip_caller.install_dir, use_user=self._pip_caller.use_user, virtual_env=self._pip_caller.virtual_env, additional_args=self._settings.get(["pip_args"]), python=sys.executable), safe_mode=safe_mode, online=self._connectivity_checker.online)
def view(): return jsonify(plugins=self._get_plugins(), repository=dict( available=self._repository_available, plugins=self._repository_plugins ), os=get_os(), octoprint=get_octoprint_version_string(), pip=dict( available=self._pip_caller.available, version=self._pip_caller.version_string, install_dir=self._pip_caller.install_dir, use_user=self._pip_caller.use_user, virtual_env=self._pip_caller.virtual_env, additional_args=self._settings.get(["pip_args"]), python=sys.executable ), safe_mode=safe_mode, online=self._connectivity_checker.online)
def _refresh_repository(self, repo_data=None): if repo_data is None: repo_data = self._fetch_repository_from_url() if repo_data is None: return False current_os = get_os() octoprint_version = get_octoprint_version(base=True) def map_repository_entry(entry): result = copy.deepcopy(entry) if not "follow_dependency_links" in result: result["follow_dependency_links"] = False result["is_compatible"] = dict(octoprint=True, os=True) if "compatibility" in entry: if "octoprint" in entry["compatibility"] and entry[ "compatibility"][ "octoprint"] is not None and isinstance( entry["compatibility"]["octoprint"], (list, tuple)) and len( entry["compatibility"]["octoprint"]): result["is_compatible"][ "octoprint"] = is_octoprint_compatible( *entry["compatibility"]["octoprint"], octoprint_version=octoprint_version) if "os" in entry["compatibility"] and entry["compatibility"][ "os"] is not None and isinstance( entry["compatibility"]["os"], (list, tuple)) and len( entry["compatibility"]["os"]): result["is_compatible"]["os"] = self._is_os_compatible( current_os, entry["compatibility"]["os"]) return result self._repository_plugins = map(map_repository_entry, repo_data) return True
def serial_factory_hook(self, comm_instance, port, baudrate, read_timeout, *args, **kwargs): self.create_serial_obj() self.sync_settings_with_serial_obj() self._serial_obj.timeout = read_timeout self._serial_obj.write_timeout = 0 if baudrate == 0: self._serial_obj.baudrate = 115200 else: self._serial_obj.baudrate = baudrate self._serial_obj.port = str(port) # Parity workaround needed for linux use_parity_workaround = settings().get( ["serial", "useParityWorkaround"]) needs_parity_workaround = get_os() == "linux" and os.path.exists( "/etc/debian_version") # See #673 if use_parity_workaround == "always" or ( needs_parity_workaround and use_parity_workaround == "detect"): self._serial_obj.parity = serial.PARITY_ODD self._serial_obj.open() self._serial_obj.close() self._serial_obj.parity = serial.PARITY_NONE self._serial_obj.open() # Set close_exec flag on serial handle, see #3212 if hasattr(self._serial_obj, "fd"): # posix set_close_exec(self._serial_obj.fd) elif hasattr(self._serial_obj, "_port_handle"): # win32 # noinspection PyProtectedMember set_close_exec(self._serial_obj._port_handle) self._serial_obj.query_packing_state() return self._serial_obj
def test_get_os(self, sys_platform, expected): with mock.patch("sys.platform", sys_platform): from octoprint.util.platform import get_os actual = get_os() self.assertEqual(actual, expected)
def __plugin_check__(): from octoprint.util.platform import get_os return get_os() == "linux" and os.path.exists(_OCTOPI_VERSION_PATH)
def _detect_os(self): return dict(id=get_os(), platform=sys.platform)
def _detect_os(self): return { "id": get_os(), "platform": sys.platform, "bits": 64 if sys.maxsize > 2**32 else 32, }