4
4
except :
5
5
sep = os .getcwd ()[0 ]
6
6
from time import localtime
7
- from sys import stdin ,implementation ,path ,print_exception
7
+ from sys import stdin ,implementation ,path
8
+ try :
9
+ from traceback import print_exception ,format_exception
10
+ except :
11
+ from sys import print_exception as sysprexcept
12
+ print_exception = lambda err ,value = None ,tb = None : sysprexcept (err )
13
+ format_exception = lambda err ,value = None ,tb = None : [err ]
8
14
if not sep + 'lib' in path :
9
15
path .insert (1 ,sep + 'lib' )
10
16
path .append (sep + 'PyBasic' )
@@ -67,7 +73,7 @@ def PyDOS():
67
73
global envVars
68
74
if "envVars" not in globals ().keys ():
69
75
envVars = {}
70
- _VER = "1.40 "
76
+ _VER = "1.41 "
71
77
prmpVals = ['>' ,'(' ,')' ,'&' ,'|' ,'\x1b ' ,'\b ' ,'<' ,'=' ,' ' ,_VER ,'\n ' ,'$' ,'' ]
72
78
73
79
print ("Starting Py-DOS..." )
@@ -138,8 +144,10 @@ def exCmd(cFile,passedIn):
138
144
else :
139
145
exec (f"passedIn = '{ passedIn } '\n { cf .read ()} " )
140
146
except Exception as err :
141
- print_exception (err )
142
- envVars ['lasterror' ] = err
147
+ print_exception (err ,err , \
148
+ err .__traceback__ if hasattr (err ,'__traceback__' ) else None )
149
+ envVars ['lasterror' ] = format_exception (err ,err , \
150
+ err .__traceback__ if hasattr (err ,'__traceback__' ) else None )
143
151
except KeyboardInterrupt :
144
152
print ("^C" )
145
153
@@ -222,7 +230,7 @@ def dirLoop(tmpDir,lastDir,isFile,swPause,swWide,swRecur,prSum, \
222
230
lastDir = ""
223
231
224
232
if dirPat is None :
225
- (quit ,nLines ) = scrnPause (swPause ,nLines ,["" ,f "Directory of { dPath .replace ('/' ,('\\ ' if envVars .get ('DIRSEP' ,'/' ) == '\\ ' else '/' ))} " ])
233
+ (quit ,nLines ) = scrnPause (swPause ,nLines ,["" ,"Directory of " + dPath .replace ('/' ,('\\ ' if envVars .get ('DIRSEP' ,'/' ) == '\\ ' else '/' ))])
226
234
dirHeadPrntd = True
227
235
nDirs += 2
228
236
if swWide :
@@ -236,7 +244,7 @@ def dirLoop(tmpDir,lastDir,isFile,swPause,swWide,swRecur,prSum, \
236
244
else :
237
245
scrAdj1 = 52 - min (scrWdth ,52 )
238
246
(quit ,nLines ) = scrnPause (swPause ,nLines , \
239
- [f" .{ " " * (23 - scrAdj1 )} <DIR>" , f" ..{ " " * (22 - scrAdj1 )} <DIR>" ])
247
+ [f' .{ " " * (23 - scrAdj1 )} <DIR>' , f' ..{ " " * (22 - scrAdj1 )} <DIR>' ])
240
248
241
249
for _dir in sorted ([srtFnc (x ,pFmt (dPath )) for x in os .listdir (dPath )]):
242
250
_dir = _dir .split ('*' )[1 ]
@@ -267,7 +275,7 @@ def dirLoop(tmpDir,lastDir,isFile,swPause,swWide,swRecur,prSum, \
267
275
wideCount += 1
268
276
if not ForD :
269
277
(quit ,nLines ) = scrnPause (swPause ,nLines , \
270
- [f" [{ _dir [:13 ]} ]{ " " * (14 - len (_dir [:13 ]))} " ],"" )
278
+ [f' [{ _dir [:13 ]} ]{ " " * (14 - len (_dir [:13 ]))} ' ],"" )
271
279
else :
272
280
(quit ,nLines ) = scrnPause (swPause ,nLines , \
273
281
[_dir [:15 ]+ " " * (16 - len (_dir [:15 ]))],"" )
@@ -278,11 +286,11 @@ def dirLoop(tmpDir,lastDir,isFile,swPause,swWide,swRecur,prSum, \
278
286
scrAdj1 = 52 - min (scrWdth ,52 )
279
287
scrAdj2 = min (13 ,65 - min (scrWdth ,65 ))
280
288
(quit ,nLines ) = scrnPause (swPause ,nLines , \
281
- [f" { _dir [:max (8 ,scrWdth - 26 )]} { " " * (24 - len (_dir )- scrAdj1 )} <DIR>{ " " * (18 - scrAdj2 )} { fTime [1 ]:02} -{ fTime [2 ]:02} -{ fTime [0 ]:04} { fTime [3 ]:02} :{ fTime [4 ]:02} " ])
289
+ [f' { _dir [:max (8 ,scrWdth - 26 )]} { " " * (24 - len (_dir )- scrAdj1 )} <DIR>{ " " * (18 - scrAdj2 )} { fTime [1 ]:02} -{ fTime [2 ]:02} -{ fTime [0 ]:04} { fTime [3 ]:02} :{ fTime [4 ]:02} ' ])
282
290
else :
283
291
scrAdj1 = 65 - min (scrWdth ,65 )
284
292
(quit ,nLines ) = scrnPause (swPause ,nLines , \
285
- [f" { _dir [:max (8 ,scrWdth - 20 - len (fSize ))]} { " " * (36 - len (_dir )+ 10 - len (fSize )- scrAdj1 )} { fSize } { fTime [1 ]:02} -{ fTime [2 ]:02} -{ fTime [0 ]:04} { fTime [3 ]:02} :{ fTime [4 ]:02} " ])
293
+ [f' { _dir [:max (8 ,scrWdth - 20 - len (fSize ))]} { " " * (36 - len (_dir )+ 10 - len (fSize )- scrAdj1 )} { fSize } { fTime [1 ]:02} -{ fTime [2 ]:02} -{ fTime [0 ]:04} { fTime [3 ]:02} :{ fTime [4 ]:02} ' ])
286
294
287
295
if quit :
288
296
break
@@ -316,8 +324,8 @@ def dirLoop(tmpDir,lastDir,isFile,swPause,swWide,swRecur,prSum, \
316
324
317
325
scrAdj1 = 65 - min (scrWdth ,65 )
318
326
(quit ,nLines ) = scrnPause (swPause ,nLines , \
319
- [(f" { " " * (4 - len (str (nFiles )))} { nFiles } File(s){ " " * (32 - len (str (tFSize ))- scrAdj1 )} { tFSize } Bytes." )[:scrWdth ], \
320
- (f" { " " * (4 - len (str (nDirs )))} { nDirs } Dir(s){ " " * (33 - len (str (availDisk ))- scrAdj1 )} { availDisk } Bytes free." )[:scrWdth ],"" ],"" )
327
+ [(f' { " " * (4 - len (str (nFiles )))} { nFiles } File(s){ " " * (32 - len (str (tFSize ))- scrAdj1 )} { tFSize } Bytes.' )[:scrWdth ], \
328
+ (f' { " " * (4 - len (str (nDirs )))} { nDirs } Dir(s){ " " * (33 - len (str (availDisk ))- scrAdj1 )} { availDisk } Bytes free.' )[:scrWdth ],"" ],"" )
321
329
322
330
return (nLines ,nFiles ,tFSize ,nDirs ,quit )
323
331
@@ -637,7 +645,7 @@ def readBATFile(BATfile):
637
645
print (f'The current date is: { "MonTueWedThuFriSatSun" [i :i + 3 ]} { localtime ()[1 ]:02} /{ localtime ()[2 ]:02} /{ localtime ()[0 ]:04} ' )
638
646
639
647
elif cmd == "TIME" :
640
- print (f" The current time is: { localtime ()[3 ]% 12 } :{ localtime ()[4 ]:02} :{ localtime ()[5 ]:02} { ["AM" ,"PM" ][localtime ()[3 ]// 12 ]} " )
648
+ print (f' The current time is: { localtime ()[3 ]% 12 } :{ localtime ()[4 ]:02} :{ localtime ()[5 ]:02} { ["AM" ,"PM" ][localtime ()[3 ]// 12 ]} ' )
641
649
642
650
elif cmd == "MEM" :
643
651
gc .collect ()
0 commit comments