Ask a Question

A Log That Readable and is Pleasant to Read

SOLVED
MarkSchofer
Frequent Contributor

A Log That Readable and is Pleasant to Read

I write to one file when an error happens another when it works as expected.  
1. How do I programmatically purge the data.   or

Or can I read a nextvalue from a sequence or Insert a date time stamp so it is unique.

******oFile.Write(aqDateTime.Now())*****
2. How do I add a carriage return so the file is not all one line.

I am using Python

if DateCheck == 'Y':
#aqFile.WriteToTextFile("C:\Users\Schofem\CheckChecks.txt", "One", aqFile.ctANSI)
oFile = aqFile.OpenTextFile("C:\\Users\\Schofem\\Logs\\CheckChecks.txt", aqFile.faWrite, aqFile.ctANSI, False)
oFile.Write(DDT.CurrentDriver.Value[0])
oFile.Write(" - ")
oFile.Write(DDT.CurrentDriver.Value[26])
oFile.Write(" - ")
oFile.Write(DDT.CurrentDriver.Value[27])
oFile.Write(" - ")
oFile.Write("PassedDateCheck")
oFile.Write("The Test")
oFile.Close()
# else:
#aqFile.WriteToTextFile("C:\Users\Schofem\CheckChecks.txt", "One", aqFile.ctANSI)
# oFile = aqFile.OpenTextFile("C:\\Users\\Schofem\\BadChecks.txt", aqFile.faWrite, aqFile.ctANSI, False)
# oFile.Write(DDT.CurrentDriver.Value[0])
# oFile.Write(" - ")
# oFile.Write(DDT.CurrentDriver.Value[26])
# oFile.Write(" - ")
# oFile.Write(DDT.CurrentDriver.Value[27])
# oFile.Write(" - ")
# oFile.Write("FailedDateCheck")
# oFile.Write("The Test")
# oFile.Close()

 

1 ACCEPTED SOLUTION

Accepted Solutions
Marsha_R
Community Hero

Re: A Log That Readable and is Pleasant to Read

For #1, you already know how to get Today.  To write it here I think you will need to convert it to a string

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/datetimetoformat...

 

For #2, you can use WriteLine instead of Write

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/opentextfile.html

 

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

View solution in original post

5 REPLIES 5
Marsha_R
Community Hero

Re: A Log That Readable and is Pleasant to Read

For #1, you already know how to get Today.  To write it here I think you will need to convert it to a string

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/datetimetoformat...

 

For #2, you can use WriteLine instead of Write

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqfile/opentextfile.html

 

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame

View solution in original post

MarkSchofer
Frequent Contributor

Re: A Log That Readable and is Pleasant to Read

Marsha Thank You Very much. It is still reading on one line.   However much improved. Thanks

# fOR AWHILE THIUS WAS THE NEW AND IMPROVED METHOD
# For #2, you can use WriteLine instead of Write -MARSHA
# #aqFile.WriteToTextFile("C:\Users\Schofem\CheckChecks.txt", "One", aqFile.ctANSI)
# oFile = aqFile.OpenTextFile("C:\\Users\\Schofem\\Logs\\CheckChecks.txt", aqFile.faWrite, aqFile.ctANSI, False)
# oFile.Write(DDT.CurrentDriver.Value[0])
# oFile.Write(" - ")
# oFile.Write(aqDateTime.Now())
# oFile.Write(DDT.CurrentDriver.Value[26])
# oFile.Write(" - ")
# oFile.Write(DDT.CurrentDriver.Value[27])
# oFile.Write(" - ")
# oFile.Write("PassedDateCheck")
# oFile.Write("The Test")
# oFile.Close()
sPath = "C:\\Users\\Schofem\\CheckChecks.txt" ******Note to those those scoring at home. Need the double forward slashes 
# Creates a text file at the specified location
aqFile.Create(sPath)
# Opens the created file for writing
myFile = aqFile.OpenTextFile(sPath, aqFile.faWrite, aqFile.ctUnicode)
# Writes text to the file
myFile.WriteLine(aqDateTime.Now())
myFile.WriteLine(DDT.CurrentDriver.Value[0])
myFile.WriteLine(DDT.CurrentDriver.Value[26])
myFile.WriteLine(DDT.CurrentDriver.Value[27])
# Closes the file
myFile.Close()

Marsha_R
Community Hero

Re: A Log That Readable and is Pleasant to Read

Hm I would have thought that had a <CR> in it.  You could try writing out a <CR> or <CR><LF> after the line and see what it does.

Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
sonya_m
Community Manager

Re: A Log That Readable and is Pleasant to Read

Thank you Marsha !

 

Did the situation improve @MarkSchofer ?


Sonya Mihaljova
Community and Education Specialist

Join Wintertainment 2021 to share your stories, have fun, earn community badges, and more!
MarkSchofer
Frequent Contributor

Re: A Log That Readable and is Pleasant to Read

This was never a major issue, however   the log is fine. The only problem is that I am looping through and processing records and it is only writing the last file processed.   Stated another way,  it only writes and does not append

cancel
Showing results for 
Search instead for 
Did you mean: