October 22, 2024
Chicago 12, Melborne City, USA
python

Working on Python app that uses terminal. implementing profile system to allow more user control or admin powers, I'm stumped


Ah im back again. apparently stack overflow doesnt like me sad face well nonetheless i need some help this is gonna be a long one so strap in (sorry). im creating a app that uses the built in terminal to display it. im implimenting a profile system that will help. the user will have 5 allowed. including ADMIN which will be hidden and accesses by typeing SUPERADMIN when prompted which profile to use. i dont need anybody to do my code for me. only the part ill tell you is required. i am a beginner coder so i know my code is probably sloppy. im completly self taught. heres my goal

Check for profiles.
if profile exists display.
if not prompt user to setup.
setup. i have the setup in place and functioning
[now is where im stumped]
Reload back to start. find profile. READ DATA. find the data i need (using basically ctrl+f but using filesystem and copying that data), save it to a variable so i can call it where i need it. continue.

heres my code

import os
import pathlib as path

userprofile = "none"
running = True
def Prof_Setup(profile):
    print("Welcome to profile setup. lets first get your name")
    name = input("Name (10 letter max.): ")
    print("Great! now how about age")
    age = input("Age (max 2 numbers): ")
    print("How tall?")
    height_feet = input("Height(feet): ")
    height_inches = input("Height(inches): ")
    print("Setting up...")
    fwrite = open('/workspaces/TurbOS/Turbos/config/profiles/PROF' + profile + '.cfig', 'x')
    fwrite.write("name:" + name + "\nage:" + age + "\nheight:" + height_feet + "'" + height_inches)
    fwrite.close
    f = open('/workspaces/TurbOS/Turbos/config/profiles/PROF1.cfig', 'r')
    print(f)
    print("Prof above ^^^^^")
    
def ReadProfData(profile):
    

while running == True:
    print("loading TurbOS...")
    os.system('clear')
    print("Welcome to TURBOS were checking for profiles...")
    print()
    if os.path.exists(path="/workspaces/TurbOS/Turbos/config/profiles/PROF1.cfig") == True:
        print("Prof exists")

    elif os.path.exists(path="/workspaces/TurbOS/Turbos/config/profiles/PROF1.cfig") == False:
        print("No profile exists. setup?")
        yn = input("Y/N: ")
    if yn == "Y":
        Prof_Setup("1")
        yn = "N"
    elif yn == "N":
        yn = "N"
        running = False

im going to change the inputs later and figure out how to make an encryption system thats randomized and reads what it needs to tell the system. ill also place a warning saying that im self taught so theres no guarentee its safe. just for the pleasure of using it. im using github codespace as its what i use to code. and my computer is broken so im using my school chromebook and i hate hate hate chromebooks man but its what im stuck with for now so. if anybody has any pointers lmk please

i tryed using import pathlib as path but for some reason when i use the period to use the read_file function it tells me it needs an expresion. which i then give [read_file()] (the brackets simply seperate the () from eachother. i dont add that to the code.) and it doesnt do anything. i need some help sad face



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video