|
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
from modulevar import Modulevar
from dialog import Dialog
from runcmd import runProcess
import winver
from mount import mount,umount
def getInstance(modname):
return WinVol(modname)
class WinVol(Modulevar):
def __init__(self,modname):
self.name = "winvol"
self.parentModule = modname
self.description = "Windows 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")))
return volumes
def getFATVolumes(self):
result = runProcess("scripts/list_fat.sh")
resultlst =result[0].decode("utf-8").splitlines()
volumes = []
for res in resultlst:
output,code = runProcess(["dosfslabel","/dev/" + res])
volumes.append((res,output.decode("utf-8")))
return volumes
def getWindowsVolumes(self):
volumes = self.getNTFSVolumes() + self.getFATVolumes()
winvols = []
for volume in volumes:
mntpoint = "/mnt/"
mntid = mount("/dev/" + volume[0])
mntpoint += mntid
if(winver.getWindowsDirectory(mntpoint) != None):
winvols.append(volume)
umount(mntid)
return winvols
def query(self):
d = Dialog(dialog="dialog", autowidgetsize=True)
d.set_background_title("[" + self.parentModule + "] Setting variable: winvol")
volumes = self.getWindowsVolumes()
if(len(volumes) == 0):
raise Exception("[" + self.name + "] No Windows Volumes found")
volumeList = []
for vol in volumes:
volumeList.append((vol[0],vol[1], False))
code, vols = d.checklist("Select Windows volumes",
choices=volumeList,
title="Module selection")
if code == d.OK:
self.value = vols
else:
raise Exception("[" + self.name + "] Operation Cancelled")
|