Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Commit

Permalink
[3.1] Dynamic program loading from programs/*
Browse files Browse the repository at this point in the history
  • Loading branch information
jcxldn committed Sep 23, 2019
1 parent fcc633c commit 24602de
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
2 changes: 1 addition & 1 deletion internal/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class notes:
name = ("PyOS")
ver = ("3.0-base-master")
ver = ("3.1-base-master")
author = ("Prouser123")
helpmsg = ("Type 'help' for a list of commands.")

Expand Down
24 changes: 4 additions & 20 deletions internal/runCommand.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
# PyOS
# Made for Python 2.7
# internal/runCommand.py

# Import Libraries

import sys
# PyOS Scripts

import internal.extra
import internal.update.runscript
# External Programs
import programs.calculator
import programs.sysinfo
import programs.example
import programs.fizzbuzz
import programs.ls
import programs.pwd
import programs.cp
import programs.mv
import programs.mkdir
import programs.downloader
import programs.snake
import programs.showallcolors

# Import programs (see programs/__init__.py)
import programs

# Setup colors
import internal.colors
Expand Down
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def cmd_loop():
#print(internal.extra.colors.BOLD + internal.extra.notes.name + " " + internal.extra.notes.ver + " - " + internal.extra.colors.WARNING + "Made for Python 2.7" + internal.extra.colors.ENDC)
print(Colors.Bold(internal.extra.notes.name + " " + internal.extra.notes.ver + " - ") + Colors.Warning("Made for Python 2.7"))
# Print python version
print ("Running on Python " + internal.extra.system.pyVer)
print("Running on Python " + internal.extra.system.pyVer)
print(str(len(internal.runCommand.getValidCommands())) + " programs detected.")
print(internal.extra.notes.helpmsg)
cmd_loop()
10 changes: 10 additions & 0 deletions programs/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from importlib import import_module as __import_module
from os import path as __path

import glob as __glob

__modules = __glob.glob(__path.join(__path.dirname(__file__), "*.py"))
__files = [ __path.basename(__f)[:-3] for __f in __modules if __path.isfile(__f) and not __f.endswith('__init__.py')]

for __i in __files:
__import_module('.' + __i, __name__)

0 comments on commit 24602de

Please sign in to comment.