Bug report

Discuss RoboTask here

Bug report

Postby andydoc1 » Wed Aug 25, 2021 11:49 pm

I am developing a python script.
Part is as follows:
Code: Select all
#from robotask import *
from datetime import datetime, timedelta
import subprocess, os

#rt = RoboTask()

#print(rt.version)

symbols = ["GBPJPY"]
v = datetime.now()
numdays=1
w = v - timedelta(days=(numdays+1))

def save_and_run_config():
    config = {
        "ExpertParameters":"MakeMoney_{}_M1.set".format(symbol),
        "Symbol":symbol,
        "FromDate":fromdate,
        "ToDate":todate,
        "Report":"\\reports\\tester_MakeMoney_{}_{}.html".format(symbol,todate)
        }


    title = "CONFIG_FILE_FOR_{}_{}".format(symbol,todate)
    print("[{}]".format(title))#def
    for x, y in config.items():#def
        print(x,"=",y,sep='')#def
    print("{} completed".format(title))



for symbol in symbols:
    for x in (w + timedelta(n) for n in range(numdays+1)):
        if((x.weekday()==0) or (x.weekday()==6)):
            continue
        todate = x.strftime("%Y.%m.%d")
        y = x - timedelta(days=1)
        fromdate = y.strftime("%Y.%m.%d")
        save_and_run_config()


The Code as above produces
Code: Select all
[STDOUT] [CONFIG_FILE_FOR_GBPJPY_2021.08.24]
[STDOUT] ExpertParameters=MakeMoney_GBPJPY_M1.set
[STDOUT] Symbol=GBPJPY
[STDOUT] FromDate=2021.08.23
[STDOUT] ToDate=2021.08.24
[STDOUT] Report=\reports\tester_MakeMoney_GBPJPY_2021.08.24.html
[STDOUT] CONFIG_FILE_FOR_GBPJPY_2021.08.24 completed

Exit code: 0
as expected

However, uncommenting the RoboTask lines causes printing issues -
uncommenting
Code: Select all
#from robotask import *
causes no problem but uncommenting
Code: Select all
rt = RoboTask()
produces the horrible
Code: Select all
[STDOUT] [CONFIG_FILE_FOR_GBPJPY_2021.08.24]
[STDOUT] ExpertParameters
[STDOUT]
[STDOUT] =
[STDOUT]
[STDOUT] MakeMoney_GBPJPY_M1.set
[STDOUT] Symbol
[STDOUT]
[STDOUT] =
[STDOUT]
[STDOUT] GBPJPY
[STDOUT] FromDate
[STDOUT]
[STDOUT] =
[STDOUT]
[STDOUT] 2021.08.23
[STDOUT] ToDate
[STDOUT]
[STDOUT] =
[STDOUT]
[STDOUT] 2021.08.24
[STDOUT] Report
[STDOUT]
[STDOUT] =
[STDOUT]
[STDOUT] \reports\tester_MakeMoney_GBPJPY_2021.08.24.html
[STDOUT] CONFIG_FILE_FOR_GBPJPY_2021.08.24 completed

Exit code: 0

Please can this be addressed?
andydoc1
 
Posts: 2
Joined: Tue Aug 24, 2021 5:37 pm

Re: Bug report

Postby Oleg » Thu Aug 26, 2021 9:35 am

Look at the script, line #27
change it to
Code: Select all
        print(x + "=" + y)#def


The full script is
Code: Select all
from robotask import *
from datetime import datetime, timedelta
import subprocess, os

rt = RoboTask()

print(rt.version)

symbols = ["GBPJPY"]
v = datetime.now()
numdays=1
w = v - timedelta(days=(numdays+1))

def save_and_run_config():
    config = {
        "ExpertParameters":"MakeMoney_{}_M1.set".format(symbol),
        "Symbol":symbol,
        "FromDate":fromdate,
        "ToDate":todate,
        "Report":"\\reports\\tester_MakeMoney_{}_{}.html".format(symbol,todate)
        }


    title = "CONFIG_FILE_FOR_{}_{}".format(symbol,todate)
    print("[{}]".format(title))#def
    for x, y in config.items():#def
        print(x + "=" + y)#def
    print("{} completed".format(title))



for symbol in symbols:
    for x in (w + timedelta(n) for n in range(numdays+1)):
        if((x.weekday()==0) or (x.weekday()==6)):
            continue
        todate = x.strftime("%Y.%m.%d")
        y = x - timedelta(days=1)
        fromdate = y.strftime("%Y.%m.%d")
        save_and_run_config()

It works.
The problem occurs because RoboTask catches STDOUT and interprets each parameter of print function as new portion of OUT stream
Also you can use
Code: Select all
        rt.log(x + "=" + y)

to out some string into the task log
Oleg Yershov
Oleg
Site Admin
 
Posts: 2668
Joined: Thu Jan 01, 1970 1:00 am


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 8 guests

cron