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