robhagemans / pcbasic

PC-BASIC - A free, cross-platform emulator for the GW-BASIC family of interpreters
http://www.pc-basic.org
Other
396 stars 48 forks source link

--debug=True not writting the redirected external shell output #109

Closed Danitegue closed 3 years ago

Danitegue commented 4 years ago

Hello Rob, happy new year!. A lot ago since I don't bother you... As you know we are using your marvelous interpreter to control some Brewer spectrometers through the com ports. The very old gw-basic Brewer software uses a lot of CMD commands to perform different file actions (copy, append, etc).

These CMD commands are written in a very old style language (windows 95), that is not valid anymore in windows 7 or 10 (the way in which the append command work for example, has changed). So, since modifying the software was not an option (too many instruments using it), I wrote a "shell commands interpreter" (Brw_functions.py), that translates these old style commands to python language, and perform the actions using only python. (This also is also useful to be able to use the software not only in windows 10, but also in linux).

The redirection of the shell is done by including in the pcbasic launcher, these extra arguments: --shell="python %BRWFUNCT_DIR%\Brw_functions.py" --debug=True --logfile=%LOG_DIR%\pcbasic_brewerlog%ID%.txt

I could see in the past, by viewing the log file, how these commands were being sent to the redirected shell, but also I could see in the same log, the outputs of the Brw_function.py.

This was useful because I could see in the same log file, when the brewer program sent the CMD command, and if the "shell commands interpreter" worked fine or not. It was working perfect in the past, but not sure why I have installed the latest version of pbasic today, (pip install pcbasic, with python v1.7.17, windows7), and the outputs of the Brw_function.py are not being written anymore in the log.

Have you changed anything related with that? Exist any extra argument we could use to enable the "shell commands interpreter" output into the pcbasic log?

To reproduce this, I think you could use a simple gw basic program that include the line 10 shell("blabla") and run it with arguments: --shell="python doit.py" --debug=True --logfile=C:\Temp\log.txt

The doit.py file can be something like: sys.stdout.write("Hello world \r\n")

So, when you execute the gwbasic code, in the log.txt, should be the "Hello world" line

Best regards, Daniel Santana

robhagemans commented 4 years ago

Hi, I don't think there have been any recent changes, very little has changed in the past year. I don't think I ever had explicit logging of SHELL outputs. Without knowing what version you used previously it's hard to know for sure, but perhaps this was a local modification in your branch of pc-basic? Yo could modify dos.py to record outputs in your log, but I'd say the easiest way to deal with this is simply to add logging to your doit.py directly and you are in complete control of what gets logged and where and how.

Danitegue commented 4 years ago

Yes, that is the temporal solution we already implemented, a dedicated log for the py file. But of course is less straight forward to notice problems with two different log files, than an integrated one, in which we saw what was doing pcbasic before and after the shell command was sent (With dates and times in the logfiles)

I will give give a look and compare my old dos.py to see what is in there...

If I find a way...would you agree to have an option to enable this?

Best regards

El sáb., 8 feb. 2020 9:58, Rob Hagemans notifications@github.com escribió:

Hi, I don't think there have been any recent changes, very little has changed in the past year. I don't think I ever had explicit logging of SHELL outputs. Without knowing what version you used previously it's hard to know for sure, but perhaps this was a local modification in your branch of pc-basic? Yo could modify dos.py to record outputs in your log, but I'd say the easiest way to deal with this is simply to add logging to your doit.py directly and you are in complete control of what gets logged and where and how.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/robhagemans/pcbasic/issues/109?email_source=notifications&email_token=AGF22GDZLZQDGSYQH7P2FD3RBZ635A5CNFSM4KLF44J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELFOG5Y#issuecomment-583721847, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGF22GEQJPELB7WUWCPRJJLRBZ635ANCNFSM4KLF44JQ .