mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
init
This commit is contained in:
parent
6d23791296
commit
1825ace9a4
103
commands.py
Normal file
103
commands.py
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
from __future__ import print_function, unicode_literals
|
||||||
|
from PyInquirer import prompt, print_json
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
|
#already ccrerrated account through website, has to login
|
||||||
|
def yesorno(question):
|
||||||
|
questions = [
|
||||||
|
{
|
||||||
|
'type': 'input',
|
||||||
|
'name': 'response',
|
||||||
|
'message': question,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
answers = prompt(questions)
|
||||||
|
if(answers["response"] == "y"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def login():
|
||||||
|
#enter username
|
||||||
|
#enter password
|
||||||
|
questions = [
|
||||||
|
{
|
||||||
|
'type': 'input',
|
||||||
|
'name': 'webmail',
|
||||||
|
'message': 'What\'s TJ Webmail',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'password',
|
||||||
|
'name': 'password',
|
||||||
|
'message': 'Password?',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
user = prompt(questions)
|
||||||
|
#reading from json of users (replace w GET to database) to check if user is registered
|
||||||
|
with open('users.json', 'r') as json_file:
|
||||||
|
data = json.load(json_file)
|
||||||
|
for i in range(len(data)):
|
||||||
|
if(user["webmail"] == data[i]["webmail"] and user["password"]) == data[i]["password"]:
|
||||||
|
print("Logged in!")
|
||||||
|
return data[i]
|
||||||
|
print("Error in your submission. Please re-enter")
|
||||||
|
return None
|
||||||
|
|
||||||
|
#did not create account through website, has to signup/login
|
||||||
|
def signup():
|
||||||
|
|
||||||
|
questions = [
|
||||||
|
{
|
||||||
|
'type': 'input',
|
||||||
|
'name': 'first-name',
|
||||||
|
'message': 'What\'s your first name',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'input',
|
||||||
|
'name': 'last-name',
|
||||||
|
'message': 'What\'s your last name?',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'list',
|
||||||
|
'name': 'grade',
|
||||||
|
'message': 'Grade?',
|
||||||
|
'choices':["9","10","11","12"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'input',
|
||||||
|
'name': 'webmail',
|
||||||
|
'message': 'What\'s TJ Webmail?',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'password',
|
||||||
|
'name': 'password',
|
||||||
|
'message': 'Password?',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
user = prompt(questions)
|
||||||
|
user["classes"] = []
|
||||||
|
with open('users.json', 'r') as json_file:
|
||||||
|
data = json.load(json_file)
|
||||||
|
data.append(user)
|
||||||
|
open("users.json", "w").write(str(json.dumps(data)))
|
||||||
|
|
||||||
|
def setup(user):
|
||||||
|
#Read classes/assignenments and setup directory:
|
||||||
|
#SkoolOS/Math/Week1
|
||||||
|
for c in user["classes"]:
|
||||||
|
os.makedirs(c)
|
||||||
|
for a in user["classes"][c]:
|
||||||
|
os.makedirs(c + "/" + a)
|
||||||
|
|
||||||
|
|
||||||
|
def start():
|
||||||
|
if(os.path.exists(".login.txt") == True):
|
||||||
|
b = yesorno("Do you have a SkoolOS account?(y/N)")
|
||||||
|
if(b):
|
||||||
|
user = login()
|
||||||
|
if(user != None):
|
||||||
|
setup(user)
|
||||||
|
else:
|
||||||
|
user = signup()
|
|
@ -1,20 +0,0 @@
|
||||||
from __future__ import print_function, unicode_literals
|
|
||||||
from PyInquirer import prompt, print_json
|
|
||||||
import os
|
|
||||||
|
|
||||||
def login():
|
|
||||||
questions = [
|
|
||||||
{
|
|
||||||
'type': 'input',
|
|
||||||
'name': 'user_name',
|
|
||||||
'message': 'What\'s your first name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': 'password',
|
|
||||||
'name': 'passwd',
|
|
||||||
'message': 'Password?',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
answers = prompt(questions)
|
|
||||||
print_json(answers) # use the answers as input for your app
|
|
99
run.py
99
run.py
|
@ -1,94 +1,21 @@
|
||||||
from __future__ import print_function, unicode_literals
|
from __future__ import print_function, unicode_literals
|
||||||
from PyInquirer import prompt, print_json
|
from PyInquirer import prompt, print_json
|
||||||
|
from commands import start
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
my_parser = argparse.ArgumentParser(prog='skool', description='Let SkoolOS control your system', epilog="Try again")
|
||||||
|
my_parser.add_argument('--init', action="store_true") #returns true if run argument
|
||||||
|
args = my_parser.parse_args()
|
||||||
|
|
||||||
|
outputs = vars(args)
|
||||||
|
if(outputs['init']):
|
||||||
|
start()
|
||||||
|
|
||||||
|
|
||||||
#list of classes for student; substitute this for Database
|
|
||||||
classes = {
|
|
||||||
"Math": ["week1_hw", "week2_hw", "week3_hw", "unit3_quiz"],
|
|
||||||
"English":["journal1", "journal2", "journal3"]
|
|
||||||
}
|
|
||||||
|
|
||||||
#already ccrerrated account through website, has to login
|
|
||||||
def yesorno(question):
|
|
||||||
questions = [
|
|
||||||
{
|
|
||||||
'type': 'input',
|
|
||||||
'name': 'response',
|
|
||||||
'message': question,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
answers = prompt(questions)
|
|
||||||
if(answers["response"] == "yes"):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def login():
|
|
||||||
#enter username
|
|
||||||
#enter password
|
|
||||||
questions = [
|
|
||||||
{
|
|
||||||
'type': 'input',
|
|
||||||
'name': 'user_name',
|
|
||||||
'message': 'What\'s your first name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': 'password',
|
|
||||||
'name': 'passwd',
|
|
||||||
'message': 'Password?',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
answers = prompt(questions)
|
|
||||||
print(answers)
|
|
||||||
f = open(".login.txt", "w")
|
|
||||||
f.write(str(answers["user_name"]))
|
|
||||||
print_json(answers) # use the answers as input for your app
|
|
||||||
|
|
||||||
#did not create account through website, has to signup/login
|
|
||||||
def signup():
|
|
||||||
#
|
|
||||||
questions = [
|
|
||||||
{
|
|
||||||
'type': 'input',
|
|
||||||
'name': 'first-name',
|
|
||||||
'message': 'What\'s your first name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': 'password',
|
|
||||||
'name': 'last-name',
|
|
||||||
'message': 'Password?',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': 'list',
|
|
||||||
'name': 'last-name',
|
|
||||||
'message': 'Grade?',
|
|
||||||
'choices':["9","10","11","12"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': 'input',
|
|
||||||
'name': 'user_name',
|
|
||||||
'message': 'What\'s your first name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'type': 'password',
|
|
||||||
'name': 'passwd',
|
|
||||||
'message': 'Password?',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
answers = prompt(questions)
|
|
||||||
print(answers)
|
|
||||||
f = open(".login.txt", "w")
|
|
||||||
f.write(str(answers["user_name"]))
|
|
||||||
print_json(answers) # use the answers as input for your app
|
|
||||||
|
|
||||||
def setup():
|
|
||||||
#Read classes/assignenments and setup directory:
|
|
||||||
#SkoolOS/Math/Week1
|
|
||||||
|
|
||||||
if(os.path.exists(".login.txt") == False):
|
|
||||||
answer = yesorno("Do you have a SkoolOS account?")
|
|
||||||
login()
|
|
||||||
else:
|
|
||||||
print("Hello!")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
users.json
Normal file
1
users.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[{"first_name": "Raffu", "last_name": "Khondaker", "password": "password", "webmail": "2022rkhondak@tjhsst.edu", "classes": {"Math": ["week1_hw", "week2_hw", "week3_hw", "unit3_quiz"], "English": ["journal1", "journal2", "journal3"]}}]
|
Loading…
Reference in New Issue
Block a user