Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
app/__pycache__
app/__pycache__
2 changes: 2 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os.path
import pwd
import corelibs.colors
from utils.autodirectory import make_directory

# Config
version = "2022.927.1"
Expand All @@ -30,6 +31,7 @@ def start():
print(f"PyTerm - Beta Release [no version] {color.yellow}(Unstable){color.end}")
else: print(f"PyTerm - Beta Release v{version} {color.yellow}(Unstable){color.end}")
print(f"Running as PID: {pid}")
make_directory(user)


def listen_for_command(errorcode):
Expand Down
28 changes: 28 additions & 0 deletions app/utils/autodirectory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### NKA Development Organization 2022. For enquiries, contact <pybotdevs@outlook.com>

# Imports
import os
import os.path
import pwd


# Config
user = pwd.getpwuid(os.getuid())[0]


# Functions
def make_directory(username: str):
"""Makes app path in user's home directory if there is no app path. If there is, this is automatically skipped."""
default_path = f"/home/{username}"
if not os.path.isdir(f"{default_path}/pyterm"):
os.mkdir(f"{default_path}/pyterm") # Making main directory
open(f"{default_path}/pyterm/pytermrc", "x")
os.mkdir(f"{default_path}/pyterm/history")
open(f"{default_path}/pyterm/history/username_hist.txt", "x")
os.mkdir(f"{default_path}/pyterm/logs")
open(f"{default_path}/pyterm/logs/{username}_info.log", "x")
open(f"{default_path}/pyterm/logs/{username}_error.log", "x")


# Initialization
# make_directory(user)