TaskWarrior automatically modify UDA - taskwarrior

I have a question. Let's say that I have created User Defined Attribute attr with values A,B,C.
How to configure taskwarrior to automatically change the attr value from A to B when I enter
task x start
and change attr from B to C when
task x done

Disadvantage of suggested solution:
You continuously need to have a script running in the background.
There can occur a small delay between your task x start command, and the change of UDA attr
It is a bit of a tedious method, perhaps you can also accomplish your goal using solely taskwarrior commands/settings.
It is made for fun and I can currently not offer any security or proper functioning guarantees. I tested and use it on WSL Ubuntu 16.04.
Assumptions:
If you enter task x start the attribute Start is set to a valid date.
Solution:
You can have a script running in the background that reads the properties of all tasks, and as soon as it detects a valid date in the Start attribute of a tasks, and a value of B in the UDA attr then it sets the UDA attr to C by executing the command task x modify attr:C command.
I made a script/small project that sorts on a custom setting of project and urgency, and it contains the functionalities of:
Running in the background from startup automatically,
Scanning the taskproperties and automatically applying the changes that are programmed in the script.
So in effect,
You should modify/add the UDA attr here:
And duplicate and change for example method private static void setCustomSort(ArrayList<Task> taskList) {1 on line 88 of the main
(For the 2nd step, between //get uuid and //create command you should add the condition that checks the task for a valid id. Then if it has, change the command that is generated to task modify attr:C)
The instructions to compile the java code and set up automation are listed here.

Related

How to run cucumber scenario's based on Test Case ID that is appended with the Scenario name?

I wanted to run Cucumber Feature file based on the Test case ID that scanerio name contains.
I know we can use #CucumberOptions 'features' tag and specify the line number to execute e.g "src/test/resources/Folder/myfile.feature:7:12"
This will run scenarios at line 7 and 12. But i wanted to run based on the TC ID.
Below is the feature file code
#Run
Feature: Login Functionality
Scenario: First Test Case(TC.No:1)
Given I perform action 1
Scenario: Second Test Case(TC.No:2)
Given I perform action 2
Scenario: Third Test Case(TC.No:3)
Given I perform action 3
Scenario: Fourth Test Case(TC.No:4)
Given I perform action 4
Scenario: Fifth Test Case(TC.No:5)
Given I perform action 5
All the scenario's are in a single feature.
For the feature file code above i wanted some way through which i can execute based on TC Id. E.g I only want to execute TC1,TC2 and TC5( TC id's picked up from scenario names).
There is a property file that contains the TC Id's to be executed. My code should read the file and then execute only those TC id's.
This can help me in reducing the number of automation TC's to be run.
Is it possible?
You can use the name property of #CucumberOptions or use the '-n' option if you are using the cli option. It also supports regular expressions.
To run TC.No:1 and TC.No:4 use something like this
#CucumberOptions(name = { "TC.No:1|TC.No:4" })
or
#CucumberOptions(name = { "TC.No:1","TC.No:4" })
You can get more details at this link.
As you are reading the ids from a file, the second option is the best. Use the cucumber.api.cli.Main class main() method to execute the features. You can create the options dynamically. Refer to this post.
CLI reference docs.
Not familiar with cucumber-jvm.
But, here is the general logic which should work (based on my ruby Cucumber knowledge)
In the hook, you can write the logic to under before method to get the scenario name scenario.name and then extract the TC.No. Compare the TC.No and skip if it's not part of your list.
Here is the link which will give information how to skip the scenario (use this class in the before method)
https://junit.org/junit4/javadoc/4.12/org/junit/AssumptionViolatedException.html
However, the best practice is to use the tags, it would have been easy if you had #TCId-xx tag. Still you can write a simple program that will scan all the feature files and update the scenarios with the tag based on the TC.No in the scenario name.

How to order control m job using REXX? like Control m utility CTMAPI

I have to order few jobs in control m from different scheduling tables. this is manual task so i want to automate it using rexx.
I found below in 'Order or Force under Batch, REXX or CLIST' section of 'CONTROL M USERGUIDE'
EXEC CTMAPI PARM=‘ORDER variable’
I could not find syntax to call CMTAPI using rexx.
ADDRESS 'LINKMVS' is the equivalent of // EXEC PGM=something,PARM='whatever' in REXX. I don't know what the variable is supposed to be, but since this is Control-M, I am going to assume job name. A very simple example:
say 'Enter name of job'
pull jobname
parmvar = 'ORDER' jobname
`ADDRESS 'LINKMVS' 'CTMAPI parmvar'
Please note that for LINKMVS, the variable name goes inside the string passed. The LINKMVS environment substitutes the variable automatically. For example, if I entered MYJOB to the prompt, LINKMVS will build a PARM string of `ORDER MYJOB'. This is the exact equivalent of
// EXEC PGM=CTMAPI,PARM='ORDER MYJOB'
This IBM® Knowledge Center page for the z/OS 2.3 TSO/E REXX Reference manual shows several examples of calling a program in the same manner as // EXEC PGM=,PARM= (item 1). Items 5 through 9 show different ways of using ADDRESS 'LINKMVS'; note how variables are treated in each example.
After suggestions from NicC, zarchasmpgmr and few research, finally i am able to order job with CTMJOB utility. I searched for the loadlib and called TSO using REXX.
/*****REXX*******/
ADDRESS TSO
"CALL 'MY.IN.LOAD(CTMJOB)'
' ORDER DSN=MY.SCHED.LIB TABLE=SCHDTBL,
JOB=JOBNAME,DATE=DATE'"
EXIT
Details found in INCONTROL for ZOS utilities guide. This document was very useful.
http://documents.bmc.com/supportu/952/56/64/195664/195664.pdf

PyQt: Pop previous commands from UndoStack during current command's undo

I'm in a situation in which I have several commands of the same class pushed onto a QUndoStack and depending on user input another command of a different class might be pushed on top of those. What I would now like to achieve is to remove a fixed number of these previous commands of the first type from the undo stack (either by undoing them or just removing them, doesn't matter in my case) when the topmost command's undo is executed. E.g. like this:
class CommandA(QUndoCommand):
# ...
class CommandB(QUndoCommand):
def undo(self):
# ...
# somehow remove last N commands of class A from undostack
stack = QUndoStack()
stack.push(CommandA())
# ...
stack.push(CommandA())
stack.push(CommandB())
Just removing the last N commands regardless of which class they belong to would also be helpful as a starting point. This seems to me like it would be a common requirement but I don't see if/how this would be possible.
In PyQt5, commands on the QUndoStack are stored by index and accessed via the command function. You can loop over the commands in the stack using the count method:
for ndx in range(stack.count()):
command = stack.command(ndx)
The command will have the type of your specific QUndoCommand class (i.e. either CommandA or CommandB), so you can use isinstance to check which one it is.
Hence, you can make a QWidget (e.g. a QtWidgets.QPushButton) or QAction whose triggered signal is connected to a function (slot) that undoes the last n CommandA commands:
def undo_last_n_CommandAs(n):
for ndx in range(stack.count()):
command = stack.command(ndx)
if n > 0 and isinstance(command, 'CommandA'):
command.undo()
n -= 1

Parameterized job using Uno-choice plugin

I'm using Uno choice plugin to select parameter values based on previous selections.
(This plugin helped me to reduce parameter count. I can reuse same parameter for multiple platform based on the platform selection)
I used the groovy script to select parameter values.
But it takes too much time to load parameters.
Is there any way to speed up this process?
I had faced similar issues and I was also using groovy scripts to cal shell scripts.I did the following things to reduce time:-
When you click on build with Parameters all task(scripts run at once together) are performed at once.
Use else conditions properly.
Also use Fallback script.
For eg:-
you have parameters such as
1) country
2) state
3) city
each parameter depends on the previous values.
1) Try to only display contents on Jenkins front-end.(cat command).
2) Call a script if only it matches valid values in the previous parameter.
3) minimum on the fly scripts.
4) optimize delays/sleep according to your load time.
5) Remove any extensions whether in chrome/Firefox.
5) Try using the same page in incognito mode.
6) If options are invalid through invalid option without going into any computation.
7) Uninstall plugin which are not required.
Will add more suggestions as I find.
I would request you also to please update if you find any method to optimize time.

How do I apply command line overrides to SystemVerilog ovm_sequence objects?

I'd like to apply a command line override to an ovm_sequence object like this:
+ovm_set_config_int=*,max_timeout,100000
The max_timeout field is declared inside ovm_sequence_utils macro.
Is there any way to do it? My understanding is that ovm sequences are not part of the ovm hierarchy, so perhaps they can't be modified from the command line.
I'm not aware of a mechanism that lets you set-up config space like that from the command line. A quick grep of the OVM source doesn't show anything either.
A quick comment on
ovm sequences are not part of the ovm hierarchy
They're not constructed at build time, that's correct. They are created just before they start running on a sequencer, but any ovm_object based class can interrogate a config integer via get_config_int()
Normally I'd use a plus-arg for things like this, and the set the config int in my base test class based on that plus-arg. For example, the command line would have:
+max_timeout=100000
...and then, in my base test class, which all my tests inherit from:
function void build();
int timeout;
[....]
if ($value$plusargs("max_timeout=%d", timeout)) begin
`ovm_info(get_type_name(), "Setting timeout", OVM_MEDIUM);
set_config_int("*", "max_timeout", timeout");
end
[....]
endfunction
Normally my uses are not quite so literal as that, having flags that set multiple values up, but that's the basics of it.
I got it working (following instructions from http://www.testbench.in/OT_10_OVM_SEQUENCE_5.html) by adding the following to my ovm_sequence in task body():
if(!(p_sequencer.get_config_int("max_timeout",max_timeout)))
max_timeout = ... // some default value
The key here is that the command line config needs to be set for the sequencer, and the sequence can pick up that config using the above-mentioned code.

Resources