Need to print logs from behave step files - python-behave

I am trying to print the - print statements in python behave step files, meanwhile i do not want to print the traceback errors. I used behave.ini file with stdout_capture=False setup. It helps to print the print statements in the step file but along with it, it also prints the traceback errors. I do not want this to print and want only output the print statements mentioned in the step files. Is there any way to do it ?
I used below command.
behave exmaple.feature --logging-level= ERROR

Try to add this to behave.ini
stderr_capture = no
refer the below documentation: https://github.com/behave/behave/blob/master/docs/behave.rst#configuration-files

Related

Trouble with Scilab "print" instruction

Trying to debug a program in Scilab, I inserted a couple
of "print" instructions to track what is going on.
At first, I used the %io(2) output "file" which, according
to the Help, stands for the console. Nothing happened.
Then I used an actual filename:
print("C:\Leszek\Xprmnt\scl\Ovsjanko\K3ScilabLog.txt", "START! \n \n \n \n GOING \n")
which does print to that file, but when the dust has settled
and I want to inspect the file what I find inside is just the last
message (just before the program crashed), even though there should
have been others before it, including the "START" etc in the quote above.
Apparently, every print command reopens the file for writing as a clean slate,
overwriting whatever was in it before. Looking into Help and online docs
I didn't find any options or parameters that I could use to change this.
What I want is, obviously, the output from all my print commands since the
beginning of the program, either on the console or in a text file.
TIA.
Just use disp("some text") or mprintf("format",var1,...,varn), both will display on the console. If you need to write in a file use fd = mopen("file.txt") then mfprint(fd,"format",var1,...,varn).

Kotlin for loop not printing in Kotlin Script

I'm new to Kotlin and I'm playing with the for loop, in Kotlin Script (*.kts file) I have this in the file:
for (i in 1..5) print("$i, ")
I did think it would print the number 1 through 5 separated by commas in one line like this:
1, 2, 3, 4, 5,
But instead I don't get any output on the command line. I'm running this on a Mac via
kotlin ranges.kts
If I put anything behind this single for loop, like a seperate println() or if I replace the print in the loop with println, it works and gives me output.
I don't get this behaviour. Can anyone explain this to me?
Edit1:
Versions:
kotlin: 1.3.71
MacOS 10.15.4 (Catalina)
This has nothing to do with the for loop and everything to do with print. It works if you add System.out.flush() at the end of the script. By default, writes to System.out (which print uses under the hood) don't always flush, and its likely that the Kotlin script runner isn't flushing the standard output stream before exiting.
This is also why using println works, as you noted -- if you look at the implementation of println in PrintStream, you'll see that it does flush its internal text and character output streams.
I created issue https://youtrack.jetbrains.com/issue/KT-38263.

How do you extract data from gdb

How do you extract data from gdb so you can examine it in another program?
I am using gdb to debug a program. To see what is in array udata, I have created a source file called printudata with the following contents:
print udata[0]
print udata[1]
print udata[2]
...
print udata[143]
From within gdb I can execute that using source command and get output like this:
(gdb) source printudata
$399 = 1
$400 = 2.5
$401 = .3-10
...
$542 = <number>
So far, that is the best I can do for examining memory.
The only thing I can think of to do with this is (learn regular expressions and) strip off everything up to the equal sign so I can paste this into a spreadsheet which will tell me whether it's correct.
Is this the really the best way to get output from gdb? I am learning all this on my own and only have the basic, free tools that come with Linux (and am a beginner with all the above listed technologies)
You can print an array if it is really an array like this:
p udata
But, if udata is really a pointer, then you can use a cast to make gdb print it like an array.
p *(double(*)[144])udata
If you really want the line at a time output of your current "script", you can define a function and use a loop:
define print_udata
set $i=0
while ($i < 144)
p udata[$i]
set $i=$i+1
end
end
To log the output to a file, you can enable/disable logging:
set logging on
...gdb commands...
set logging off
The output will be in a file called gdb.txt.
In addition to the above, gdb has the "output" and "printf" commands. These don't enter the value into the value history, and they let you control the output much more precisely.
gdb has built-in scripting in both its own scripting language and in python. You can even script GDB from within a python program. You can use any of those options to write the data to a file.
More information about python & gdb here.

Python Eclipse output to an external text file

I have a long running code which outputs stuff every minute. I will be running it all night and will check results in the morning.
Is there a way to write all the Console stuff to an external text file. I do not want to modify the code, but just looking to direct all Console output to an external file. I am working in Eclipse. I tried the Run -> Run Configurations... -> Your Application -> Common tab -> File idea but the output is horrible - no line breaks.
Is there a way to get the exact same output as the Console into a text file - all formatted nicely?
Many thanks in advance.
RS
you can add a text file. If you write your code to a file which is in a specific directory or if you know the name of it, your program can recognize this. For example, if your variable is words, you can write words = open("what your file is called") then at the end of you code end by writing to file: file.write(string)

How can you print a file using Win32 Printing and Print Spooler Functions

I am trying to figure out how you can print a file, for example an excel spreadsheet using the Win32 Printing and Print Spooler Functions. I know the path of the file, but don't have a clue to send it to the print spooler.
You can call ShellExecute with lpOperation="print", see http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx
Note this will only work for document types that have the print verb defined, right click on a document you want to print and see if Print appears in the menu.
to print an excel file, you will have to use excel (or write your own excel file parser - ouch). eg, via Automation. try googling: excel automation

Resources