@Kapil3sh/

nach - OS

Python

Its dummy program handler mimicking an OS

fork
loading
Files
  • main.py
  • 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
102
103
104
105
106
107
108
109
110
#System Imports
import time,replit,datetime,requests
now = datetime.datetime.now()

#Runtime Imports (Programs)
import calc,echo,dictionary,documents

#Runtime variables
kernel_running = True
kernel_cmd = ""
kernel_name = "nach-OS"
kernel_build = "36"

def exception_handler(error_type, source):
  if error_type == "warning":
    print("WARNING: " + source)
  elif error_type == "program_error":
    print("PROGRAM ERROR: " + source)
  elif error_type == "system_error":
    print("SYSTEM ERROR: " + source)
  elif error_type == "fatal_program_error":
    print("FATAL PROGRAM ERROR: " + source)
  elif error_type == "fatal_system_error":
    print("FATAL SYSTEM ERROR: " + source)

def program_handler(program):

  if program == "calc":
    calculator_program = calc.calcu()
    calculator_program.run_calc()

  if program == "echo":
    x = input("echo ")
    print (x)

  """if program == "stopwatch":
    stopwatch_program = stopwatch.
    stopwatch_program.run_stopwatch(kernel_build)"""

  if program == "dictionary":
    print()
    exception_handler("program_error", "Dictionary is temporarily disabled due to many bugs.")
    print()
    #dictionary_program = dictionary.
    #dictionary_program.run_dictionary()

  #if program == "connect4":
    #connect4_program = connect4.__package__
    #connect4_program.run_connect4(kernel_build)

  if program == "documents":
    documents_program = documents.document
    documents_program.__name__

def command_parser(command):
  if command == "help":
    print()
    print("=========")
    print("Help Menu")
    print("=========")
    print("help - Display this menu")
    print("run <program> - Run a program")
    print("programs - List all programs")
    print("clear - Clear the console")
    print()

  if command[:4] == "run ":
    program_handler(command[4:])

  if command == "programs":
    print()
    print("========")
    print("Programs")
    print("========")
    print("calc, echo, stopwatch, dictionary, connect4")
    print()

  if command == "clear":
    replit.clear()
    
    print("Running " + kernel_name + " Build " + kernel_build + " On " + str(now.day) + "/" + str(now.month) + "/" + str(now.year))
    print("Use 'help' to list all available commands.")
    print()

  if command[:7] == "config ":
    configuration_handler(command[7:])

  if command == "this_is_canada":
    print("(We aren't from canada by the way)")
    url = 'https://pastebin.com/raw/7bBdsfSK' # url of paste
    r = requests.get(url) # response will be stored from url
    content = r.text  # raw text from url
    print(content) # prints content

def command_handler():
  kernel_cmd = input("> ")
  command_parser(kernel_cmd)

def main():
  replit.clear()

  print("Running " + kernel_name + " Build " + kernel_build + " On " + str(now.day) + "/" + str(now.month) + "/" + str(now.year))
  print("Use 'help' to list all available commands.")
  print()
  
  while kernel_running:
    command_handler()

main()