diff options
Diffstat (limited to 'abs/core/LinHES-system/add_storage.py')
-rw-r--r-- | abs/core/LinHES-system/add_storage.py | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/abs/core/LinHES-system/add_storage.py b/abs/core/LinHES-system/add_storage.py index 92a6120..28d679c 100644 --- a/abs/core/LinHES-system/add_storage.py +++ b/abs/core/LinHES-system/add_storage.py @@ -77,12 +77,9 @@ class disk_device: def get_in_use(self): in_use = False for i in self.fs_map: - if i.startswith("["): - split_line=i.split() - device_path = split_line[5] - if self.block_path in device_path: - in_use = True - break + if self.block_path in i[0]: + in_use = True + break return in_use @@ -132,21 +129,32 @@ class disk_device: return def get_fsmap(self): - cmd = "/sbin/fsck -N" - fs_map = runcmd(cmd)[1] - fs_map = fs_map.split("\n") + #block,point,fs + fs_map=[] + + f = open('/proc/mounts','r') + mounts=f.readlines() + f.close() + for line in mounts: + temp_fs=[] + split_line=line.split() + block=split_line[0] + mountp=split_line[1] + fs=split_line[2] + block=os.path.realpath(block) + if block.startswith("/dev"): + temp_fs.append(block) + temp_fs.append(mountp) + temp_fs.append(fs) + fs_map.append(temp_fs) return fs_map def find_fstype(self,moutpoint): fstype="ext3" mp=['/myth', '/data/media'] for i in self.fs_map: - if i.startswith("["): - split_line=i.split() - #find mount_p and remove the last char - mount_p = split_line[3][:-1] - if mount_p in mp: - fstype = split_line[4].split(".")[1] + if i[1] in mp: + fstype = i[2] break return fstype @@ -377,18 +385,22 @@ def main(scan_only): #print i.mount_path #print i.is_mounted #print i.in_use + #print i.model + #print i.block_path #print "--" if search_for_match(i,known_drive_list) or i.in_use : - #print "Drive matched" - #print i.model + print " Storage is already in use or previously skipped: %s location: %s size: %s" %(i.model,i.block_path,i.device_size) continue - else: + else: + print "\n" if not scan_only: print "\n" print "-------------------------------------------------------------" + print "Found new hard drive: %s location: %s size: %s \n" %(i.model,i.block_path,i.device_size) + if prompt_to_add(i) : print "\nDisk will be added to the storage pool!" process_list.append(i) @@ -412,7 +424,8 @@ def main(scan_only): print "\nDid not find any new storage to add.\n" #BE = MythBE(db=DB) - #save new list to disk_device + + #save new list to disk_device write_known_drive_list(system_drive_list) for i in process_list: |