Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Logging order in a single "build" step #4001

OnQuickBuild ·

Hello Robin

I have a question about the logs of a "Shell/Batch Command" step.

I'm using this step to invoke a Python script (call it "entry.py"), which subsequently invokes a few other scripts (such as funcs.py).

In some of the Python scripts, there are print outs like "in function 1...", "in function 2...".
For example:

# funcs.py
print('in function 1...')
function_1(args)

print('in function 2...')
function_2(args)

So inside function_1, there are print outs of its own info.

When I execute the "entry.py" in a command prompt, the stdout would appear in expected order:

in function 1...
func_1_info abc
func_1_info cde
.
.
in function 2...
func_2_info abc
func_2_info cde

However, when I execute "entry.py" on Quickbuild with batch command step, the output pipe is acting like a stack, which outputs:

func_1_info abc
func_1_info cde
.
func_2_info abc
func_2_info cde
.
in function 1...
in function 2...

How is this happening? Is there some kind of rule here when using stdout print outs?

Thanks!

  • replies 3
  • views 570
  • stars 0
robinshen ADMIN ·

On which platform are you running this step? Are all the outputs sent to stdout?

OnQuickBuild ·

It's windows, running batch command step.

I think so. It's just Python print() function, which is a sys.stdout object. According to stack overflow.

robinshen ADMIN ·

Tested and it works fine at my side. I am running below command from QB:
python c:\temp\entry.py

where entry.py contains below content:

# funcs.py
def function_1(args):
	print('func_1_info abc')
	
def function_2(args):
	print('func_2_info cde')

print('in function 1...')
function_1('')

print('in function 2...')
function_2('')

Can you please check if the python from command line is the same as you've invoked from QB? Or you may start QB agent or server (the one running this command step) in console mode to make sure all environments are the same as your command prompt, and run the step again.