@@ -24,15 +24,16 @@ def __init__(self):
2424 def action (self , * args , verbose = False ):
2525 if verbose == 2 :
2626 capture = False
27- elif self . verbose :
27+ elif verbose :
2828 capture = not self .verbose
2929 else :
3030 capture = True
3131 logging .debug (f"run: diskutil { args !r} " )
3232 if capture :
33- subprocess .run (["diskutil" ] + list (args ), check = True ,
34- stdout = subprocess .PIPE ,
35- stderr = subprocess .STDOUT )
33+ p = subprocess .run (["diskutil" ] + list (args ), check = True ,
34+ stdout = subprocess .PIPE ,
35+ stderr = subprocess .STDOUT )
36+ logging .debug (f"process output: { p .stdout } " )
3637 else :
3738 subprocess .run (["diskutil" ] + list (args ), check = True )
3839
@@ -46,16 +47,24 @@ def get_list(self):
4647 logging .info (f"DiskUtil.get_list()" )
4748 self .list = self .get ("list" , "-plist" )
4849 self .disk_list = self .list ["WholeDisks" ]
50+ logging .debug (" Whole disks:" )
51+ for i in self .disk_list :
52+ logging .debug (f" - { i !r} " )
4953 self .disk_parts = {dsk ["DeviceIdentifier" ]: dsk for dsk in self .list ["AllDisksAndPartitions" ]}
54+ logging .debug (" All disks and partitions:" )
55+ for k , v in self .disk_parts .items ():
56+ logging .debug (f" - { k } : { v !r} " )
5057
5158 def get_apfs_list (self , dev = None ):
52- logging .info (f"DiskUtil.get_apfs_list()" )
59+ logging .info (f"DiskUtil.get_apfs_list({ dev = !r } )" )
5360 if dev :
5461 apfs = self .get ("apfs" , "list" , dev , "-plist" )
5562 else :
5663 apfs = self .get ("apfs" , "list" , "-plist" )
5764 for ctnr in apfs ["Containers" ]:
5865 vgs = self .get ("apfs" , "listVolumeGroups" , ctnr ["ContainerReference" ], "-plist" )
66+ logging .debug (f"container: { ctnr !r} " )
67+ logging .debug (f" VGs: { vgs !r} " )
5968 ctnr ["VolumeGroups" ] = vgs ["Containers" ][0 ]["VolumeGroups" ]
6069 self .ctnr_by_ref [ctnr ["ContainerReference" ]] = ctnr
6170 self .ctnr_by_store [ctnr ["DesignatedPhysicalStore" ]] = ctnr
@@ -65,6 +74,7 @@ def get_disk_info(self):
6574 self .disks = {}
6675 for i in self .disk_list :
6776 self .disks [i ] = self .get ("info" , "-plist" , i )
77+ logging .debug (f" { i } : { self .disks [i ]} " )
6878
6979 def get_info (self ):
7080 logging .info (f"DiskUtil.get_info()" )
@@ -117,7 +127,8 @@ def get_partition_info(self, dev, refresh_apfs=False):
117127 part .container = {}
118128 part .container ["Volumes" ] = []
119129 logging .info (f"{ part .name } doesn't have any Volumes" )
120-
130+
131+ logging .debug ("Partition {dev}: {part}" )
121132 return part
122133
123134 def get_partitions (self , dskname ):
@@ -151,19 +162,19 @@ def refresh_part(self, part):
151162 part .container = self .ctnr_by_store [part .name ]
152163
153164 def mount (self , target ):
154- self .action ("quiet" , " mount" , target )
165+ self .action ("mount" , target )
155166 info = self .get ("info" , "-plist" , target )
156167 return info ["MountPoint" ]
157168
158169 def addVolume (self , container , name , ** kwargs ):
159170 args = []
160171 for k , v in kwargs .items ():
161172 args .extend (["-" + k , v ])
162- self .action ("quiet" , " apfs" , "addVolume" , container , "apfs" , name , * args , verbose = True )
173+ self .action ("apfs" , "addVolume" , container , "apfs" , name , * args , verbose = True )
163174
164175 def addPartition (self , after , fs , label , size ):
165176 size = str (size )
166- self .action ("quiet" , " addPartition" , after , fs , label , size , verbose = True )
177+ self .action ("addPartition" , after , fs , label , size , verbose = True )
167178
168179 disk = after .rsplit ("s" , 1 )[0 ]
169180
@@ -181,10 +192,10 @@ def addPartition(self, after, fs, label, size):
181192 raise Exception ("Could not find new partition" )
182193
183194 def changeVolumeRole (self , volume , role ):
184- self .action ("quiet" , " apfs" , "changeVolumeRole" , volume , role , verbose = True )
195+ self .action ("apfs" , "changeVolumeRole" , volume , role , verbose = True )
185196
186197 def rename (self , volume , name ):
187- self .action ("quiet" , " rename" , volume , name , verbose = True )
198+ self .action ("rename" , volume , name , verbose = True )
188199
189200 def resizeContainer (self , name , size ):
190201 size = str (size )
0 commit comments