Skip to content
This repository was archived by the owner on May 5, 2024. It is now read-only.

Commit 8f59e2b

Browse files
committed
yeah
1 parent b3303eb commit 8f59e2b

File tree

8 files changed

+208
-39
lines changed

8 files changed

+208
-39
lines changed

config.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Section1]
2+
option1 = Value1
3+
option2 = Value2
4+
5+
[Section2]
6+
option3 = Value3
7+
option4 = Value4
8+
-1.1 KB
Binary file not shown.
-1.96 KB
Binary file not shown.
-1.96 KB
Binary file not shown.

python/shell.py

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import os
22
import subprocess
3-
from towii import pydata1,pydata2
43
import tkinter
54
from tkinter import messagebox
5+
from towii import pydata1, pydata2
66

77

88
def print_greetings():
99
'''
1010
Print a welcome message to the user.
1111
'''
12-
print("thanks for using PythonicShell!")
12+
print("Thanks for using PythonicShell!")
1313
print("Version 1.0")
1414

15+
1516
def print_help():
1617
print("Here are the available commands:")
1718
print("cd <directory>: Change current working directory to <directory>")
@@ -31,56 +32,65 @@ def mkdir():
3132
print("Directory '%s' created successfully." % directory_name)
3233
except OSError as error:
3334
print("Error creating directory '%s': %s" % (directory_name, error))
35+
36+
3437
def editfile():
3538
'''
3639
Edit a file in the current working directory.
3740
'''
3841
filename = input("Enter the name of the file to edit: ")
3942
path = os.path.join(os.getcwd(), filename)
40-
if 'path' == None:
43+
if not os.path.exists(path):
4144
open(filename, 'w')
4245

43-
if not 'path' == None:
44-
try:
45-
subprocess.run(["nano", path])
46-
print("editing file!", filename)
47-
except OSError as error:
48-
print("Error editing file '%s': %s" % (filename, error))
46+
try:
47+
subprocess.run(["nano", path])
48+
print("Editing file:", filename)
49+
except OSError as error:
50+
print("Error editing file '%s': %s" % (filename, error))
51+
52+
4953
def senddata():
50-
message = input()
51-
pydata1.send(message.encode())
54+
message = input("Enter the message to send: ")
55+
pydata1.send(message.encode('utf-8'))
56+
57+
5258
def StartOS():
5359
subprocess.Popen('PythonicOS.exe')
5460

61+
5562
def my_shell():
5663
print_greetings()
5764

58-
while True:
59-
command = input(f"{os.getcwd()} $ ")
60-
tokens = command.split()
65+
while True:
66+
command = input(f"{os.getcwd()} $ ")
67+
tokens = command.split()
68+
69+
if len(tokens) == 0:
70+
continue
6171

62-
if len(tokens) == 0:
63-
continue
64-
if tokens[0] == "cd":
65-
if len(tokens) > 1:
66-
os.chdir(tokens[1])
72+
if tokens[0] == "cd":
73+
if len(tokens) > 1:
74+
os.chdir(tokens[1])
75+
else:
76+
print("cd: missing operand")
77+
elif tokens[0] == "help":
78+
print_help()
79+
elif tokens[0] == "sd":
80+
senddata()
81+
elif tokens[0] == "exit":
82+
break
83+
elif tokens[0] == "help":
84+
print_greetings()
85+
elif tokens[0] == "edit":
86+
editfile()
87+
elif tokens[0] == "start":
88+
StartOS()
89+
elif tokens[0] == "time":
90+
subprocess.call(['python', 'python/time.py'])
6791
else:
68-
print("cd: missing operand")
69-
elif tokens[0] == "help":
70-
print_help()
71-
elif tokens[0] == "sd":
72-
senddata()
73-
elif tokens[0] == "exit":
74-
break
75-
elif tokens[0] == "help":
76-
print_greetings()
77-
elif tokens[0] == "edit":
78-
editfile()
79-
elif tokens[0] == "start":
80-
StartOS()
81-
82-
else:
83-
print(f"{tokens[0]}: command not found")
92+
print(f"{tokens[0]}: command not found")
93+
8494

8595
if __name__ == "__main__":
8696
my_shell()

python/time.py

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import time
2+
import os
3+
import time
4+
import os
5+
import sys
6+
7+
def clear_screen():
8+
# Clear the console screen
9+
os.system('cls' if os.name == 'nt' else 'clear')
10+
11+
def kbhit():
12+
# Check if a key is pressed
13+
if os.name == 'nt':
14+
import msvcrt
15+
return msvcrt.kbhit()
16+
else:
17+
import termios
18+
import fcntl
19+
import select
20+
# Set stdin file descriptor to non-blocking mode
21+
fd = sys.stdin.fileno()
22+
old_attr = termios.tcgetattr(fd)
23+
new_attr = old_attr[:]
24+
new_attr[3] = new_attr[3] & ~termios.ICANON & ~termios.ECHO
25+
termios.tcsetattr(fd, termios.TCSANOW, new_attr)
26+
old_flags = fcntl.fcntl(fd, fcntl.F_GETFL)
27+
fcntl.fcntl(fd, fcntl.F_SETFL, old_flags | os.O_NONBLOCK)
28+
29+
try:
30+
# Check if there is any input available
31+
_, _, _ = select.select([sys.stdin], [], [], 0)
32+
return True
33+
except:
34+
return False
35+
finally:
36+
# Restore stdin back to blocking mode
37+
termios.tcsetattr(fd, termios.TCSAFLUSH, old_attr)
38+
fcntl.fcntl(fd, fcntl.F_SETFL, old_flags)
39+
40+
def display_clock():
41+
while True:
42+
# Clear the screen before displaying the time
43+
clear_screen()
44+
# Get the current time
45+
current_time = time.strftime("%H:%M:%S")
46+
47+
# ASCII art digits for each number
48+
digits = {
49+
"0": [" 8888 ",
50+
"88 88",
51+
"88 88",
52+
"88 88",
53+
" 8888 "],
54+
"1": [" 88 ",
55+
" 888 ",
56+
" 88 ",
57+
" 88 ",
58+
"888888"],
59+
"2": [" 8888 ",
60+
" 88",
61+
" 8888 ",
62+
"88 ",
63+
"888888"],
64+
"3": [" 8888 ",
65+
" 88",
66+
" 8888 ",
67+
" 88",
68+
" 8888 "],
69+
"4": ["88 88",
70+
"88 88",
71+
"888888",
72+
" 88",
73+
" 88"],
74+
"5": ["888888",
75+
"88 ",
76+
"8888 ",
77+
" 88",
78+
"8888 "],
79+
"6": [" 8888 ",
80+
"88 ",
81+
"8888 ",
82+
"88 88",
83+
" 8888 "],
84+
"7": ["888888",
85+
" 88",
86+
" 88 ",
87+
" 88 ",
88+
" 88 "],
89+
"8": [" 8888 ",
90+
"88 88",
91+
" 8888 ",
92+
"88 88",
93+
" 8888 "],
94+
"9": [" 8888 ",
95+
"88 88",
96+
" 88888",
97+
" 88",
98+
" 8888 "],
99+
":": [" ",
100+
" ++ ",
101+
" ",
102+
" ++ ",
103+
" "],
104+
" ": [" ",
105+
" ",
106+
" ",
107+
" ",
108+
" "],
109+
"AM": [" ",
110+
" 8888 ",
111+
"88 88",
112+
"88 88",
113+
" "],
114+
"PM": [" ",
115+
"88 88",
116+
"88 88",
117+
" 8888 ",
118+
" "]
119+
}
120+
121+
122+
# Display the time
123+
lines = ["", "", "", "", ""]
124+
for digit in current_time:
125+
if digit in digits:
126+
for i, line in enumerate(digits[digit]):
127+
lines[i] += line + " "
128+
else:
129+
for i in range(5):
130+
lines[i] += " "
131+
132+
# Print the time in the center of the screen
133+
print("\n" + "-" * 30)
134+
for line in lines:
135+
print(line)
136+
print("-" * 30)
137+
138+
139+
140+
# Check if the user pressed the 'Q' key
141+
if kbhit():
142+
key = sys.stdin.read(1).upper()
143+
if key == 'Q':
144+
break
145+
146+
# Wait for 1 second
147+
time.sleep(1)
148+
149+
# Run the clock
150+
display_clock()

python/towii.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
# if you want to make your own sockets for the desktop or have a literal standard for data transfer
88
# import socket thenn call socket.socketpair() with the names of the socket like pydata1, pydata2 = socket.socketpair()
99
#
10+
# do note that pydata1 is the socket that is used to recive data from the desktop and should allways be left open
11+
# pydata2 is the socket that is used to send data to the desktop and should allways be left open
12+
# if you want to send data to the desktop use pydata2.send(data.encode())
1013
#
11-
#
12-
#
13-
#
14-
#
14+
# if you want to recive data from the desktop use data = pydata2.recv(1024).decode()
15+
# you can only recive from pydata1, and only send from pydata2
1516
#
1617
#
1718
#

0 commit comments

Comments
 (0)