mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-30 05:45:09 +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 = {}
|
||||
p = subprocess.Popen(["system_profiler", "SPUSBDataType", "-xml"], stdout = subprocess.PIPE)
|
||||
plist = plistlib.loads(p.communicate()[0])
|
||||
p.wait()
|
||||
|
||||
for entry in plist:
|
||||
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)
|
||||
result = self._recursiveSearch(plist, "removable_media")
|
||||
|
||||
p = subprocess.Popen(["system_profiler", "SPCardReaderDataType", "-xml"], stdout=subprocess.PIPE)
|
||||
plist = plistlib.loads(p.communicate()[0])
|
||||
p.wait()
|
||||
|
||||
for entry in plist:
|
||||
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)
|
||||
result.extend(self._recursiveSearch(plist, "removable_media"))
|
||||
|
||||
for drive in result:
|
||||
# Ignore everything not explicitly marked as removable
|
||||
if drive["removable_media"] != "yes":
|
||||
continue
|
||||
|
||||
# Ignore any removable device that does not have an actual 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
|
||||
|
||||
def performEjectDevice(self, device):
|
||||
p = subprocess.Popen(["diskutil", "eject", device.getId()], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
|
||||
output = p.communicate()
|
||||
Logger.log("d", "umount returned: %s.", repr(output))
|
||||
|
||||
return_code = p.wait()
|
||||
if return_code != 0:
|
||||
return False
|
||||
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.read_string(serialised) # Read the input string as config file.
|
||||
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()
|
||||
name_path_dict = {}
|
||||
@ -45,7 +51,13 @@ class VersionUpgrade22to24(VersionUpgrade):
|
||||
|
||||
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()
|
||||
config.write(output)
|
||||
|
Loading…
x
Reference in New Issue
Block a user