mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 06:35:58 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
99f7a2b7f4
@ -17,41 +17,60 @@ class OSXRemovableDrivePlugin(RemovableDrivePlugin.RemovableDrivePlugin):
|
|||||||
drives = {}
|
drives = {}
|
||||||
p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout = subprocess.PIPE)
|
p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout = subprocess.PIPE)
|
||||||
plist = plistlib.loads(p.communicate()[0])
|
plist = plistlib.loads(p.communicate()[0])
|
||||||
p.wait()
|
|
||||||
|
|
||||||
for entry in plist:
|
result = self._recursiveSearch(plist, "removable_media")
|
||||||
if "_items" in entry:
|
|
||||||
for item in entry["_items"]:
|
|
||||||
for dev in item["_items"]:
|
|
||||||
if "removable_media" in dev and dev["removable_media"] == "yes" and "volumes" in dev and len(dev["volumes"]) > 0:
|
|
||||||
for vol in dev["volumes"]:
|
|
||||||
if "mount_point" in vol:
|
|
||||||
volume = vol["mount_point"]
|
|
||||||
drives[volume] = os.path.basename(volume)
|
|
||||||
|
|
||||||
p = subprocess.Popen(["system_profiler", "SPCardReaderDataType", "-xml"], stdout=subprocess.PIPE)
|
p = subprocess.Popen(["system_profiler", "SPCardReaderDataType", "-xml"], stdout=subprocess.PIPE)
|
||||||
plist = plistlib.loads(p.communicate()[0])
|
plist = plistlib.loads(p.communicate()[0])
|
||||||
p.wait()
|
|
||||||
|
|
||||||
for entry in plist:
|
result.extend(self._recursiveSearch(plist, "removable_media"))
|
||||||
if "_items" in entry:
|
|
||||||
for item in entry["_items"]:
|
for drive in result:
|
||||||
for dev in item["_items"]:
|
# Ignore everything not explicitly marked as removable
|
||||||
if "removable_media" in dev and dev["removable_media"] == "yes" and "volumes" in dev and len(dev["volumes"]) > 0:
|
if drive["removable_media"] != "yes":
|
||||||
for vol in dev["volumes"]:
|
continue
|
||||||
if "mount_point" in vol:
|
|
||||||
volume = vol["mount_point"]
|
# Ignore any removable device that does not have an actual volume
|
||||||
drives[volume] = os.path.basename(volume)
|
if "volumes" not in drive or not drive["volumes"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
for volume in drive["volumes"]:
|
||||||
|
if not "mount_point" in volume:
|
||||||
|
continue
|
||||||
|
|
||||||
|
mount_point = volume["mount_point"]
|
||||||
|
|
||||||
|
if "_name" in volume:
|
||||||
|
drive_name = volume["_name"]
|
||||||
|
else:
|
||||||
|
drive_name = os.path.basename(mount_point)
|
||||||
|
|
||||||
|
drives[mount_point] = drive_name
|
||||||
|
|
||||||
return drives
|
return drives
|
||||||
|
|
||||||
def performEjectDevice(self, device):
|
def performEjectDevice(self, device):
|
||||||
p = subprocess.Popen(["diskutil", "eject", device.getId()], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
p = subprocess.Popen(["diskutil", "eject", device.getId()], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||||
output = p.communicate()
|
output = p.communicate()
|
||||||
Logger.log("d", "umount returned: %s.", repr(output))
|
|
||||||
|
|
||||||
return_code = p.wait()
|
return_code = p.wait()
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Recursively search for key in a plist parsed by plistlib
|
||||||
|
def _recursiveSearch(self, plist, key):
|
||||||
|
result = []
|
||||||
|
for entry in plist:
|
||||||
|
if key in entry:
|
||||||
|
result.append(entry)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if "_items" in entry:
|
||||||
|
result.extend(self._recursiveSearch(entry["_items"], key))
|
||||||
|
|
||||||
|
if "Media" in entry:
|
||||||
|
result.extend(self._recursiveSearch(entry["Media"], key))
|
||||||
|
|
||||||
|
return result
|
||||||
|
@ -19,8 +19,14 @@ class VersionUpgrade22to24(VersionUpgrade):
|
|||||||
config = configparser.ConfigParser(interpolation = None)
|
config = configparser.ConfigParser(interpolation = None)
|
||||||
config.read_string(serialised) # Read the input string as config file.
|
config.read_string(serialised) # Read the input string as config file.
|
||||||
config.set("general", "version", "3")
|
config.set("general", "version", "3")
|
||||||
containers = config.get("general", "containers")
|
|
||||||
container_list = containers.split(",")
|
container_list = []
|
||||||
|
if config.has_section("containers"):
|
||||||
|
for index, container_id in config.items("containers"):
|
||||||
|
container_list.append(container_id)
|
||||||
|
elif config.has_option("general", "containers"):
|
||||||
|
containers = config.get("general", "containers")
|
||||||
|
container_list = containers.split(",")
|
||||||
|
|
||||||
user_variants = self.__getUserVariants()
|
user_variants = self.__getUserVariants()
|
||||||
name_path_dict = {}
|
name_path_dict = {}
|
||||||
@ -45,7 +51,13 @@ class VersionUpgrade22to24(VersionUpgrade):
|
|||||||
|
|
||||||
container_list = new_container_list
|
container_list = new_container_list
|
||||||
|
|
||||||
config.set("general", "containers", ",".join(container_list))
|
if not config.has_section("containers"):
|
||||||
|
config.add_section("containers")
|
||||||
|
|
||||||
|
config.remove_option("general", "containers")
|
||||||
|
|
||||||
|
for index in range(len(container_list)):
|
||||||
|
config.set("containers", index, container_list[index])
|
||||||
|
|
||||||
output = io.StringIO()
|
output = io.StringIO()
|
||||||
config.write(output)
|
config.write(output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user