Update pycatfile.py
[PyCatFile.git] / pyshell-old.py
blob1cfa1ac481dcccb3015fc51605788f879df8cec9
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 - ast Update: 10/22/2024 Ver. 0.14.2 RC 1 - Author: cooldude2k $
17 '''
19 from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
20 import sys
21 import traceback
22 import code
23 import re
24 import readline
25 import pycatfile
26 from sys import argv
27 from pycatfile import *
29 taskfound = False
30 if(len(sys.argv) < 2):
31 taskfound = True
32 ps1 = "PyShell " + \
33 str(sys.version_info[0])+"."+str(sys.version_info[1]
34 )+"."+str(sys.version_info[2])+"> "
35 cmdinput = None
36 print("PyShell "+sys.version+" on "+sys.platform +
37 "\nLoaded Python module PyCatFile "+pycatfile.__version__+"\n")
38 while(True):
39 try:
40 cmdinput = code.InteractiveConsole().raw_input(ps1)
41 except KeyboardInterrupt:
42 print("\nKeyboardInterrupt")
43 except EOFError:
44 print("")
45 sys.exit(0)
46 except Exception:
47 traceback.print_exc()
48 # exec(str(cmdinput));
49 try:
50 exec(code.compile_command(str(cmdinput)))
51 except Exception:
52 traceback.print_exc()
53 sys.exit(0)
55 if(sys.argv[1] == "sh" or sys.argv[1] == "shell" or sys.argv[1] == "pysh" or sys.argv[1] == "pyshell" or sys.argv[1] == "python"):
56 taskfound = True
57 ps1 = "PyShell " + \
58 str(sys.version_info[0])+"."+str(sys.version_info[1]
59 )+"."+str(sys.version_info[2])+"> "
60 cmdinput = None
61 print("PyShell "+sys.version+" on "+sys.platform +
62 "\nLoaded Python module PyCatFile "+pycatfile.__version__+"\n")
63 while(True):
64 try:
65 cmdinput = code.InteractiveConsole().raw_input(ps1)
66 except KeyboardInterrupt:
67 print("\nKeyboardInterrupt")
68 except EOFError:
69 print("")
70 sys.exit(0)
71 except Exception:
72 traceback.print_exc()
73 # exec(str(cmdinput));
74 try:
75 exec(code.compile_command(str(cmdinput)))
76 except Exception:
77 traceback.print_exc()
78 sys.exit(0)
80 if(sys.argv[1] == "shebang" or sys.argv[1] == "shabang" or sys.argv[1] == "hashbang" or sys.argv[1] == "poundbang" or sys.argv[1] == "hashexclam" or sys.argv[1] == "hashpling"):
81 taskfound = True
82 if(len(sys.argv) < 3):
83 print(str("command: "+sys.argv[0]+"\narguments: " +
84 sys.argv[1]+"\nerror: syntax error missing arguments"))
85 sys.exit(0)
86 shebang = "".join(open(sys.argv[2], "r").readlines())
87 exec(compile(str(shebang), "", "exec"))
88 sys.exit(0)
90 if(sys.argv[1] == "exec" or sys.argv[1] == "run" or sys.argv[1] == "execute"):
91 taskfound = True
92 argcmd = list(sys.argv)
93 argcmd[0:1] = []
94 argcmd = list(argcmd)
95 argcmd[0:1] = []
96 argcmd = list(argcmd)
97 argcmd = " ".join(argcmd)
98 exec(argcmd)
100 if(not taskfound):
101 print(str("command: "+sys.argv[0]+"\narguments: " +
102 sys.argv[1]+"\nerror: syntax error missing arguments"))
103 sys.exit(0)