Exemplo n.º 1
0
def changeColor():
    intDecision = 0
    listOfOptions = [". Yes(Default)", ". No", ". Cancel"]
    while (((intDecision < 1) or (intDecision > len(listOfOptions)))):
        try:
            print(
                "\nDo you want Color Mode to be ON? If turned off it is harder to use the terminal interface."
            )
            if settingsJson.colorMode == True:
                print("Currently Color Mode is ON")
            else:
                print("Currently Color Mode is OFF")

            for i in range(len(listOfOptions)):
                terminalColor.printBlueString(str(i + 1) + listOfOptions[i])
            intDecision = int(input())
            if ((intDecision < 1) or (intDecision > len(listOfOptions))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfOptions[intDecision - 1] == ". Cancel"):
                break
            elif (listOfOptions[intDecision - 1] == ". Yes(Default)"):
                settingsJson.colorMode = True
                writeJSONSettings()
            elif (listOfOptions[intDecision - 1] == ". No"):
                settingsJson.colorMode = False
                writeJSONSettings()
            else:
                intDecision = 0
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
    terminalColor.printGreenString("SETTINGS UPDATED")
Exemplo n.º 2
0
def askForCredentials(storeCredentials):  #Ask user for login info
    hasValidCred = False
    wantsToCancel = False
    while (not hasValidCred and not wantsToCancel):
        try:
            print(
                "\nPlease enter your Email and Password.(Type \"Cancel\" to exit)\nEmail:",
                end=" ")
            username = str(input())
            if username.lower() == "cancel":
                wantsToCancel = True
                break
            password = getpass.getpass(prompt="Password(Input Hidden): ")
            if password.lower() == "cancel":
                wantsToCancel = True
                break
            hasValidCred = checkCredentials(
                dict(username=username,
                     password=password,
                     type="verify_password"))
            if hasValidCred:
                if storeCredentials: askToSaveLoginInfo()
                return True
            else:
                terminalColor.printRedString("Login Failed")
                return False
        except:
            terminalColor.printRedString("Invalid Input")
    return False
Exemplo n.º 3
0
def changeEditingMode():
    intDecision = 0
    listOfOptions = [". In Program", ". Externally", ". Cancel"]
    while (((intDecision < 1) or (intDecision > len(listOfOptions)))):
        try:
            print(
                "\nHow do you want strings to be edited? Note, on Windows it is neccesary to edit strings exterrnally."
            )
            if settingsJson.externalEditor:
                print(
                    "Currently strings are being edited through an external program."
                )
            else:
                print("Currently strings are being edited internally.")

            for i in range(len(listOfOptions)):
                terminalColor.printBlueString(str(i + 1) + listOfOptions[i])
            intDecision = int(input())
            if ((intDecision < 1) or (intDecision > len(listOfOptions))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfOptions[intDecision - 1] == ". Cancel"):
                break
            elif (listOfOptions[intDecision - 1] == ". Externally"):
                settingsJson.externalEditor = True
                writeJSONSettings()
            elif (listOfOptions[intDecision - 1] == ". In Program"):
                settingsJson.externalEditor = False
                writeJSONSettings()
            else:
                intDecision = 0
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
    terminalColor.printGreenString("SETTINGS UPDATED")
Exemplo n.º 4
0
def askToSaveLoginInfo():
    saveChoice = 0
    listOfChoices = [". Yes", ". No"]
    while ((saveChoice < 1) or (saveChoice > len(listOfChoices))):
        try:
            print("Do want to save your login credentials?")
            for i in range(len(listOfChoices)):
                terminalColor.printBlueString(str(i + 1) + listOfChoices[i])
            saveChoice = int(input())
            if ((saveChoice < 1) or (saveChoice > len(listOfChoices))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfChoices[saveChoice - 1] == ". No"):
                break
            elif (listOfChoices[saveChoice - 1] == ". Yes"):
                fileFunctions.checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/Settings")
                jsonToSave = dict(key1=settingsJson.key1,
                                  key2=settingsJson.key2,
                                  key3=settingsJson.key3)
                with open(
                        os.path.expanduser('~') +
                        "/HardwareDonations/Settings/LoginInfo",
                        'w') as outfile:
                    json.dump(jsonToSave, outfile)
                terminalColor.printGreenString("Login credentials saved")
        except:
            saveChoice = 0
            terminalColor.printRedString("Invalid Input")
def readFileList():
    with open(
            os.path.expanduser('~') +
            "/HardwareDonations/Settings/DownloadList", 'r') as myfile:
        data = myfile.read()
    obj = json.loads(data)

    typesOfDownload = ["Legal", "PDFs", "Photos", "Wallpapers"]
    categorySelection = 0
    while (categorySelection < 1) or (categorySelection >
                                      (len(typesOfDownload) + 1)):
        print("\nWhat category do you want to browse for downloads?")
        for i in range(len(typesOfDownload)):
            terminalColor.printBlueString(
                str(i + 1) + ". " + typesOfDownload[i])
        terminalColor.printBlueString(
            str(len(typesOfDownload) + 1) + ". Cancel")
        try:
            categorySelection = int(input())
            if (categorySelection > 0) and (categorySelection <=
                                            (len(typesOfDownload))):
                chooseFileToDownload(obj,
                                     typesOfDownload[categorySelection - 1])
                categorySelection = 0
            elif (categorySelection == (len(typesOfDownload) + 1)):
                return
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 6
0
def verifyUploadData(jsonToUpload):
    uploadDataOk = False
    while not uploadDataOk:
        for x in jsonToUpload: print(terminalColor.generateYellowString(x) + ": " + jsonToUpload[x] )
        print("\nDo you want to want to upload these changes?[Yes/No]")
        strDecision = input()
        if strDecision.lower() == "yes" or strDecision.lower() == "y": return True
        elif strDecision.lower() == "no" or strDecision.lower() == "n": return False
        else: terminalColor.printRedString("Invalid Input")                        
Exemplo n.º 7
0
def editTextEntry(stuffToUpdate, unitInfo, category): #code to edit data in a category
    copyOfStuffToUpdate = stuffToUpdate.copy()
    originalData = unitInfo[category]
    try: oldData = copyOfStuffToUpdate[category]
    except: oldData = unitInfo[category]
    print("Original " + category + " Data: " + originalData)
    newData = methodOfEditingString(category +": " ,oldData)
    while len(newData) < 2 or len(newData) > 70:
        terminalColor.printRedString("The data you entered is too long or short")
        newData = methodOfEditingString(category +": " ,oldData)
    if newData == originalData and category in copyOfStuffToUpdate: del copyOfStuffToUpdate[category]
    elif not newData == originalData: copyOfStuffToUpdate[category] = newData
    return copyOfStuffToUpdate
Exemplo n.º 8
0
def deleteUnit(unitID): #connects to AWS Lambda to delete a unit
    try:
        payload = dict(key1=settingsJson.key1, key2=settingsJson.key2, key3=settingsJson.key3, type="unit_delete", unitID=unitID)
        response = settings.initiateLambdaClient().invoke(
            FunctionName='arn:aws:lambda:us-west-1:105369739187:function:HDPasswordCheck',
            InvocationType='RequestResponse',
            Payload=json.dumps(payload),
        )
        responseJSON=json.loads(response['Payload'].read())
        if not responseJSON["result"]: terminalColor.printRedString("Failed to delete unit: " + responseJSON["reason"])
        return responseJSON["result"]
    except:
        return False
Exemplo n.º 9
0
def installSelectedBSIs(listOfSelectedBSI):
	#This is a placeholder for future internet features
	terminalColor.printRedString("\nunable to connect to BSI-Servers")

	writeInstalledBSIs(listOfSelectedBSI)

	#runs all BSIs in the list listOfSelectedBSI
	if not settingsJson.dummyBSIInstall:
		for i in listOfSelectedBSI:
			terminalColor.printGreenString("\nInitializing " + i +" BSI")
			exec(str(i + "BSI()" ))
	
	#Reminds user to apply all changes
	terminalColor.printRedString("\nPlease restart the computer to apply all changes made")
	os.system('sleep 5s')
def chooseFileToDownload(obj, typeOfDownload):
    intDecision = 0
    terminateLoop = False
    urlToDownload = "none"
    nameToDownload = "none"
    extensionToDownload = "none"
    categoryToDownload = "none"
    while (((intDecision < 1) or (intDecision > len(downloadName) + 1))
           or (terminateLoop == False)):
        print("\n")
        downloadURLs = []
        downloadName = []
        downloadExtension = []
        downloadCategory = []
        for downloadable in obj[typeOfDownload]:
            downloadURLs.append(str(downloadable["url"]))
            downloadName.append(str(downloadable["name"]))
            downloadExtension.append(str(downloadable["fileExtention"]))
            downloadCategory.append(typeOfDownload)
            terminalColor.printBlueString(
                str(len(downloadURLs)) + ". " + downloadable["name"])
            print("     Description: " + downloadable["description"])
            print("     Size: " + downloadable["size"])
            print("     File Extension: " + downloadable["fileExtention"])
        terminalColor.printBlueString(str(len(downloadName) + 1) + ". Cancel")

        try:
            print("Which file do you want to download?")
            intDecision = int(input())
            if ((intDecision < 1) or (intDecision > (len(downloadURLs) + 1))):
                terminalColor.printRedString("Invalid Input")
            elif (intDecision == (len(downloadName) + 1)):
                terminateLoop = True
            else:
                print("\nDownloading URL: " + downloadURLs[intDecision - 1])
                terminateLoop = True
                urlToDownload = downloadURLs[intDecision - 1]
                nameToDownload = downloadName[intDecision - 1]
                extensionToDownload = downloadExtension[intDecision - 1]
                categoryToDownload = downloadCategory[intDecision - 1]
                fileFunctions.chooseFolderToSaveFile([
                    urlToDownload, nameToDownload, extensionToDownload,
                    categoryToDownload
                ])
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
    return
Exemplo n.º 11
0
def changeCPUArchitecture(original, current): #Selects CPU Arch.
    cpuArchitectures = ["Unknown","64-Bit","32-Bit","PowerPC","Cancel"]
    intDecision = 0
    while ( (intDecision < 1 ) or (intDecision > len(cpuArchitectures)) ):
        try:
            print("\nWhat CPU Architecture does this unit have?")
            print("Original CPU Architecture Data: " + original)
            print("Current CPU Architecture Data: " + current)
            for i in range( len(cpuArchitectures) ): terminalColor.printBlueString( str(i+1) + ". " + cpuArchitectures[i])
            intDecision = int(input())
            if ( (intDecision < 1) or (intDecision > len(cpuArchitectures)) ): terminalColor.printRedString("Invalid Input")
            elif cpuArchitectures[intDecision -1] == "Cancel": return current
            else: return cpuArchitectures[intDecision -1]
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 12
0
def changeRAMType(original, current): #Selects type of RAM
    ramType = ["Unknown","Other","DDR RAM","DDR2 RAM","DDR3 RAM","DDR4 RAM","DDR SDRAM","DDR2 SDRAM","DDR3 SDRAM","DDR4 SDRAM","Cancel"]
    intDecision = 0
    while ( (intDecision < 1 ) or (intDecision > len(ramType)) ):
        try:
            print("\nWhat type of RAM does this unit have?")
            print("Original RAM Type Data: " + original)
            print("Current RAM Type Data: " + current)
            for i in range( len(ramType) ): terminalColor.printBlueString( str(i+1) + ". " + ramType[i])
            intDecision = int(input())
            if ( (intDecision < 1) or (intDecision > len(ramType)) ): terminalColor.printRedString("Invalid Input")
            elif ramType[intDecision -1] == "Cancel": return current
            else: return ramType[intDecision - 1]
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 13
0
def changeUnitLocation(original, current): #Selects version of ARK-OS
    unitLocations = ["Unknown","Donated","Site 1(Bosco Tech)","Site 2(Roosevelt)","Site 3(ELAC)", "Cancel"]
    intDecision = 0
    while ( (intDecision < 1 ) or (intDecision > len(unitLocations)) ):
        try:
            print("\nWhere is this unit located?")
            print("Original Location Version Data: " + original)
            print("Current Location Version Data: " + current)
            for i in range( len(unitLocations) ): terminalColor.printBlueString( str(i+1) + ". " + unitLocations[i])
            intDecision = int(input())
            if ( (intDecision < 1) or (intDecision > len(unitLocations)) ): terminalColor.printRedString("Invalid Input")
            elif unitLocations[intDecision -1] == "Cancel": return current
            else: return unitLocations[intDecision - 1]
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 14
0
def changeARKOSVersion(original, current): #Selects version of ARK-OS
    arkosVersions = ["Unknown","None","Experimental","v1.0.6","v1.1.2","v1.2.1","v2.0.1 \"Bosco\"","v2.1.0 \"Bosco Tech\"", "Cancel"]
    intDecision = 0
    while ( (intDecision < 1 ) or (intDecision > len(arkosVersions)) ):
        try:
            print("\nWhat version of ARK-OS does this unit have installed?")
            print("Original ARK-OS Version Data: " + original)
            print("Current ARK-OS Version Data: " + current)
            for i in range( len(arkosVersions) ): terminalColor.printBlueString( str(i+1) + ". " + arkosVersions[i])
            intDecision = int(input())
            if ( (intDecision < 1) or (intDecision > len(arkosVersions)) ): terminalColor.printRedString("Invalid Input")
            elif arkosVersions[intDecision -1] == "Cancel": return current
            else: return arkosVersions[intDecision - 1]
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 15
0
def createUnit():
    print("\nPlease enter the following information")
    searchResults = searchUnits()
    if searchResults["unitExists"]:
        terminalColor.printRedString("This unit already exists")
        return
    elif searchResults["reason"] == "Invalid Access Level":
        terminalColor.printRedString("Invalid Access Level")
        return
    unitID = searchResults["unitID"]
    terminalColor.printGreenString("No unit located with this id")
    jsonTemplate = {}
    listOfCategories = [
        "Location", "Status", "UserID", "Manufacturer", "Model",
        "ARK-OS_Version", "Operating System", "CPU Type", "CPU GHz",
        "CPU Threads", "CPU Architecture", "RAM", "RAM Slots", "RAM Type",
        "HDD", "HDD Port", "HDD Speed", "USB Ports", "Audio Ports",
        "Display Ports", "Disk Drive", "Networking", "Ports", "Comments"
    ]
    for i in listOfCategories:
        jsonTemplate[i] = "NO DATA"
    newUnitJSON = unitEdit.unitEditEntry(dict(unitInfo=jsonTemplate),
                                         "Creating New Unit")
    if newUnitJSON["Unit_ID"] == "OkToUpload":
        newUnitJSON["Unit_ID"] = unitID
        unitType = unitID.split("-", 1)[0]
        if unitType == "HDD":
            newUnitJSON["Category"] = "HDD(Hardware Donations Desktop)"
        elif unitType == "HDL":
            newUnitJSON["Category"] = "HDL(Hardware Donations Laptop)"
        elif unitType == "NX":
            newUnitJSON["Category"] = "NX(Experimental)"
        payload = dict(key1=settingsJson.key1,
                       key2=settingsJson.key2,
                       key3=settingsJson.key3,
                       type="unit_create",
                       unitID=unitID,
                       unitInfo=newUnitJSON)
        response = settings.initiateLambdaClient().invoke(
            FunctionName=
            'arn:aws:lambda:us-west-1:105369739187:function:HDPasswordCheck',
            InvocationType='RequestResponse',
            Payload=json.dumps(payload),
        )
        passTest = json.loads(response['Payload'].read())
        if passTest["result"]:
            terminalColor.printGreenString("Unit Successfully created")
        else:
            terminalColor.printRedString("Unit creation failed")
    else:
        terminalColor.printRedString("Unit creation canceled")
Exemplo n.º 16
0
def accountSettings(isLoggedOut):
    if isLoggedOut:
        isLoggedOut = not browseDatabase.askForCredentials(True)
    if not isLoggedOut:
        intDecision = 0
        listOfOptions = [". Logout", ". Change Password", ". Cancel"]
        while (((intDecision < 1) or (intDecision > len(listOfOptions)))):
            try:
                print("\nWhat settings do you want to change?")
                for i in range(len(listOfOptions)):
                    terminalColor.printBlueString(
                        str(i + 1) + listOfOptions[i])
                intDecision = int(input())
                if ((intDecision < 1) or (intDecision > len(listOfOptions))):
                    terminalColor.printRedString("Invalid Input")
                elif (listOfOptions[intDecision - 1] == ". Cancel"):
                    pass  #Exit program
                elif (listOfOptions[intDecision - 1] == ". Logout"):
                    logoutOfAccount()
                elif (listOfOptions[intDecision - 1] == ". Change Password"):
                    intDecision = 0
                    terminalColor.printRedString(
                        "This option has not been set up yet")
            except:
                intDecision = 0
                terminalColor.printRedString("Invalid Input")
Exemplo n.º 17
0
def Settings():
	intDecision = 0
	settingsOptions = ["Update Software", "Change Color Mode", "Developer Options", "Main Menu"]

	while ( ( (intDecision < 1) or (intDecision > len(settingsOptions)) ) ):
			try:
				#Display options
				print("\nWhat do you want to do?")
				for i in range( len(settingsOptions) ):
						terminalColor.printBlueString( str(i+1) + ". " + settingsOptions[i] )

				#get user input
				intDecision = int(input())

				if ( (intDecision < 1) or (intDecision > len(settingsOptions)) ): terminalColor.printRedString("Invalid Input")
				elif ( settingsOptions[intDecision-1] == "Main Menu"): break
				elif ( settingsOptions[intDecision-1] == "Change Color Mode"):
						intDecision = 0
						if settingsJson.colorMode:
								print("\nCurrently Color Mode is ON\nDo you want to turn it off?[Yes/No]")
								userYesNo=str(input())
								if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"): settingsJson.colorMode = False
						else:
								print("\nCurrently Color Mode is OFF\nDo you want to turn it on?[Yes/No]")
								userYesNo=str(input())
								if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"): settingsJson.colorMode = True
				elif ( settingsOptions[intDecision-1] == "Update Software"):
						intDecision = 0
						os.system( path.dirname(__file__) + '/BSI-Installer.sh')
						sys.exit()
				elif ( settingsOptions[intDecision-1] == "Developer Options"):
						intDecision = 0
						developerOptions()
				else:
						intDecision = 0
				writeSettings() 
			except Exception as e:
				if e == SystemExit: sys.exit()
				intDecision = 0
				terminalColor.printRedString("Invalid Input")
Exemplo n.º 18
0
def developerOptions():
	intDecision = 0
	devSettingsOptions = ["Dummy BSI Install Mode", "Delete BSI Install Data", "Exit"]

	while ( ( (intDecision < 1) or (intDecision > len(devSettingsOptions)) ) ):
			try:
				#Display options
				terminalColor.printRedString("\nWarning: these settings are not meant for regular users, they are mostly for testing purposes")
				print("What do you want to do?")
				for i in range( len(devSettingsOptions) ):
					terminalColor.printBlueString( str(i+1) + ". " + devSettingsOptions[i] )
				
				#get user input
				intDecision = int(input())

				if ( (intDecision < 1) or (intDecision > len(devSettingsOptions)) ): terminalColor.printRedString("Invalid Input")
				elif ( devSettingsOptions[intDecision-1] == "Exit"): pass
				elif ( devSettingsOptions[intDecision-1] == "Dummy BSI Install Mode"):
					intDecision = 0   
					terminalColor.printRedString("if enabled when installing a BSI nothing is downloaded/installed")
					if settingsJson.dummyBSIInstall:
						print("Currently this option is ENABLED. Do you want to disable it?[Yes/No]")
						userYesNo=str(input())
						if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"): settingsJson.dummyBSIInstall = False
					else: 
						print("Currently this option is DISABLED. Do you want to enable it?[Yes/No]")
						userYesNo=str(input())
						if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"): settingsJson.dummyBSIInstall = True
				elif ( devSettingsOptions[intDecision-1] == "Delete BSI Install Data"):
					terminalColor.printRedString("if you Delete your BSI Install Data you will not be able to tell what BSIs have been installed onto your computer")
					print("Are you absolutely certain you want to delete this data?[Yes/No]")
					userYesNo=str(input())
					if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"):
						try: os.remove(os.path.expanduser('~') + "/.BSI/computerInfo")
						except: pass
				else:
					intDecision = 0
			except:
				intDecision = 0
				terminalColor.printRedString("Invalid Input")
Exemplo n.º 19
0
def printUnitInfo(responseJson, unitID): #Prints out data on units
    try:
        unitInfo = responseJson["unitInfo"]
        print("\nInfo Page For " + unitID )
        terminalColor.printCyanString(" " + unitID )
        print( terminalColor.generateYellowString( "  Unit Category: " ) + unitInfo["Category"])
        print( terminalColor.generateYellowString( "  Unit Number: " ) + unitID.split("-",1)[1] )
        print( terminalColor.generateYellowString( "  Location: " ) + unitInfo["Location"])
        print( terminalColor.generateYellowString( "  Status: " ) + unitInfo["Status"])
        print( terminalColor.generateYellowString( "  User ID: " ) + unitInfo["UserID"])
        terminalColor.printCyanString( " System Info")
        print( terminalColor.generateYellowString( "  Manufacturer: " ) + unitInfo["Manufacturer"])
        print( terminalColor.generateYellowString( "  Model: " ) + unitInfo["Model"])
        print( terminalColor.generateYellowString( "  ARK-OS Version: " ) + unitInfo["ARK-OS_Version"])
        print( terminalColor.generateYellowString( "  Original Operating System: " ) + unitInfo["Operating System"])
        terminalColor.printCyanString(" CPU")
        print( terminalColor.generateYellowString( "  CPU Model: " ) + unitInfo["CPU Type"])
        print( terminalColor.generateYellowString( "  CPU GHz: " ) + unitInfo["CPU GHz"])
        print( terminalColor.generateYellowString( "  CPU Threads: " ) + unitInfo["CPU Threads"])
        print( terminalColor.generateYellowString( "  CPU Architecture: " ) + unitInfo["CPU Architecture"])
        terminalColor.printCyanString( " RAM")
        print( terminalColor.generateYellowString( "  RAM GB: " ) + unitInfo["RAM"])
        print( terminalColor.generateYellowString( "  RAM Slots: " ) + unitInfo["RAM Slots"])
        print( terminalColor.generateYellowString( "  RAM Type: " ) + unitInfo["RAM Type"])
        terminalColor.printCyanString( " HDD")
        print( terminalColor.generateYellowString( "  HDD Size: " ) + unitInfo["HDD"])
        print( terminalColor.generateYellowString( "  HDD Port: " ) + unitInfo["HDD Port"])
        print( terminalColor.generateYellowString( "  HDD Speed: " ) + unitInfo["HDD Speed"])
        terminalColor.printCyanString( " Ports")
        print( terminalColor.generateYellowString( "  USB Ports: " ) + unitInfo["USB Ports"])
        print( terminalColor.generateYellowString( "  Audio Ports: " ) + unitInfo["Audio Ports"])
        print( terminalColor.generateYellowString( "  Display Ports: " ) + unitInfo["Display Ports"])
        print( terminalColor.generateYellowString( "  External Disk Drives: " ) + unitInfo["Disk Drive"])
        print( terminalColor.generateYellowString( "  Networking: " ) + unitInfo["Networking"])
        print( terminalColor.generateYellowString( "  Other Ports: " ) + unitInfo["Ports"])
        print( terminalColor.generateCyanString( " Comments: ") + unitInfo["Comments"])
    except:
        terminalColor.printRedString("Unable to print all data")
Exemplo n.º 20
0
def changeSettings():
    intDecision = 0
    listOfOptions = [
        ". GUI Mode", ". Color Mode", ". Account Settings", ". Version Info",
        ". Editing Mode", ". Cancel"
    ]
    while (((intDecision < 1) or (intDecision > len(listOfOptions)))):
        try:
            print("\nWhat settings do you want to change?")
            for i in range(len(listOfOptions)):
                terminalColor.printBlueString(str(i + 1) + listOfOptions[i])
            intDecision = int(input())
            if ((intDecision < 1) or (intDecision > len(listOfOptions))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfOptions[intDecision - 1] == ". Cancel"):  #Exit program
                break
            elif (listOfOptions[intDecision - 1] == ". GUI Mode"):
                intDecision = 0
                changeGUI()
            elif (listOfOptions[intDecision - 1] == ". Color Mode"):
                intDecision = 0
                changeColor()
            elif (listOfOptions[intDecision - 1] == ". Editing Mode"):
                intDecision = 0
                changeEditingMode()
            elif (listOfOptions[intDecision - 1] == ". Account Settings"):
                intDecision = 0
                if browseDatabase.hasValidCredStored(): accountSettings(False)
                else: accountSettings(True)
            elif (listOfOptions[intDecision - 1] == ". Version Info"):
                intDecision = 0
                print("\nHardware-Donations Desktop App\nVersion " +
                      settingsJson.versionNum + "\nBuilt With Python 3.6.9")
            else:
                intDecision = 0
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 21
0
def logoutOfAccount():
    intlogoutDecision = 0
    listOfLogoutOptions = [". Yes", ". No"]
    while intlogoutDecision == 0:
        print("Do you want to logout of your account?")
        for i in range(len(listOfLogoutOptions)):
            terminalColor.printBlueString(str(i + 1) + listOfLogoutOptions[i])
        intlogoutDecision = int(input())
        if ((intlogoutDecision < 1)
                or (intlogoutDecision > len(listOfLogoutOptions))):
            terminalColor.printRedString("Invalid Input")
        elif (listOfLogoutOptions[intlogoutDecision -
                                  1] == ". No"):  #Exit program
            pass
        elif (listOfLogoutOptions[intlogoutDecision - 1] == ". Yes"):
            settingsJson.key1 = "na"
            settingsJson.key2 = "na"
            settingsJson.key3 = "na"
            loginFileLoc = os.path.expanduser(
                '~') + "/HardwareDonations/Settings/LoginInfo"
            if fileFunctions.checkForFile(loginFileLoc):
                fileFunctions.deleteFile(loginFileLoc)
            terminalColor.printGreenString("SETTINGS UPDATED")
Exemplo n.º 22
0
def searchUnits():
    unitTypeInt = 0
    unitNumInt = 0
    unitType = ""
    unitID = ""
    listOfUnitTypes = [". HDD", ". HDL", ". NX", ". Exit"]
    while ((unitTypeInt < 1) or (unitTypeInt > len(listOfUnitTypes))):
        try:
            print("\nWhat unit type do you want to search for?")
            for i in range(len(listOfUnitTypes)):
                terminalColor.printBlueString(str(i + 1) + listOfUnitTypes[i])
            unitTypeInt = int(input())
            if ((unitTypeInt < 1) or (unitTypeInt > len(listOfUnitTypes))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfUnitTypes[unitTypeInt - 1] == ". Exit"):
                break
            elif (listOfUnitTypes[unitTypeInt - 1] == ". HDD"):
                unitType = "HDD"
            elif (listOfUnitTypes[unitTypeInt - 1] == ". HDL"):
                unitType = "HDL"
            elif (listOfUnitTypes[unitTypeInt - 1] == ". NX"):
                unitType = "NX"
            print("\nWhat unit number do you want to search for?")
            print(unitType + "-", end="")
            unitNumInt = int(input())
            unitID = unitType + "-" + str(unitNumInt)
            responseJson = getUnitInfo(unitID)
            if (responseJson["result"] == True):
                return dict(unitExists=True, rJSON=responseJson, unitID=unitID)
            else:
                return dict(unitExists=False,
                            unitID=unitID,
                            reason=responseJson["reason"])
        except:
            unitTypeInt = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 23
0
def uploadNewPhoto(unitID):
    print("\nAre you sure you want to replace the unit photo?(Yes/No)")
    strDecision = input()
    if strDecision.lower() == "yes" or strDecision.lower() == "y":
        Tk().withdraw()
        filepath = askopenfilename()
        filename = filepath.split("/")[-1]
        filetype = filename.split(".")[-1]
        filename = filename.replace(" ", "")
        if filetype.lower() == "jpg" or filetype.lower() == "jpeg" or filetype.lower() == "png":
            uploadLocation = fileFunctions.uploadToS3(unitID, filename, filepath)
            if not uploadLocation == "false":
                stuffToUpdate = dict(Photo_URL=uploadLocation)
                uploadUnitUpdate(stuffToUpdate, unitID)
            else: terminalColor.printRedString("Upload failed")
        else: terminalColor.printRedString("Invalid file type. Please upload a \"JPEG\" or \"PNG\" file")
    else: terminalColor.printRedString("Upload canceled")
def chooseFolderToSaveFile(downloadInfo):
    if (downloadInfo[1] == "none"):
        return
    else:
        fileLoc = ""
        if (settingsJson.guiMode == True):
            root = Tk()
            root.withdraw()
            options = {
            }  #https://www.programcreek.com/python/example/9924/tkFileDialog.asksaveasfilename

            if (downloadInfo[2] == ".txt"):
                options['filetypes'] = [('text files', '.txt')]
            elif (downloadInfo[2] == ".pdf"):
                options['filetypes'] = [('pdf files', '.pdf')]
            elif (downloadInfo[2] == ".zip"):
                options['filetypes'] = [('zip files', '.zip')]
            elif (downloadInfo[2] == ".png"):
                options['filetypes'] = [('png files', '.png')]
            elif (downloadInfo[2] == "unknown"):
                if ".png" in downloadInfo[0].lower():
                    options['filetypes'] = [('png files', '.png')]
                    downloadInfo[2] = ".png"
                elif ".jpg" in downloadInfo[0].lower():
                    options['filetypes'] = [('jpg files', '.jpg')]
                    downloadInfo[2] = ".jpg"
                elif ".jpeg" in downloadInfo[0].lower():
                    options['filetypes'] = [('jpeg files', '.jpeg')]
                    downloadInfo[2] = ".jpeg"

            if (downloadInfo[3] == "PDFs"):
                options['initialdir'] = checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/PDF_Files")
            elif (downloadInfo[3] == "Legal"):
                options['initialdir'] = checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/Legal_Files")
            elif (downloadInfo[3] == "Photos"):
                options['initialdir'] = checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/Photos")
            elif (downloadInfo[3] == "Wallpapers"):
                options['initialdir'] = checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/Wallpapers")
            elif (downloadInfo[3] == "Labels"):
                options['initialdir'] = checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/Labels")
            elif (downloadInfo[3] == "Unit Photos"):
                options['initialdir'] = checkForDirectory(
                    os.path.expanduser('~') + "/HardwareDonations/Unit_Photos")

            options['title'] = "Download As"
            options['initialfile'] = downloadInfo[1] + downloadInfo[2]

            fileLoc = filedialog.asksaveasfilename(**options)
        elif (settingsJson.guiMode == False):
            validDirPath = False
            while validDirPath == False:
                print(
                    "Please type the path of the directory you want to save to.(Or type \"Cancel\")"
                )
                fileLoc = str(input())
                if fileLoc.lower() == "cancel":
                    break
                elif not ("/" == fileLoc[-1] and os.path.exists(fileLoc)):
                    terminalColor.printRedString("Invalid directory")
                else:
                    validDirPath = True
        if (len(fileLoc) > 0) and not (fileLoc.lower() == "cancel"):
            fileLoc = fileLoc

            def _progress(count, block_size, total_size):
                if (float(count * block_size) / float(total_size) < 1.0):
                    sys.stdout.write('\rDownloading %.2f%%' %
                                     (float(count * block_size) /
                                      float(total_size) * 100.0))
                    sys.stdout.flush()

            urllib.request.urlretrieve(downloadInfo[0],
                                       fileLoc,
                                       reporthook=_progress)
            terminalColor.printGreenString("\nDOWNLOAD FINISHED")
            print("File Saved To: " + fileLoc)
        else:
            terminalColor.printRedString("DOWNLOAD CANCELED")
Exemplo n.º 25
0
def unitEditEntry(responseJson, typeOfEditing): #User selects what category they want to edit
    unitInfo = responseJson["unitInfo"]
    intDecision = 0
    listOfOptions = [". Location", ". Status", ". User ID",". Manufacturer",". Model",". ARK-OS Version", ". Original Operating System", ". CPU Model", ". CPU GHz",". CPU Threads",". CPU Architecture",". RAM GB",". RAM Slots",". RAM Type", ". HDD GB", ". HDD Port",". HDD Speed",". USB Ports",". Audio Ports",". Display Ports",". External Disk Drives",". Networking",". Other Ports", ". Comments", ". Exit", ". Save and Exit"]
    listOfCategories = ["Location", "Status", "UserID", "Manufacturer", "Model", "ARK-OS_Version", "Operating System", "CPU Type", "CPU GHz", "CPU Threads","CPU Architecture","RAM","RAM Slots","RAM Type", "HDD", "HDD Port","HDD Speed","USB Ports","Audio Ports","Display Ports","Disk Drive","Networking","Ports", "Comments"]
    stuffToUpdate = {}
    while ( (intDecision < 1 ) or (intDecision > len(listOfOptions)) ):
        try:
            print("\nWhat section do you want to edit?")
            for i in range( len(listOfOptions) - 1):
                if ( len(listOfCategories) > i and listOfCategories[i] in stuffToUpdate ): terminalColor.printGreenRegString( str(i+1) + listOfOptions[i] )
                else: terminalColor.printBlueString( str(i+1) + listOfOptions[i] )
            if len(stuffToUpdate) > 0: terminalColor.printBlueString( str(len(listOfOptions)) + listOfOptions[len(listOfOptions) - 1] ) #Prints "Save and Exit"
            intDecision = int(input())
            if ( (intDecision) == 20207864):
                for i in listOfCategories:
                    stuffToUpdate[i] = "[REDACTED]"
            elif ( (intDecision < 1) or (intDecision > len(listOfOptions)) ): terminalColor.printRedString("Invalid Input")
            elif ( listOfOptions[intDecision-1] == ". Exit" ):
                try: testVariable = responseJson["Unit_ID"]
                except: responseJson["Unit_ID"] = "bad"
                return responseJson
            elif ( listOfOptions[intDecision-1] == ". Save and Exit" ) and len(stuffToUpdate) > 0:
                if typeOfEditing == "Editing Existing Unit":
                    if verifyUploadData(stuffToUpdate): return uploadUnitUpdate(stuffToUpdate, unitInfo["Unit_ID"])
                    else:
                        intDecision = 0
                elif typeOfEditing == "Creating New Unit":
                    if len(stuffToUpdate) > 23:
                        if verifyUploadData(stuffToUpdate): 
                            stuffToUpdate["Unit_ID"] = "OkToUpload"
                            return stuffToUpdate
                        else:
                            intDecision = 0
                    else:
                        intDecision = 0
                        terminalColor.printRedString("Please fill out all fields before creating a new unit")
            elif ( listOfOptions[intDecision-1] == ". Comments"):
                intDecision = 0
                try: oldComments = stuffToUpdate["Comments"]
                except: oldComments = unitInfo["Comments"]
                newComments = click.edit(oldComments)
                stuffToUpdate["Comments"] = newComments
            elif checkIfCategoryHasLists(listOfCategories[intDecision-1]):
                category = listOfCategories[intDecision-1]
                intDecision = 0
                originalData = unitInfo[category]
                try: oldData = stuffToUpdate[category]
                except: oldData = unitInfo[category]
                if category == "RAM Type": newData = changeRAMType(originalData, oldData)
                elif category == "CPU Architecture": newData = changeCPUArchitecture(originalData, oldData)
                elif category == "ARK-OS_Version": newData = changeARKOSVersion(originalData, oldData)
                elif category == "Location": newData = changeUnitLocation(originalData, oldData)
                if newData == originalData and category in stuffToUpdate: del stuffToUpdate[category]
                elif not newData == originalData: stuffToUpdate[category] = newData
            else:
                stuffToUpdate = editTextEntry(stuffToUpdate, unitInfo, listOfCategories[intDecision-1])
                intDecision = 0
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 26
0
def selectCategory():
    intDecision = 0
    listOfOptions = [
        ". Search Units", ". Search Users", ". Create Unit", ". Exit"
    ]
    while ((intDecision < 1) or (intDecision > len(listOfOptions))):
        try:
            print("\nWhat do you want to do?")
            for i in range(len(listOfOptions)):
                terminalColor.printBlueString(str(i + 1) + listOfOptions[i])
            intDecision = int(input())
            if ((intDecision < 1) or (intDecision > len(listOfOptions))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfOptions[intDecision - 1] == ". Exit"):
                break
            elif (listOfOptions[intDecision - 1] == ". Search Units"):
                intDecision = 0
                searchResults = searchUnits()
                if searchResults["unitExists"]:
                    unitEdit.unitEditOptions(searchResults["rJSON"],
                                             searchResults["unitID"])
                elif searchResults["unitExists"] and (
                        searchResults["reason"] == "Unable To Find Unit"):
                    terminalColor.printRedString("unable to find unit")
                elif searchResults["unitExists"] and (
                        searchResults["reason"] == "Invalid Access Level"):
                    terminalColor.printRedString("Invalid Access Level")
                else:
                    terminalColor.printRedString("Error")
            elif (listOfOptions[intDecision - 1] == ". Create Unit"):
                intDecision = 0
                createUnit()
            elif (listOfOptions[intDecision - 1] == ". Search Users"):
                intDecision = 0
                terminalColor.printRedString("unable to find user")
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")
Exemplo n.º 27
0
    terminalColor.printGreenString("SETTINGS LOADED!")
    printARKDino()

    intDecision = 0
    listOfOptions = [
        ". Install ARK-OS", ". Access Database", ". Download Files",
        ". Go To Youtube Channel", ". Settings", ". Exit"
    ]
    while (((intDecision < 1) or (intDecision > len(listOfOptions)))):
        try:
            print("\nWhat do you want to do?")
            for i in range(len(listOfOptions)):
                terminalColor.printBlueString(str(i + 1) + listOfOptions[i])
            intDecision = int(input())
            if ((intDecision < 1) or (intDecision > len(listOfOptions))):
                terminalColor.printRedString("Invalid Input")
            elif (listOfOptions[intDecision - 1] == ". Exit"):
                break  #Exit program
            elif (listOfOptions[intDecision - 1] == ". Download Files"):
                intDecision = 0
                if (fileFunctions.internet_on() == True):
                    downloadFiles.downloadFilesMain()
                else:
                    terminalColor.printRedString(
                        "Unable to connect to internet")
            elif (listOfOptions[intDecision - 1] == ". Download Files"):
                intDecision = 0
                if (fileFunctions.internet_on() == True):
                    downloadFiles.downloadFilesMain()
                else:
                    terminalColor.printRedString(
Exemplo n.º 28
0
	print("BBB   SSS  III")
	print("B  B  S     I")
	print("BBB   SSS   I")
	print("B  B    S   I")
	print("BBB   SSS  III")

	print("\nBSI(Bash Script Installer) Manager\nMade By: Julian Lopez\nVersion: " + str(settingsJson.version) + settingsJson.versionName )
	intDecision = 0
	listOfOptions = ["Set up a new computer","Settings","Exit"]

	while ( ( (intDecision < 1) or (intDecision > len(listOfOptions)) ) ):
			try:
				print("\nWhat do you want to do?")
				for i in range( len(listOfOptions) ):
					terminalColor.printBlueString( str(i+1) + ". " + listOfOptions[i] )
				intDecision = int(input())
				if ( (intDecision < 1) or (intDecision > len(listOfOptions)) ): terminalColor.printRedString("Invalid Input")
				elif ( listOfOptions[intDecision-1] == "Exit"): break #Exit program
				elif ( listOfOptions[intDecision-1] == "Set up a new computer"):
					intDecision = 0   
					BSISelector()
				elif ( listOfOptions[intDecision-1] == "Settings"):
					intDecision = 0   
					Settings()
				else:
					intDecision = 0    
			except Exception as e:
				if e == SystemExit: sys.exit()
				intDecision = 0
				terminalColor.printRedString("Invalid Input")
Exemplo n.º 29
0
def BSISelector():
	#Initializing variables
	listOfAllBSI = ["System", "Game", "Wine", "Office"]
	listOfCommands = ["Install Selected", "Reset Selection", "Cancel"]
	if "System" in settingsJson.installedBSIs: listOfSelectedBSI=[]
	else: listOfSelectedBSI=["System"]
	intDecision = 0
	hasSelectedBSIs = False

	while not hasSelectedBSIs:
		try:
			#Displays options for user to select
			print("\nWhat BSI(Bash Script Installer) packages do you want to install?")
			if settingsJson.dummyBSIInstall: terminalColor.printRedString("Dummy Install Mode is Active")
			for i in range( len(listOfAllBSI) ):
				if (listOfAllBSI[i] in settingsJson.installedBSIs ): terminalColor.printYellowString( str(i+1) + ". " + listOfAllBSI[i] + " BSI(v" + str(settingsJson.installedBSIVersions[i]) + " already installed on " + str(settingsJson.datesOfInstalls[i]) + ")" )
				elif (listOfAllBSI[i] in listOfSelectedBSI ): terminalColor.printGreenRegString( str(i+1) + ". " + listOfAllBSI[i] + " BSI" )                
				else: terminalColor.printBlueString( str(i+1) + ". " + listOfAllBSI[i] + " BSI" )
			for i in range( len(listOfCommands) ):
				terminalColor.printBlueString( str(i+1+len(listOfAllBSI) ) + ". " + listOfCommands[i])
			
			#get user input
			intDecision = int(input())
			
			#find out what what user wanted
			if ( (intDecision < 1) or (intDecision > (len(listOfOptions) + len(listOfAllBSI) + 1 ) ) ): terminalColor.printRedString("Invalid Input")
			elif( intDecision <= len(listOfAllBSI) ):#Has selected a BSI
				
				#Display info on selected BSI
				CurrentBSI = listOfAllBSI[intDecision-1] + "BSI"
				print("\n" + listOfAllBSI[intDecision-1] + " BSI" ) #Name of BSI
				print(eval( listOfAllBSI[intDecision-1] + "BSIComments" ) ) #BSI comments
				CurrentBSIComments = "Installs: "
				BSIDownloadSources = ["toDownloadAPT", "toDownloadSnap", "toDownloadAdditional"]
				for i in BSIDownloadSources:
					currentDownloadList = eval( CurrentBSI + i) 
					if len(currentDownloadList) > 0 and CurrentBSIComments == "Installs: " : CurrentBSIComments = CurrentBSIComments + ', '.join(currentDownloadList)
					elif len(currentDownloadList) > 0: CurrentBSIComments = CurrentBSIComments + ", " + ', '.join(currentDownloadList)
				print( CurrentBSIComments ) #BSI downloads
				print(eval( listOfAllBSI[intDecision-1] + "BSIChanges" ) ) #BSI Changes
				if not(listOfAllBSI[intDecision-1] == "System") and not(listOfAllBSI[intDecision-1] in settingsJson.installedBSIs) :
					
					#Ask if wants to download BSI
					print("\nDo You want to install this BSI onto this computer?[Yes/No]")
					userYesNo=str(input())
					if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"):
						if( not (listOfAllBSI[intDecision-1] in listOfSelectedBSI)): listOfSelectedBSI.append(listOfAllBSI[intDecision-1])
					elif(userYesNo.lower() == "no") or (userYesNo.lower() == "n"):
						if(listOfAllBSI[intDecision-1] in listOfSelectedBSI): listOfSelectedBSI.remove(listOfAllBSI[intDecision-1])
			elif( intDecision <= len(listOfCommands) + len(listOfAllBSI) ):
				commandSelection = intDecision-1-len(listOfAllBSI)

				#Install Selected BSIs
				if( commandSelection == 0 ):
					print("\nDo You want to install these BSIs onto this computer?[Yes/No]")
					for i in listOfSelectedBSI: terminalColor.printGreenRegString(i + " BSI")
					userYesNo=str(input())
					if(userYesNo.lower() == "yes") or (userYesNo.lower() == "y"):
						installSelectedBSIs(listOfSelectedBSI)
						hasSelectedBSIs = True
				#Reset Selection
				elif( commandSelection == 1 ):
					listOfSelectedBSI=["System"]
				
				#Cancel
				elif( commandSelection == 2 ):
					hasSelectedBSIs = True
		except:
			terminalColor.printRedString("Invalid Input")
Exemplo n.º 30
0
def unitEditOptions(responseJson, unitID): #unit options user is given
    intDecision = 0
    listOfOptions =[". Edit Entry", ". Upload New Photo", ". Download Unit Photos", ". Download Unit Label", ". Download Unit PDF", ". Delete Unit", ". Exit"]
    while ( (intDecision < 1 ) or (intDecision > len(listOfOptions)) ):
        try:
            printUnitInfo(responseJson, unitID)
            print("\nWhat do you want to do with this unit?")
            for i in range( len(listOfOptions) ): terminalColor.printBlueString( str(i+1) + listOfOptions[i] )
            intDecision = int(input())
            if ( (intDecision < 1) or (intDecision > len(listOfOptions)) ): terminalColor.printRedString("Invalid Input")
            elif ( listOfOptions[intDecision-1] == ". Exit"): break
            elif ( listOfOptions[intDecision-1] == ". Edit Entry"):
                intDecision = 0
                responseJson = unitEditEntry(responseJson, "Editing Existing Unit")
            elif ( listOfOptions[intDecision-1] == ". Upload New Photo"):
                intDecision = 0
                uploadNewPhoto(unitID)
            elif ( listOfOptions[intDecision-1] == ". Delete Unit"):
                if deleteUnit(unitID): terminalColor.printGreenString("Unit Deleted")
                else: intDecision = 0
            elif ( listOfOptions[intDecision-1] == ". Download Unit Photos"):
                intDecision = 0
                try:
                    unitInfo = responseJson["unitInfo"]
                    if unitInfo["Photo_URL"] == "https://hardware-donations-database-gamma.s3-us-west-1.amazonaws.com/Misc_Items/noPhotoFound.png":
                        terminalColor.printRedString("No unit photos uploaded")
                    else: downloadUnitPhoto(responseJson)
                except:
                    terminalColor.printRedString("Unable to download unit photos")
            elif ( listOfOptions[intDecision-1] == ". Download Unit Label"):
                intDecision = 0
                try:
                    downloadUnitLabel(unitID)
                except:
                    try:
                        createNewUnitLabel(unitID)
                        downloadUnitLabel(unitID)
                    except:
                        terminalColor.printRedString("Unable to download unit label")
            elif ( listOfOptions[intDecision-1] == ". Download Unit PDF"):
                intDecision = 0
                try:
                    downloadUnitPDF(unitID)
                except:
                    try:
                        createNewUnitPDF(unitID, responseJson)
                        downloadUnitPDF(unitID)
                    except:
                        terminalColor.printRedString("Unable to download unit PDF")
        except:
            intDecision = 0
            terminalColor.printRedString("Invalid Input")