def createContainerAndItem(): item = pickItem(False) settingDic = getSettingsForContainer(True, item) if settingDic == None: aborted() return s = sutilsxbmc.getNumberFromUser(0, addon.getLocalizedString(50021)) # Enter size in GB. if s == "": aborted() return size = str(int(s) * 1024 * 1024 * 1024) password = sutilsxbmc.getConfirmedPassword() fileSystem = filesysToUse() item.setDicSettings(settingDic, True) xbmc.executebuiltin("Notification(Truecrypt, " + addon.getLocalizedString(50021) + ", 5, " + __icon__ + ")") # Creation of cantainer started. item.createNewFile(size, password) if not fileSystem == None: format(item, fileSystem, password) xbmc.executebuiltin("Notification(Truecrypt, " + addon.getLocalizedString(50054) + ", 5, " + __icon__ + ")") # Attempting to mount created file. success = mountUnmount(item, password) if success: xbmcgui.Dialog().ok(xbmc.getLocalizedString(10511), addon.getLocalizedString(50063)) sutilsxbmc.refreshCurrentListing() del password
def reset(item): confirmed = xbmcgui.Dialog().yesno(addon.getLocalizedString(50019), addon.getLocalizedString(50023), addon.getLocalizedString(50023)) # "Continue?" ,"All settings for selected item will be removed. Continue?" if confirmed: item.resetSettings() sutilsxbmc.refreshCurrentListing()
def assignExistinContainer(): item = pickItem(False); settingDic = getSettingsForContainer(item = item); if settingDic == None : return; item.setDicSettings(settingDic); # selectedItem.setContainerSettings(name =name, filePath = filePath, drive = mountPoint, icon = icon, active = True); sutilsxbmc.refreshCurrentListing();
def assignExistinContainer(): item = pickItem(False) settingDic = getSettingsForContainer(item=item) if settingDic == None: return item.setDicSettings(settingDic) # selectedItem.setContainerSettings(name =name, filePath = filePath, drive = mountPoint, icon = icon, active = True); sutilsxbmc.refreshCurrentListing()
def delete(item): confirmed = xbmcgui.Dialog().yesno(addon.getLocalizedString(50069), xbmc.getLocalizedString(750), addon.getLocalizedString(50060)+": " + item.name, xbmc.getLocalizedString(561) +": " + item.filePath); #"Delete file?", "Are you sure?", "Item: " + item.name,"File: " + item.filePath if confirmed : # @type item resources.lib.tcitem success = item.delete(); if not success: xbmcgui.Dialog().ok(addon.getLocalizedString(50058), addon.getLocalizedString(50059), item.getErrorMessage()); # "Failed", "Failed to delete specified file." else: xbmcgui.Dialog().ok(addon.getLocalizedString(50038), addon.getLocalizedString(50057)); # "Info", "File deleted sucessfully.") item.resetSettings(); sutilsxbmc.refreshCurrentListing();
def changePassword(filePath, oldPass="", newPass="", keyFiles="", item=None): ''' The method executes changing of password in the volume through shell script. :param filePath: path to the volume :param oldPass: password to be changed :param newPass: new password :param keyFiles: key file path :param item: item on which task is executed (only for lock reasons) ''' if item != None: item.lock(__settings__.getLocalizedString(50122)) sutilsxbmc.refreshCurrentListing() cmd = "\"" + shellScript + "\" " cmd += "\"" + consts.commandChagePassword + "\" " cmd += "\"" + filePath + "\" " escapedOldPass = sutils.escapeCharsForShell(oldPass) escapedNewPass = sutils.escapeCharsForShell(newPass) # this is command for the debug log only tempcmd = consts.logExecutingScript + cmd + ( "\"" + escapedOldPass + "\" " + "\"" + escapedNewPass + "\"" if debugLogPassword else "\"*****\" \"*****\"") + ( " \"" + keyFiles + "\"" if debugLogKeyFiles else " \"*****\"") xbmc.log(consts.logExecutingScript + tempcmd, level=xbmc.LOGDEBUG) cmd += "\"" + escapedOldPass + "\" " cmd += "\"" + escapedNewPass + "\"" cmd += " \"" + keyFiles + "\"" p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) if item != None: item.unlock() if errors: setErrorMessage(str(errors)) returnCode = int(output[len(output) - 2:]) # returnCode = 1; if returnCode == 0: return True else: return False
def unmountDrive(item): item.unmount(); if addon.getSetting("performMountChecks") == "true": mounted = item.isMounted(); if not mounted : # xbmc.executebuiltin("Notification(Truecrypt, " + addon.getLocalizedString(50050) + ", 5, " + __icon__ + ")"); sutilsxbmc.refreshCurrentListing(); item.remove_tc_aux_mnt(); else: if debug: print("TrueCrypt Drive Failed to unmount." + " " + item.getErrorMessage()); xbmcgui.Dialog().ok(addon.getLocalizedString(50030), addon.getLocalizedString(50049), item.getErrorMessage()); # "Truecrypt Error", "The truecrypt drive failed to unmount."
def performAction(action, item): if action == addon.getLocalizedString(50001): # Mount if debug: print("Truecrypt attempt to mount drive.") mountDrive(item) elif action == addon.getLocalizedString(50002): # Unmount if debug: print("Truecrypt attempt to unmount drive") unmountDrive(item) elif action == addon.getLocalizedString(50003): # "Deactivate" if debug: print("Truecrypt deactivating item.") item.deactivate() xbmcgui.Dialog().ok( addon.getLocalizedString(50012), addon.getLocalizedString(50013) + " " + addon.getLocalizedString(50014)) # Info , Item is deactivated. Use Addon settings to re-activate it." sutilsxbmc.refreshCurrentListing() elif action == addon.getLocalizedString(50004): # "Reset settings" if debug: print("Truecrypt reseting item.") reset(item) elif action == xbmc.getLocalizedString(117): # delete if debug: print("Truecrypt deleting item.") delete(item) elif action == addon.getLocalizedString(50005): # "Recreate container" if debug: print("Truecrypt recreating container.") recreateContainer(item) elif action == addon.getLocalizedString(50006): # "Format" if debug: print("Truecrypt formating container.") formatExistingContainer(item) elif action == addon.getLocalizedString(50007): # "Store password" if debug: print("Truecrypt password being stored.") setPassword(item) elif action == addon.getLocalizedString(50008): # "Remove stored password" if debug: print("Truecrypt password being removed.") removePassword(item) elif action == addon.getLocalizedString(50066): # Change password if debug: print("Truecrypt password being changed.") changePass(item) elif action == xbmc.getLocalizedString(222): # cancel if debug: print("Truecrypt canceled.") pass
def unmountDrive(item): item.unmount() if addon.getSetting("performMountChecks") == "true": mounted = item.isMounted() if not mounted: # xbmc.executebuiltin("Notification(Truecrypt, " + addon.getLocalizedString(50050) + ", 5, " + __icon__ + ")"); sutilsxbmc.refreshCurrentListing() item.remove_tc_aux_mnt() else: if debug: print("TrueCrypt Drive Failed to unmount." + " " + item.getErrorMessage()) xbmcgui.Dialog().ok(addon.getLocalizedString(50030), addon.getLocalizedString(50049), item.getErrorMessage())
def performAction(action, item ): if action == addon.getLocalizedString(50001) : # Mount if debug: print("Truecrypt attempt to mount drive."); mountDrive(item); elif action == addon.getLocalizedString(50002) : # Unmount if debug: print("Truecrypt attempt to unmount drive"); unmountDrive(item); elif action == addon.getLocalizedString(50003) : # "Deactivate" if debug: print("Truecrypt deactivating item."); item.deactivate(); xbmcgui.Dialog().ok(addon.getLocalizedString(50012), addon.getLocalizedString(50013) + " " + addon.getLocalizedString(50014)); # Info , Item is deactivated. Use Addon settings to re-activate it." sutilsxbmc.refreshCurrentListing(); elif action == addon.getLocalizedString(50004) : # "Reset settings" if debug: print("Truecrypt reseting item."); reset(item) elif action == xbmc.getLocalizedString(117): # delete if debug: print("Truecrypt deleting item."); delete(item); elif action == addon.getLocalizedString(50005): # "Recreate container" if debug: print("Truecrypt recreating container."); recreateContainer(item); elif action == addon.getLocalizedString(50006) : # "Format" if debug: print("Truecrypt formating container."); formatExistingContainer(item); elif action == addon.getLocalizedString(50007) : # "Store password" if debug: print("Truecrypt password being stored."); setPassword(item); elif action == addon.getLocalizedString(50008): # "Remove stored password" if debug: print("Truecrypt password being removed."); removePassword(item); elif action == addon.getLocalizedString(50066): # Change password if debug: print("Truecrypt password being changed."); changePass(item); elif action == xbmc.getLocalizedString(222): # cancel if debug: print("Truecrypt canceled."); pass;
def mountDrive(item): # create and exec command password = item.getPassword(); if password == None or password == "": password = sutilsxbmc.getStringFromUser(heading = addon.getLocalizedString(50011), hidden = True); # Enter password if password == None or password == "": aborted(); return; item.mount(password); if addon.getSetting("performMountChecks") == "true": mounted = item.isMounted(); if mounted : sutilsxbmc.refreshCurrentListing(); # xbmc.executebuiltin(u"Notification(Truecrypt, " + addon.getLocalizedString(50048).decode('utf-8') + ", 5, " + __icon__ + ")"); # The truecrypt drive is now mounted. else: errStr=item.getErrorMessage(); xbmcgui.Dialog().ok(addon.getLocalizedString(50030),addon.getLocalizedString(50049) , errStr); # Truecrypt Error", "The truecrypt drive failed to mount." del password;
def format(filePath, mountPoint, fs, item=None): ''' Method executes formating of the volume through the shell script. Volume has to be mounted first. :param filePath: path to the volume :param mountPoint: mount point :param fs: file system :param item: item which it concerns (only for lock reasons) ''' if item != None: item.lock(__settings__.getLocalizedString(50006)) sutilsxbmc.refreshCurrentListing() cmd = "\"" + shellScript + "\"" cmd += " " + consts.commandFormat + " " cmd += "\"" + filePath + "\" " cmd += "\"" + mountPoint + "\" " cmd += "\"\" " #\"" + __settings__.getSetting("tc_aux_mnt" + str(self.index)) + "\" "; cmd += fs xbmc.log(consts.logExecutingScript + cmd, level=xbmc.LOGDEBUG) p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) output, errors = p.communicate() xbmc.log(consts.logStandardOut + str(output), level=xbmc.LOGDEBUG) xbmc.log(consts.logErrorOut + str(errors), xbmc.LOGERROR if errors else xbmc.LOGDEBUG) returnCode = int(output[len(output) - 2:]) # returnCode = 0; if item != None: item.unlock() if errors != None: setErrorMessage(str(errors)) if returnCode == 0: return True else: return False
def delete(item): confirmed = xbmcgui.Dialog().yesno( addon.getLocalizedString(50069), xbmc.getLocalizedString(750), addon.getLocalizedString(50060) + ": " + item.name, xbmc.getLocalizedString(561) + ": " + item.filePath) #"Delete file?", "Are you sure?", "Item: " + item.name,"File: " + item.filePath if confirmed: # @type item resources.lib.tcitem success = item.delete() if not success: xbmcgui.Dialog().ok(addon.getLocalizedString(50058), addon.getLocalizedString(50059), item.getErrorMessage()) # "Failed", "Failed to delete specified file." else: xbmcgui.Dialog().ok(addon.getLocalizedString(50038), addon.getLocalizedString(50057)) # "Info", "File deleted sucessfully.") item.resetSettings() sutilsxbmc.refreshCurrentListing()
def mountDrive(item): # create and exec command password = item.getPassword() if password == None or password == "": password = sutilsxbmc.getStringFromUser( heading=addon.getLocalizedString(50011), hidden=True) # Enter password if password == None or password == "": aborted() return item.mount(password) if addon.getSetting("performMountChecks") == "true": mounted = item.isMounted() if mounted: sutilsxbmc.refreshCurrentListing() # xbmc.executebuiltin(u"Notification(Truecrypt, " + addon.getLocalizedString(50048).decode('utf-8') + ", 5, " + __icon__ + ")"); # The truecrypt drive is now mounted. else: errStr = item.getErrorMessage() xbmcgui.Dialog().ok(addon.getLocalizedString(50030), addon.getLocalizedString(50049), errStr) # Truecrypt Error", "The truecrypt drive failed to mount." del password
def createContainerAndItem(): item = pickItem(False); settingDic = getSettingsForContainer(True, item); if settingDic== None: aborted() return; s = sutilsxbmc.getNumberFromUser(0, addon.getLocalizedString(50021)); # Enter size in GB. if s == "" : aborted() return; size = str(int(s) * 1024 * 1024 * 1024) password = sutilsxbmc.getConfirmedPassword(); fileSystem = filesysToUse(); item.setDicSettings(settingDic, True); xbmc.executebuiltin("Notification(Truecrypt, " + addon.getLocalizedString(50021) + ", 5, " + __icon__ + ")"); # Creation of cantainer started. item.createNewFile(size, password); if not fileSystem == None : format(item, fileSystem, password); xbmc.executebuiltin("Notification(Truecrypt, " + addon.getLocalizedString(50054) + ", 5, " + __icon__ + ")"); # Attempting to mount created file. success = mountUnmount(item, password); if success : xbmcgui.Dialog().ok(xbmc.getLocalizedString(10511), addon.getLocalizedString(50063)); sutilsxbmc.refreshCurrentListing(); del password;
listDisks() listSmartdTasks() listOtherTasks() else: s = consts.colorShadeOfRed + addon.getLocalizedString( 50059) + consts.colorEnd # restart of OL required addFolderItem(s, -99) xbmcplugin.endOfDirectory(int(sys.argv[1])) # Execute chosen task # indexes 1 - 20 are reserved for common smartd tasks elif index == 1: 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))
def reset(item): confirmed = xbmcgui.Dialog().yesno(addon.getLocalizedString(50019) , addon.getLocalizedString(50023), addon.getLocalizedString(50023)); # "Continue?" ,"All settings for selected item will be removed. Continue?" if confirmed: item.resetSettings(); sutilsxbmc.refreshCurrentListing();
if index == None : # creates initial folder structured menu if sutils.isFileExecutableByOwner(consts.script): listDisks(); listSmartdTasks(); listOtherTasks(); else: s = consts.colorShadeOfRed + addon.getLocalizedString(50059) + consts.colorEnd; # restart of OL required addFolderItem(s, -99); xbmcplugin.endOfDirectory(int(sys.argv[1])); # Execute chosen task # indexes 1 - 20 are reserved for common smartd tasks elif index == 1: 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: