Small update
[PyCatFile.git] / pyshell-old.py
blob6e886e709abafa39adbb47990a169a7b98e24c56
1 #!/usr/bin/env python
3 '''
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Revised BSD License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 Revised BSD License for more details.
12 Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
13 Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
14 Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16 $FileInfo: pyshell-old.py - Last Update: 7/10/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
17 '''
19 from __future__ import print_function
21 import code
22 import re
23 import readline
24 import sys
25 import traceback
26 from sys import argv
28 import pycatfile
29 from pycatfile import *
31 taskfound = False
32 if (len(sys.argv) < 2):
33 taskfound = True
34 ps1 = "PyShell " + \
35 str(sys.version_info[0]) + "." + str(sys.version_info[1]
36 ) + "." + str(sys.version_info[2]) + "> "
37 cmdinput = None
38 print("PyShell " + sys.version + " on " + sys.platform +
39 "\nLoaded Python module PyCatFile " + pycatfile.__version__ + "\n")
40 while (True):
41 try:
42 cmdinput = code.InteractiveConsole().raw_input(ps1)
43 except KeyboardInterrupt:
44 print("\nKeyboardInterrupt")
45 except EOFError:
46 print("")
47 sys.exit(0)
48 except Exception:
49 traceback.print_exc()
50 # exec(str(cmdinput));
51 try:
52 exec(code.compile_command(str(cmdinput)))
53 except Exception:
54 traceback.print_exc()
55 sys.exit(0)
57 if (sys.argv[1] == "sh" or sys.argv[1] == "shell" or sys.argv[1] ==
58 "pysh" or sys.argv[1] == "pyshell" or sys.argv[1] == "python"):
59 taskfound = True
60 ps1 = "PyShell " + \
61 str(sys.version_info[0]) + "." + str(sys.version_info[1]
62 ) + "." + str(sys.version_info[2]) + "> "
63 cmdinput = None
64 print("PyShell " + sys.version + " on " + sys.platform +
65 "\nLoaded Python module PyCatFile " + pycatfile.__version__ + "\n")
66 while (True):
67 try:
68 cmdinput = code.InteractiveConsole().raw_input(ps1)
69 except KeyboardInterrupt:
70 print("\nKeyboardInterrupt")
71 except EOFError:
72 print("")
73 sys.exit(0)
74 except Exception:
75 traceback.print_exc()
76 # exec(str(cmdinput));
77 try:
78 exec(code.compile_command(str(cmdinput)))
79 except Exception:
80 traceback.print_exc()
81 sys.exit(0)
83 if (sys.argv[1] == "shebang" or sys.argv[1] == "shabang" or sys.argv[1] == "hashbang" or sys.argv[1]
84 == "poundbang" or sys.argv[1] == "hashexclam" or sys.argv[1] == "hashpling"):
85 taskfound = True
86 if (len(sys.argv) < 3):
87 print(str("command: " + sys.argv[0] + "\narguments: " +
88 sys.argv[1] + "\nerror: syntax error missing arguments"))
89 sys.exit(0)
90 shebang = "".join(open(sys.argv[2], "r").readlines())
91 exec(compile(str(shebang), "", "exec"))
92 sys.exit(0)
94 if (sys.argv[1] == "exec" or sys.argv[1] == "run" or sys.argv[1] == "execute"):
95 taskfound = True
96 argcmd = list(sys.argv)
97 argcmd[0:1] = []
98 argcmd = list(argcmd)
99 argcmd[0:1] = []
100 argcmd = list(argcmd)
101 argcmd = " ".join(argcmd)
102 exec(argcmd)
104 if (not taskfound):
105 print(str("command: " + sys.argv[0] + "\narguments: " +
106 sys.argv[1] + "\nerror: syntax error missing arguments"))
107 sys.exit(0)