textfsm parse two different outputs with one template - python-textfsm

I use ntc-templates for cisco output. In all of cisco's wisdom, from 16.x to 17.x IOS-XE, they have changed the output of 'show license status'
Is there a way to use one textfsm template with conditional matches to determine which part of the template to use?
Currently using 2 templates, which works, but adds 'overhead' as this method doesn't work with the netmiko usetextfsm implementation as it is based on the command being run.

Related

(Robot Framework IDE) RIDE->Search Tests Window-> Search tab what is "ADD all to Selected" used for

As the title says, in RIDE interface for Robot Framework, on the Search Tests Window, i have two Tabs:
1-Search 2- Add All to Selected
For first Tab, i wonder if i can insert a list of Test cases on search box and if the second TAB
will tick them on the interface.
I couldn't use it in this way but seems to function like that.
Any idea?
Edit:
So here i have added two complete test names separated with comma followed by space:
but as you see the Search Engine finds only the last test name. I can search by what i have added as TestID inside Documentation of each test,and add something like :
TC-69, TC67 but search engine finds as before only the last test.
You don't mention what version of RIDE you are using. In the past there was a bug on that search feature.
Today I have verified that Search function is working as expected on RIDE version 2.0b2, in Windows 10, Python 3.9 and wxPython 4.1.1.
I used a list in the Search box and then Add All to Selected. I use a large test name and a partial test name:
9__Checks if all the firewall rules related to the Network Discovery group are disabled, 2_
Here is a partial capture of the dialog (not the best colors combination ;) :
EDIT: Please edit the search text to not include the word Acces or Accès, so it is only Contextuel_REFSITE.
Another problem (could be a bug in RIDE) is the documentation having latin characters, and the search function become broken.
The tab Tag Search, will only search by tags, and then you have the option to add to Included or to Excluded tests.
Note: It is very important to confirm the version of RIDE you are using (Tools->View RIDE Log).

Docxtemplater - Newlines between loop iterations

TLDR - how do I use either a custom parser function or modify the loop module to it'll add a newline after each iteration?
Long story:
I'm using old templates that used to be rendered with some MS tools, now trying to render them with docxtemplater. Main requirement is to not modify the templates. Use them as they are, and be able to render documents as identical as possible to that MS tool.
Here's what a loop looks like in one of the templates:
«TableStart:MortgageInfo»« MortgageInfo_Name»
« MortgageInfo_MortgageStreet»
«CityStateZip»«TableEnd:MortgageInfo»
I used custom delimiters for « and » and created a custom loop module to handle the custom TableStart: and TableEnd: format.
There is no linebreak between «CityStateZip» and «TableEnd:MortgageInfo» so the 2nd item is rendered immediately after the 1st without a linebreak.
Anybody has any idea how I add this missing linebreak? Please bare in mind - no modification to the template is allowed...

Customize IBM DiffMerge to export a custom Report

I am using IBM DiffMerge to generate a Report that shows all differences between two .cls files or .sbs files. I was playing with it and I saw that there is a filed in option menu that allows you to change the format of the report, but it implies some keywords, like $elemname to print the element's name or $elemtype to print its type $leftonly or $rightonly which show how many differences are in the left diagram or in the right one.
Now, I was wondering if there are more variables like those above, especially one that can print a component's GUID (unique ID in Rhapsody).
Thanks,
Daniel
I would expect that $GUID will give you what you're looking for.
Under the ReporterPlus installation folder there is a folder named Templates. In it you'll find a file named DiffReport.dpl which you can load it into ReporterPlus for editing like any other template. You must run Rep+ with a command line option so that it loads with the Diffmerge specific schema:
Reporter.exe /mode=dfm
After that you can load the Diffmerge template, and edit it to customize the output of DiffMerge reports. When you do, try adding $GUID into the output.
Regards, Simon

Robot Framework HTML Report Customisation

I need to customize the HTML report generated at the end of test execution.
Few things I require are:
Remove the table - Statistics by Tags as I am not using any tags
Add the version number for the SUT in the summary section of the report.
What solutions are there for this? I tried to change the robot code and also tried to work on the output.xml. But nothing worked.
There is no facility provided by robot to customize the report and log files, as far as adding or removing sections is concerned. You have two options:
write your own report generator that converts output.xml into a format you like, or
create a fork of the robot framework source code and make the modifications there.
For the case of putting the version number for the SUT in the summary section of the report, you can add that with the --metadata command line option:
pybot --meta "SUT version: 1.2.3" ...
That will add the version to the summary section. You can also use the Documentation setting or the --doc command line option to put information that will appear in the report summary.
If you aren't using tags, you should! Those are one of the best features of the framework. You can create tags during a test run, so you could have your tests define a "sut version" tag and set it to the version of the system being tested.

How to get and set the default output directory in Robot Framework(Ride) in Run time

I would like to move all my output files to a custom location, to a Run directory created based on Date time during Run time. The output folder by datetime is created in the TestSetup
I have function "Process_Output_files" which will move the files to the Run folder(Run1,Run2,Run3 Folders).
I have tried using the argument-d and used the function "Process_Output_files" as suite tear down to move the output files to the respective Run directory.
But I get the following error "The process cannot access the file because it is being used by another process". I know this is because the Robot Framework (Ride) is currently using this.
If I dont use the -d argument, the output files are getting saved in temp folders.
c:\users\<user>\appdata\local\temp\RIDEfmbr9x.d\output.xml
c:\users\<user>\appdata\local\temp\RIDEfmbr9x.d\log.html
c:\users\<user>\appdata\local\temp\RIDEfmbr9x.d\report.html
My question is, Is there a way to get move the files to custom location during run time with in Robot Framework.
You can use the following syntax in RIDE (Arguments:) to create the output in newfolders dynamically
--outputdir C:/AutomationLogs/%date:~-4,4%%date:~-10,2%%date:~-7,2% --timestampoutputs
The above syntax gives you the output in below folder:
Output: C:\AutomationLogs\20151125\output-20151125-155017.xml
Log: C:\AutomationLogs\20151125\log-20151125-155017.html
Report: C:\AutomationLogs\20151125\report-20151125-155017.html
Hope this helps :)
I understand the end result you want is to have your output files in their custom folders. If this is your desire, it can be accomplished at runtime and you won't have to move them as part of your post processing. This will not work in RIDE, unfortunately, since the folder structure is created dynamically. I have two options for you.
Option 1: Use a script to kick off your tests
RIDE is awesome, but in my humble opinion, one shouldn't be using it to run ones tests, only to build and debug ones tests. Scripts are far more powerful and flexible.
Assuming you have a test, test2.txt, you wish to run, the script you use to do this could be something like:
from time import gmtime, strftime
import os
#strftime returns string representations of a date-time tuple.
#gmtime returns the date-time tuple representing greenwich mean time
dts=strftime("%Y.%m.%d.%H.%M.%S", gmtime())
cmd="pybot -d Run%s test2"%(dts,)
os.system(cmd)
As an aside, if you do intend to do post processing of your files using rebot, be aware you may not need to create intermediate log and report files. The output.xml files contain everything you need, so if you don't want to create superfluous files, use --log NONE --report NONE
Option 2: Use a listener to do post processing
A listener is a program you write that responds to events (x_start, x_end, etc). The close() event is akin to the teardown function and is the last thing called. So, assuming you have a function moveFiles() you simply need to create a listener class (myListener), define the close() method to call your moveFiles() function, and alert your test that it should report to a listener with the argument --listener myListener.
This option should be compatible with RIDE though I admit I have never tried to use listeners with the IDE.
At least you can write a custom run script that handles the moving of files after the test case execution. In this case the files are no longer used by pybot.

Resources