11# __main__.py
22# Import
33# os for file commands and others, time for wait second, platform for os command, multiprocessing for CPU count
4- import os , time , platform , shutil , socket , getpass , multiprocessing , tkinter , sys
4+ import os , time , platform , shutil , socket , getpass , multiprocessing , tkinter , sys , ctypes
55import webbrowser as web # Webbrowser for openLink command
66import subprocess as sp # Subprocess for ping
77import datetime as dt # Datetime for date and time
@@ -34,8 +34,8 @@ def ping(host): # Ping a server
3434 command = ['ping' , param , '4' , host ] # Ping command
3535 return sp .call (command ) == 0 # Return text
3636
37- def fileExists (fileName ): # Check if file or directory exists
38- return os .path .exists (fileName )
37+ def fileExists (name ):
38+ return os .path .exists (name )
3939
4040def setupColor (): # Setup text and background color
4141 try :
@@ -136,12 +136,18 @@ def init():
136136 print ('mkfil Creates a file' )
137137 print ('netstat Displays protocol statistics and current TCP/IP network connections' )
138138 print ('notepad [Windows] Opens Windows Notepad' )
139+ print ('npm install Install npm package' )
140+ print ('npm update Update npm package' )
141+ print ('npm upgrade Upgrade npm package' )
139142 print ('openBinFil Opens a binary file' )
140143 print ('openFil Opens a file' )
141144 print ('openLink Opens a link in your browser' )
142145 print ('openWindow Opens a window' )
143146 print ('ping Pings a server with an IP address' )
147+ print ('pip install Installs pip package' )
148+ print ('pip install -U Updates pip package' )
144149 print ('print Displays messages you enter' )
150+ print ('prompt Changes the prompt' )
145151 print ('py [Windows] Opens Python\' s interpreter in cmd in a new window' )
146152 print ('pyver Displays Python version' )
147153 print ('rename Renames a file' )
@@ -155,6 +161,7 @@ def init():
155161 print ('terminate Exits the program' )
156162 print ('TASKKILL Kill or stop a running process or application.' )
157163 print ('time Also shows date and time' )
164+ print ('title [Windows] Changes the console title' )
158165 print ('tree Graphically displays the directory structure of a drive or path\n ' )
159166 elif cmd == 'help -a' or cmd == 'help --alt' : # Help
160167 print ('changelog Shows PyTerm\' s change log (../change.log)' )
@@ -186,13 +193,19 @@ def init():
186193 print ('mkfil Creates a file' )
187194 print ('netstat Displays protocol statistics and current TCP/IP network connections' )
188195 print ('notepad [Windows] Opens Windows Notepad' )
196+ print ('npm install Install npm package' )
197+ print ('npm update Update npm package' )
198+ print ('npm upgrade Upgrade npm package' )
189199 print ('openBinFil Opens a binary file' )
190200 print ('openFil Opens a file' )
191201 print ('openLink Opens a link in your browser' )
192202 print ('openWindow Opens a window' )
193203 print ('systeminfo Shows information about you computer' )
194204 print ('ping Pings a server with an IP address' )
195205 print ('print Displays messages you enter' )
206+ print ('prompt Changes the prompt' )
207+ print ('pip install Installs pip package' )
208+ print ('pip install -U Updates pip package' )
196209 print ('py [Windows] Opens Python\' s interpreter in cmd in a new window' )
197210 print ('pyver Displays Python version' )
198211 print ('rename Renames a file' )
@@ -205,6 +218,7 @@ def init():
205218 print ('terminate Exits the program' )
206219 print ('TASKKILL Kill or stop a running process or application.' )
207220 print ('time Also shows date and time' )
221+ print ('title [Windows] Changes the console title' )
208222 print ('tree Graphically displays the directory structure of a drive or path\n ' )
209223 elif cmd == 'help -h' or cmd == 'help --help' or cmd == 'help /?' :
210224 print ('Usage: help [-a]\n \n \n \n ' )
@@ -476,7 +490,7 @@ def init():
476490 window = tkinter .Tk () # Setup variable
477491 window .title (windowName ) # Set title
478492 window .mainloop () # Open
479- elif cmd == 'changePrompt' : # Change command prompt
493+ elif cmd == 'changePrompt' or cmd == 'prompt' : # Change command prompt
480494 print ('New prompt?' ) # Ask for new prompt
481495 prompt = input () # Get new prompt
482496 try : # Test code
@@ -593,7 +607,7 @@ def init():
593607 print (os .system ('netstat' ))
594608 elif cmd == 'diskpart' : # Diskpart
595609 if __os__ == 'Windows' : # Check if OS is Windows
596- os .system ('start cmd /c diskpart' ) # Open diskpart in cmd
610+ os .system ('diskpart' ) # Open diskpart in cmd
597611 else :
598612 print ('Error!, diskpart is only for Windows' ) # Not Windows
599613 elif cmd == 'TASKKILL' : # Force kill a task
@@ -609,6 +623,8 @@ def init():
609623 os .system ('start gnome-terminal python ' + input ())
610624 elif __os__ == 'Darwin' : # For Mac OS
611625 os .system ('start open -a Terminal python ' + input ())
626+ else :
627+ print ('OS is not recognized!' )
612628 except :
613629 print ('Error! Please try again!' )
614630 elif cmd == 'move' : # Move file
@@ -627,6 +643,39 @@ def init():
627643 os .system ('tree ' + str (input ())) # Output
628644 elif cmd == 'pyver' : # Python version
629645 print ('Python ' + platform .python_version ())
646+ elif cmd == 'npm install' : # Install package via npm
647+ print ('Package name?' )
648+ pkgName = input ()
649+ os .system ('npm install ' + pkgName )
650+ elif cmd == 'npm upgrade' or cmd == 'npm install -U' or cmd == 'npm update' : # Update/upgrade package via npm
651+ print ('Package name?' )
652+ pkgName = input ()
653+ os .system ('npm install ' + pkgName )
654+ elif cmd == 'pip install' : # Install package via pip
655+ print ('Package name?' )
656+ pkgName = input ()
657+ os .system ('pip install ' + pkgName )
658+ elif cmd == 'pip install -U' or cmd == 'pip update' or cmd == 'pip upgrade' : # Update/upgrade package via pip
659+ print ('Package name?' )
660+ pkgName = input ()
661+ os .system ('pip install -U ' + pkgName )
662+ elif cmd == 'git clone' : # Clone Git repository using url
663+ print ('Repository url?' )
664+ repoURL = input ('' )
665+ print ('Directory to clone it to?' )
666+ repoPath = input ('' )
667+ print ('Name to clone it as?' )
668+ repoName = input ('' )
669+ try :
670+ os .system ('cd ' + repoPath + ' & git clone ' + repoURL + ' ' + repoName )
671+ except :
672+ print ('Error! Please make sure the directory and repository url is valid!' )
673+ elif cmd == 'title' :
674+ if __os__ == 'Windows' :
675+ print ('New title -> ' , end = '' )
676+ ctypes .windll .kernel32 .SetConsoleTitleW (input ())
677+ else :
678+ print ('This function is only for Windows!' )
630679 elif cmd == '' or cmd == None : # Empty input
631680 continue # Continue
632681 else : # Is not a command
0 commit comments