def overview(listOfSshConnections): from Functions import displayFunctions from Functions import controlFunctions from Functions import dataFunctions displayFunctions.clearTerminal() overviewOptions = [ 'updates', 'storage', 'uptime', 'CPU temps' ] printOverviewOptions(overviewOptions) overviewChoices = dataFunctions.getListOfIndicesFromList(overviewOptions) chosenOverviewIndex = dataFunctions.checkInputAgainstList_int(overviewChoices) displayFunctions.clearTerminal() if chosenOverviewIndex == 0: printUpdateOverview(listOfSshConnections) elif chosenOverviewIndex == 1: printStorageOverview(listOfSshConnections) elif chosenOverviewIndex == 2: printUptimeOverview(listOfSshConnections) elif chosenOverviewIndex == 3: printTempOverview(listOfSshConnections) print('Select overview again to reset view')
def displayFoldingScreen(listOfSshConnections): import config from Functions import displayFunctions from Functions import foldingFunctions from Functions import controlFunctions foldingData = foldingFunctions.foldingXmlParse() terminalSize = controlFunctions.updateTermSize() columnsIndex = 1 displayFunctions.clearTerminal() userInfoBanner = displayFunctions.getScreenDivider('User Info', terminalSize[columnsIndex]) print(userInfoBanner) printFoldingUsername(foldingData) print('') printFoldingRankChange(foldingData) print('') printFoldingPointsToday(foldingData) print('') printFoldingPointsInTheLast24Hrs(foldingData) printFoldingPointsAverage24Hrs(foldingData) print('') serverInfoBanner = displayFunctions.getScreenDivider('Server Info', terminalSize[columnsIndex]) print(serverInfoBanner) printAllServerFoldingInfo(config.server_name, listOfSshConnections)
def getCommandAndSend(): import config from Functions import displayFunctions from Functions import dataFunctions from Functions import controlFunctions bashCommandsToInstallDependancies = constructInstallDependanciesCommand() bashCommandDictionary = { 'Shutdown': 'sudo shutdown', 'Reboot': 'sudo reboot', 'Run Updates': 'sudo apt upgrade && sleep 1', 'Install Dependancies': bashCommandsToInstallDependancies } displayFunctions.clearTerminal() print("Which server do you want to send a command:") displayFunctions.printServerList() allowedInputs = dataFunctions.getListOfServerIndicies() chosenServerIndex = dataFunctions.checkInputAgainstList_int(allowedInputs) printListOfAvailableCommands(bashCommandDictionary) allowedInputs = range(len(bashCommandDictionary)) chosenCommandIndex = dataFunctions.checkInputAgainstList_int(allowedInputs) chosenBashCommand = getBashCommandFromIndex(chosenCommandIndex, bashCommandDictionary) initiateCommandInNewWindow(chosenServerIndex, bashCommandDictionary[chosenBashCommand])
def newSshWindow(): from Functions import displayFunctions from Functions import controlFunctions from Functions import dataFunctions displayFunctions.clearTerminal() displayFunctions.printServerList() allowedInputs = dataFunctions.getListOfServerIndicies() selectedServer = int( dataFunctions.checkInputAgainstList_int(allowedInputs)) createNewSshConnection(selectedServer)
def printUptimeOverview(listOfSshConnections): import config from Functions import displayFunctions from Functions import dataFunctions displayFunctions.clearTerminal() print("Loading uptime details...\n") for i in range(len(config.server_name)): print(config.server_name[i] + ':') serverUptime = dataFunctions.getUptime(listOfSshConnections[i]) print(serverUptime + '\n')
def printTempOverview(listOfSshConnections): import config from Functions import displayFunctions from Functions import dataFunctions displayFunctions.clearTerminal() print("Loading CPU temperature details...\n") for i in range(len(config.server_name)): print(config.server_name[i] + ':') serverTempInfo = dataFunctions.getTempInfo(listOfSshConnections[i]) print(serverTempInfo) print('')
def userSelectServer(): import config from Functions import displayFunctions from Functions import controlFunctions from Functions import dataFunctions displayFunctions.clearTerminal() print('Select which server to show details for:') displayFunctions.printServerList() allowedInputs = dataFunctions.getListOfServerIndicies() userInput = dataFunctions.checkInputAgainstList_int(allowedInputs) return userInput
def printStorageOverview(listOfSshConnections): import config from Functions import displayFunctions from Functions import dataFunctions displayFunctions.clearTerminal() print("Loading storage details...\n") for i in range(len(config.server_name)): rootStorage = dataFunctions.getRootStorage(listOfSshConnections[i]) additionalStorage = dataFunctions.getAdditionalStorage(config.additional_storage[i], listOfSshConnections[i]) print(config.server_name[i] + ':') displayFunctions.printStorageData(rootStorage, additionalStorage)
def printUpdateOverview(listOfSshConnections): import config from Functions import displayFunctions from Functions import dataFunctions displayFunctions.clearTerminal() print("Loading update details...\n") for i in range(len(config.server_name)): print(config.server_name[i] + ':') updates = dataFunctions.getUpdateData(listOfSshConnections[i]) print(' ' + updates) print('')
def displayDashboard(sshConnection, selectedServer): import config from Functions import dataFunctions, controlFunctions, foldingFunctions, displayFunctions currentScreen = 'd' print("\nLoading...\n") # These commands above the clear take some time so better to hide them behind 'loading' rootStorage = dataFunctions.getRootStorage(sshConnection) additionalStorage = dataFunctions.getAdditionalStorage( config.additional_storage[selectedServer], sshConnection) updates = dataFunctions.getUpdateData(sshConnection) displayFunctions.clearTerminal() print('Server Information: ' + config.server_name[selectedServer]) serverUptime = dataFunctions.getUptime(sshConnection) print(serverUptime + '\n') serverTempInfo = dataFunctions.getTempInfo(sshConnection) print('Package temperature:') print(serverTempInfo) print('Storage:') displayFunctions.printStorageData(rootStorage, additionalStorage) print('Update Data:\n ' + updates) foldingLogData = foldingFunctions.getFoldingLogData(sshConnection) printFoldingData(foldingLogData) numberOfLogFiles = getNumberOfLogFiles( config.extra_logfile_name[selectedServer]) if numberOfLogFiles != 0: for i in range(numberOfLogFiles): printLogFiles(sshConnection, config.extra_logfile_name[selectedServer][i], config.extra_logfile_location[selectedServer][i]) print('Select "0" to view processess and CPU load\n')