-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpreter.py
More file actions
230 lines (182 loc) · 7.36 KB
/
Copy pathinterpreter.py
File metadata and controls
230 lines (182 loc) · 7.36 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import os
import shutil
import colorama
import time
import keyboard
import numpy as np
import cv2
from colorama import Fore, Back, Style
colorama.init(autoreset=True)
dir_path = os.path.dirname(os.path.realpath(__file__))
command_list = []
defenition_list = []
def add_command(c):
return command_list.append(c)
def add_def(d):
return defenition_list.append(d)
# adding commands to the command list
'''
System Types:
1. -a = about shell
2. -h = shell commands
3. --file -a = file specific commands
'''
# All True Type System Variables
ShellConfig = {"-a": "-a", "-h": "-h", "--file -a": "--file -a"}
# Commands List
add_command(f"{ShellConfig['-a']} commands")
add_command(f"{ShellConfig['-h']} txt [name] [folder]")
add_command(f"{ShellConfig['--file -a']} make [name] [extension] [folder]")
add_command(f"{ShellConfig['-h']} list files")
add_command(f"{ShellConfig['-h']} info")
add_command(f"{ShellConfig['--file -a']} move [file path] [new file path]")
add_command(f"{ShellConfig['-h']} quit shell -s")
add_command(f"{ShellConfig['-h']} make dir [name]")
add_command(f"{ShellConfig['--file -a']} del [path]")
add_command(f"{ShellConfig['-h']} del dir [path]")
add_command(f"{ShellConfig['-h']} cd dir [path]")
add_command("-h camera")
add_command("-h chk disk usg")
add_command("-h shout [text]")
add_command("-h virt memory prcs -s")
add_command("--file -a write [path]")
add_command("--file -a read [path]")
add_command("-h --foo-printer [amount] [input]")
# functions to call
add_command("help()")
# adding defenitions to the defenitions list
add_def(f"{ShellConfig['-a']} commands: shows all commands")
add_def(f"{ShellConfig['-h']} txt [name] [folder]: creates a text file")
add_def(
f"{ShellConfig['--file -a']} make [name] [extension] [folder]: creates any type of file")
add_def(
f"{ShellConfig['-h']} list files: lists all of the files/directories from the current directory")
add_def(f"{ShellConfig['-h']} info: gives a brief description about the shell")
add_def(
f"{ShellConfig['--file -a']} move [file path] [new file path]: moves an existing file to another directory")
add_def(f"{ShellConfig['-h']} quit shell -s: quits the shell")
add_def(f"{ShellConfig['-h']} make dir [name]: creates a new directory")
add_def(f"{ShellConfig['--file -a']} del [path]:")
add_def(f"{ShellConfig['-h']} del dir [path]: deletes a folder")
add_def("help(): gives a description for each commands in the shell")
add_def(
f"{ShellConfig['-h']} cd dir [path]: changes current directory to specified path")
add_def("-h camera: opens webcam, press 'q' to quit session")
add_def("-h chk disk usg: gives statistics on the usage of your system's disk")
add_def("-h shout [text]: echos some text to the screen")
add_def("-h virt memory prcs -s: gives statistics on your virtual memory's processes")
add_def("--file -a write [path]: writes to a file")
add_def("--file -a read [path]: reads a file")
add_def("-h --foo-printer [amount] [input]: prints ascii value of foo input, and translates back to character based on foo input")
'''
Shell User Properties
'''
user_list = ["default"]
def all_commands():
for command in command_list:
# Shows a list of all the commands, sorted by number(least to greatest).
print(f"{command_list.index(command)}: {command}")
def make_text_file(folder, name):
if os.path.exists(folder):
file = open(f"{folder}/{name}.txt", "a")
file.close()
else:
os.mkdir(folder)
file = open(f"{folder}/{name}.txt", "a")
file.close()
def make_file(folder, name, extension):
if os.path.exists(folder):
file = open(f"{folder}/{name}.{extension}", "a")
file.close()
else:
os.mkdir(folder)
file = open(f"{folder}/{name}.{extension}", "a")
file.close()
def current_directories():
for root, dirs, files in os.walk("C:\\Users\\User\Documents"):
for filename in files:
print(Fore.CYAN + " " + str(filename))
for d in dirs:
print(Fore.CYAN + " " + str(d))
def make_dir(new):
path = os.path.join(dir_path, new)
os.mkdir(path)
print(f"new directory '{new}' has been made.")
def info():
print(f"This is a command line interface. '#shellprcsr~' is for multi-purpose use.")
def move_file(file_path, new_file_path):
try:
shutil.move(f"{file_path}", f"{new_file_path}")
print(Fore.CYAN + "file has been moved successfully.")
except:
print(Fore.YELLOW +
f"'{file_path}' is an invalid directory, and or the new file path is invalid.")
def del_file(file_path):
if os.path.exists(file_path):
shutil.rmtree(file_path)
time.sleep(0.1)
print(Fore.CYAN + "file successfully deleted (execution in 0.1 seconds)")
else:
print(Fore.YELLOW + "This file path does not exist")
def del_folder(path):
if os.path.exists(path):
os.remove(path)
time.sleep(0.1)
print(Fore.CYAN + "folder successfully deleted (execution in 0.1 seconds)")
else:
print(Fore.YELLOW + "This folder path does not exist")
def call_help():
for defenition in defenition_list:
# Shows all defenitions for commands, sorted by number(least to greatest).
print(f"{defenition_list.index(defenition)}: {defenition}")
def change_dir(path):
if os.path.exists(path):
shutil.move(f"{dir_path}", f"{path}")
else:
print(Fore.YELLOW + "This directory does not exist")
def write_file(path):
x = 0
width = os.get_terminal_size().columns
print(Back.CYAN + Fore.BLACK + "File Writer".center(width))
if os.path.exists(path):
with open(path, "a") as file:
while True:
x += 1
gnu = input(f"{x} ")
file.write(gnu)
file.write("\n")
if keyboard.is_pressed('q'):
break
else:
print(Fore.YELLOW + "This path does not exist, please try again.")
def read_file(path):
width = os.get_terminal_size().columns
print(Back.CYAN + Fore.BLACK + "File Reader".center(width))
if os.path.exists(path):
with open(path, "r") as file:
print(file.read())
else:
print(Fore.YELLOW + "This path does not exist, please try again.")
def camera():
cap = cv2.VideoCapture(0)
face_cascade = cv2.CascadeClassifier(
cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier(
cv2.data.haarcascades + 'haarcascade_eye.xml')
while True:
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 5)
roi_gray = gray[y:y+w, x:x+w]
roi_color = frame[y:y+h, x:x+w]
eyes = eye_cascade.detectMultiScale(roi_gray, 1.3, 5)
for (ex, ey, ew, eh) in eyes:
cv2.rectangle(roi_color, (ex, ey),
(ex + ew, ey + eh), (0, 255, 0), 5)
cv2.imshow('frame', frame)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()