コード例 #1
0
ファイル: default.py プロジェクト: HuwSy/unofficial-addons
def listDisks():
    disksData = smartmontools.getDisks();
    if len(disksData) > 0:
        addFolderItem(consts.fontBold + consts.colorBlue + addon.getLocalizedString(50018) +        # Choose disk for smartctl:
                      consts.colorEnd + consts.fontBoldEnd, -97);
        for data in disksData:
            l = data.split("|"); # params indexes: 0 - name; 1 - disk id from /dev/disk/by-id; 2 - device (/dev/sda, /dev/hda etc.)

            # getting and setting params to be passed to next call
            deviceType = smartmontools.getDiskType(l[1]);
            dic = smartctl.getStatusInfo(l[2], deviceType);
            dic[consts.paramDevice] = l[2];
            dic[consts.paramDiskId] = l[1];
            dic[consts.paramDiskType] = deviceType;
            params = sutilsxbmc.createParamStringFromDictionairy(dic, False);
            
            displayName = "";
            
            # add color to device name
            try:
                if dic[consts.paramDeviceIsSuported]:
                    if dic[consts.paramOverallHealth] == "PASSED":
                        displayName = consts.colorShadeOfGreen;
                    else:
                        displayName = consts.colorShadeOfRed;
                else:
                    displayName = consts.colorOrange;
            except:
                displayName = "";
            
            displayName += l[0] + " (" + l[2] + ")" + (consts.colorEnd if displayName else "");
                    
            addFolderItem(displayName , 20, params, True);
コード例 #2
0
def listDisks():
    disksData = smartmontools.getDisks()
    if len(disksData) > 0:
        addFolderItem(
            consts.fontBold + consts.colorBlue +
            addon.getLocalizedString(50018) +  # Choose disk for smartctl:
            consts.colorEnd + consts.fontBoldEnd,
            -97)
        for data in disksData:
            l = data.split("|")
            # params indexes: 0 - name; 1 - disk id from /dev/disk/by-id; 2 - device (/dev/sda, /dev/hda etc.)

            # getting and setting params to be passed to next call
            deviceType = smartmontools.getDiskType(l[1])
            dic = smartctl.getStatusInfo(l[2], deviceType)
            dic[consts.paramDevice] = l[2]
            dic[consts.paramDiskId] = l[1]
            dic[consts.paramDiskType] = deviceType
            params = sutilsxbmc.createParamStringFromDictionairy(dic, False)

            displayName = ""

            # add color to device name
            try:
                if dic[consts.paramDeviceIsSuported]:
                    if dic[consts.paramOverallHealth] == "PASSED":
                        displayName = consts.colorShadeOfGreen
                    else:
                        displayName = consts.colorShadeOfRed
                else:
                    displayName = consts.colorOrange
            except:
                displayName = ""

            displayName += l[0] + " (" + l[2] + ")" + (consts.colorEnd
                                                       if displayName else "")

            addFolderItem(displayName, 20, params, True)
コード例 #3
0
ファイル: default.py プロジェクト: HuwSy/unofficial-addons
    startSmartd();
    sutilsxbmc.refreshCurrentListing();
elif index == 2:
    stopSmartd();
    sutilsxbmc.refreshCurrentListing();
elif index == 3:
    reloadSmartdConfig();
elif index == 4:
    runTestNowSmartd();
elif index == 5:
    showSmartdLog();
   
# indexes 20 - 29 are reserved for common smartctl tasks 
elif index == 20:
    diskId = params[consts.paramDiskId];
    listSmartctlTasks(params[consts.paramDevice], diskId, smartmontools.getDiskType(diskId) ); 
elif index == 21:
    setDeviceType(params[consts.paramDiskId]);
    
# indexes 30 - 39 are reserved for smartctl tests
elif index == 30:
    listSmartctlTests(params[consts.paramDevice], params[consts.paramDiskId], 
                      params[consts.paramDiskType]);
elif index > 30 and index <35:
    executeSmartctlTest(index, params[consts.paramDevice], params[consts.paramDiskId], 
                        params[consts.paramDiskType]);
elif index == 39:
    smartctl.cancelSelfTest(params[consts.paramDevice], params[consts.paramDiskType]);

# indexes 40 - 49 are reserved for smartctl reports + indexes higher than 50000
elif (index >= 40 and index <50) or index > 50000:
コード例 #4
0
    sutilsxbmc.refreshCurrentListing()
elif index == 2:
    stopSmartd()
    sutilsxbmc.refreshCurrentListing()
elif index == 3:
    reloadSmartdConfig()
elif index == 4:
    runTestNowSmartd()
elif index == 5:
    showSmartdLog()

# indexes 20 - 29 are reserved for common smartctl tasks
elif index == 20:
    diskId = params[consts.paramDiskId]
    listSmartctlTasks(params[consts.paramDevice], diskId,
                      smartmontools.getDiskType(diskId))
elif index == 21:
    setDeviceType(params[consts.paramDiskId])

# indexes 30 - 39 are reserved for smartctl tests
elif index == 30:
    listSmartctlTests(params[consts.paramDevice], params[consts.paramDiskId],
                      params[consts.paramDiskType])
elif index > 30 and index < 35:
    executeSmartctlTest(index, params[consts.paramDevice],
                        params[consts.paramDiskId],
                        params[consts.paramDiskType])
elif index == 39:
    smartctl.cancelSelfTest(params[consts.paramDevice],
                            params[consts.paramDiskType])