Display output from a Symfony task on a template - symfony1

I am executing a task from an action in Symfony. I wish to capture the output from the task & display it to the (admin) user. Do I extract it from the dispatcher / log or somewhere else?

This might not be the answer you're looking for, however, in a task you can log to a seperate file like so (within the execute function in the task class):
$fileLogger = new sfFileLogger($this->dispatcher,
array('file' =>$this->configuration->getRootDir().'/log/foobar.log'));
$this->dispatcher->connect('command.log', array($fileLogger, 'listenToLogEvent'));
And then in your task when you use:
$this->logSection('something', 'Log whatever message you want....', 1000);
It will automatically log to the custom log file.
Hope this helps. :-)

Why not just perform the task within the action - and format the output in the template ? why are you running a separate task from an Action ? (i know this thread is old)

Related

TFS build custom conditions for running a task - check if specific previous task has failed

TFS build allows to specify conditions for running a task: reference.
The condition I would like to define is: a specific task [addressed by name or other mean] has failed.
This is similar to Only when a previous task has failed, but I want to specify which previous task that is.
Looking at the examples I don't see any condition that is addressing a specific task outcome, only the entire build status.
Is it possible? any workaround to achieve this?
It doesn't seem like there's an out-of-the-box solution for this requirement, but I can come up with (an ugly :)) workaround.
Suppose your specific task (the one you examine in regards to its status) is called A. The goal is to call another build task (let's say B) only in case A fails.
You can do the following:
Define a custom build variable, call it task.A.status and set to success
Create another build task, e.g. C and schedule it right after A; condition it to only run if A fails - there's a standard condition for that
The task C should only do one thing - set task.A.status build variable to 'failure' (like this, if we are talking PowerShell: Write-Host "##vso[task.setvariable variable=task.A.status]failure")
Finally, the task B is scheduled sometime after C and is conditioned to run in case task.A.status equals failure, like this: eq(variables['task.A.status'], 'failure')
I might be incorrect in syntax details, but you should get the general idea. Hope it helps.

Ant task to get value of repeating XML element

I have the following requirement.
from Ant xmlproperty task. What happens when there is more than one tag with the same name?
it's clear how to repeat for each file.
My requirement is to iterate for each file and I would like to get the value of 'machine' element for corresponding file
eg:
<echo>${PREFIX.main.tagList.tag.file[file1]}</echo> // should return machine1
<echo>${PREFIX.main.tagList.tag.file[file2]}</echo> // should return machine2
An example would help, but I think I discovered this limitation in the xmlproperty task before. For performing complex processing of external files I would use an embedded groovy task, which just loves XML :-)
You haven't specified a sample input, so here's a similar example:
Parse HTML using with an Ant Script

SSIS - Execute task in foreach loop only once

I need some help with the following issue:
Inside a foreach loop, I have a Data Flow Task that reads each file from the collection folder. If it fails while proccesing a certain file, that file is copied to an error folder (using a file system task called "Copy Work to Error").
I would like to set up a Send Email Task that warns me if there were any files sent to the error folder during the package execution. I could easily add this task after the "Copy Work to Error" task, but if there are many files that fail the Data Flow Task, my inbox would get filled.
Instead, I would like the Send Mail Task only once (after the foreach loop completes) only if the "Copy Work to Error" task was executed at least once. Is there any way I could achieve that?
Thanks,
Ovidiu
Here's one way that I can think of:
Create an integer variable, #Total outside the ForEach container and set it to 0.
Create an integer variable, #PerIteration inside the ForEach container.
Add a Script Task as an event handler to the File System Task. This task should increment #Total by #PerIteration.
Add your SendMail task after the ForEach container. In the precedence constraint, set type to Expression, and specify the condition #Total > 0. This should ensure that your task is triggered only if the File System Task was executed in the loop at least once.
You could achieve this using just a boolean variable say IsError created outside the scope of the for each loop with default value as False. You can set this to True immediately after the success of Copy Work to Error task using an expression task(SSIS 2012) or an Execute SQL task. And finally your Send Mail task would be connected to the For Each loop with the precedence constraint set as the Expression - isError.
When the error happens, create a record in a table with the information you would like to include in the email - e.g.
1. File that failed with full path
2. the specific error
3. date/time
Then at the end of the package, send a consolidated email. This way, you have a central location to turn to in case you want to revisit the issue, or if the email is lost/not delivered.
If you need implementation help, please revert back.

Eclispe RCP: Invoke Save all from within my code

I want to invoke the save all command of my eclispe rcp from within my code. I spent like an hour without any ideas.. this cant be that hard?
You can use the saveAllEditors command
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.saveAllEditors(true);

What's the alternative to ant: waitfor task if I need to look for a file with a pattern?

I have to look for a .xls(say test-results.xls) in a given folder. If not available, it should wait for 60 minutes for *.xls creation before timing-out. The test-execution target will meanwhile create this test result file.
I am trying to use ant: waitfor task and the associate "available" task for filename. But "available" task expects a specific filename(eg: test-results.xls). I can't have that as the file is appended with time-stamp(eg: test-result_08-22-2012 9:45 PM.xls). I tried using fileset task but it says fileset can't be used within waitfor task.
I have to use ant: waitfor task and look for a file with a particular pattern(say: test-result*.xls or *.xls). Please let me know if that's possible or is there an alternative to waitfor task for this particular scenario?
Hi you can use this combination ant-contrib PropertyRegex and waitfor task. We have used this combination for our requirement which is similar to yours.

Resources