ntfsvol.py
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from dialog import Dialog
import logger
from runcmd import runProcess
from vars.modulevar import Modulevar
def getInstance(modname):
return NTFSVol(modname)
class NTFSVol(Modulevar):
def __init__(self,modname):
self.name = "ntfsvol"
self.parentModule = modname
self.description = "NTFS Volume"
self.value = None
def getNTFSVolumes(self):
result = runProcess("scripts/list_ntfs.sh")
resultlst =result[0].decode("utf-8").splitlines()
volumes = []
for res in resultlst:
output,code = runProcess(["ntfslabel","/dev/" + res])
volumes.append((res,output.decode("utf-8").rstrip()))
return volumes
def query(self):
d = Dialog(dialog="dialog", autowidgetsize=True)
d.set_background_title("[" + self.parentModule + "] Setting variable: ntfsvol")
volumes = self.getNTFSVolumes()
if(len(volumes) == 0):
raise Exception("[" + self.name + "] No NTFS Volumes found")
logger.msgLog("Detected NTFS volumes in " + repr(volumes), "ntfsvol", logger.TYPE_INFO)
volumeList = []
for vol in volumes:
volumeList.append((vol[0],vol[1], False))
code, vols = d.checklist("Select NTFS volumes",
choices=volumeList,
title="Module selection")
if code == d.OK:
self.value = vols
else:
raise Exception("[" + self.name + "] Operation Cancelled")