repl.it
@THEJOEMAN23/

WarhawkOS

Python

No description

fork
loading
Files
  • main.py
  • apps.py
  • loginInfo
  • loginInfo.bak
  • settings.py
  • systemInfo
  • systemInfo.bak
  • systemUtils.py
  • Packager files
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Text based OS by Warhawk947. Make sure to FORK the project to save your data!
# Copyright Warhawk947. All Rights Reserved.

from termcolor import colored
from sys import stdout
from systemUtils import systemUtils
import basehash
from time import sleep

loginFile = 'loginInfo'
systemFile = 'systemInfo'
loginInfo = {}
systemInfo = {}

hashFn = basehash.base36()

print(systemUtils.intStr(''))
sleep(111111)

def flush():
  stdout.flush()

def login():
  print('You are signed out. Please log in to continue.')
  while True:
    username = input('Username: ')
    passcode = input('Passcode: ') 
    if username == loginInfo['usr']:
      if passcode == loginInfo['psscd']:
        return 'TRUE'
      else:
        systemUtils.clear()
        print('Incorrect Passcode. Please try again.')
    else:
      systemUtils.clear()
      print('Incorrect Username. Please try again.')  
    

def setup():
  print('Welcome to Account Setup. You need to setup an account to continue.')
  username = input('Username: ')
  passcode = input('Passcode: ')
  systemUtils.clear()
  print('Welcome to Account Setup. You need to setup an account to continue.')
  print('Username: %s' % username)
  print('Passcode: %s' % ('*' * len(passcode)))
  while True:
    verify = input('Verify Passcode: ')
    if verify == passcode:
      systemUtils.clear()
      break

  return username, passcode, 'TRUE'



def saveLoginInfo():
  global hashFn
  with open(loginFile, 'w') as file:
    for key, value in loginInfo.items():
      file.write('%s=%s\n' % (key, hashFn.hash(value)))

def main():
  systemInfo = systemUtils.getSystemInfo()
  from apps import allApps
  appList = allApps.returnApps()
  
  print('Welcome, %s!' % loginInfo['usr'])
  if systemInfo['helpOnStart'] == 'TRUE':
    print('''Type @apps for apps, @settings for settings, @help for help, 
and @logout to logout. Type @<insert program name here> to run an app if you know its name.''')
  while True:
    cmd = input('>')
    if cmd.startswith('@'):
      program = cmd[1:]
      if program in appList:
        try:
          exec('allApps.%s()' % program)
        except Exception as e:
          print(colored('Error: The app returned an error. The error was %s' % e, 'red'))
      else:
        print(colored('Error: You don\'t have an app called %s' % program, 'red'))
      
    else:
      print(colored('Error: No @ beginning statement. Did you mean @%s?' % cmd, 'red'))


loginInfo = systemUtils.getLoginInfo()

if loginInfo['usr'] == 'PLACEHOLDER' and loginInfo['psscd'] == 'PLACEHOLDER':
  loginInfo['usr'], loginInfo['psscd'], loginInfo['loggedIn'] = setup()
  saveLoginInfo()

if loginInfo['loggedIn'] == 'FALSE':
  loginInfo['loggedIn'] = login()
  saveLoginInfo()
  systemUtils.clear()
  main()

else:
  main() # Here we go!
?