Explicitly stop p4 submit operation in perforce - perforce

I want to stop perforce p4 submit operation through the change-submit hook. The submit operation should wait until the hook operation is completed and should fail to submit if the hook operation returns false.

The submit operation should wait until the hook operation is completed and should fail to submit if the hook operation returns false.
You are describing the behavior of a change-submit trigger. Note that "false" means a non-zero return code from the executable specified by the trigger.

Related

Java Card Applet trigger proactive CAT command in process method

I need to get the current time and reset the UICC in an APDU command processed in the process method of the Applet. I'm concerned about the statement in the uicc.toolkit.ProactiveHandlerSystem.getTheHandler() method:
The applet shall get the reference of the handler at its triggering, the beginning of
the processToolkit method.
I assume I will get a HANDLER_NOT_AVAILABLE ToolkitException when trying to get the handler anywhere else except the processToolkit method.
Has anyone experience with this?
What are the alternatives to get the time and execute the reset?
I could get the time in advance after the PROFILE DOWNLOAD event or in the last STATUS event before the process command is triggered. But this would mean to poll the time continuously even if the my APDU command is not called. I could wait for the next STATUS command and listen to it to execute the reset, but this would be a delay of 30 seconds.

How to run a script after Pyramid's transaction manager has returned

How can I run myscript.py after the transaction manager has returned. Additionally, I would prefer if the script was not blocking.
In my view, I am receiving a file from a POST. Since I'm creating the file with repoze.filesafe's create_file(), it keeps the file in a temporary location until the transaction manager returns. The file only exists on the harddisk in its correct path after transaction manager has returned without an error.
Therefore, I need to run my script after the transaction manager has returned.
You can register a hook to be run after commit via the transaction package. Register one in your view:
import transaction
def your_after_commit(success, arg1, arg2, kwarg1=None, kwarg2=None):
if success:
print "Transaction commit succeeded"
else:
print "Transaction commit failed"
def someview(request):
current_transaction = transaction.get()
current_transaction.addAfterCommitHook(your_after_commit, args=(1, 2), kws={kwarg1='foo', kwargs2='bar'})
This still runs your script in the context of the current request (e.g. the request does not complete until your script returns). If you need a full asynchronous setup, you'll need to move to a proper asynchronous solution such as Celery. You would not use that with a transaction hook; just register a task to be run with Celery instead.

e.output is null on WF Completed event

I am working with WF 4 and I want that when an activity failed, finshed the WF and send the callback to client with in/out argument.
but, on Completed event, the e.output is empty.
Why does it happen???
If your workflow failed there is no output. So either use the exception to pass data to the caller or handle the exception in the workflow and have it terminate normally.

Returning timer job status from custom timer job

There is a timer job status page in Central Admin
/_admin/ServiceRunningJobs.aspx
How can I properly return the status for my custom timer job ?
The Execute() method of timer job returns void.
It either fails (Exception) or succeeds (Method completes)
SPJobDefinition.UpdateProgress

Timer Job Scheduling on DataSheet Entry in SharePoint

I have a list on which I have an ItemUpdated handler.
When I edit using the datasheet view and modify every item, the ItemUpdated event will obviously run for every single item.
In my ItemUpdated event, I want it to check if there is a Timer Job scheduled to run. If there is, then extend the SPOneTimeSchedule schedule of this job to delay it by 5 seconds. If there isn't, then create the Timer Job and schedule it for 5 seconds from now.
I've tried looking to see if the job definition exists in the handler and if it does exist, then extend the schedule by 5 seconds. If it doesn't exist, then create the job definition to run in a minutes time.
MyTimerJob rollupJob = null;
foreach (SPJobDefinition job in web.Site.WebApplication.JobDefinitions)
{
if (job.Name == Constants.JOB_ROLLUP_NAME)
{
rollupJob = (MyTimerJob)job;
}
}
if (rollupJob == null)
{
rollupJob = new MyTimerJob(Constants.JOB_ROLLUP_NAME, web.Site.WebApplication);
}
SPOneTimeSchedule schedule = new SPOneTimeSchedule(DateTime.Now.AddSeconds(5));
rollupJob.Schedule = schedule;
rollupJob.Update();
When I try this out on the server, I get a lot of errors
"An update conflict has occurred, and you must re-try this action. The object MyTimerJob Name=MyTimerJobName Parent=SPWebApplication Name=SharePoint -80 is being updated by NT AUTHORITY\NETWORK SERVICE in the w3wp process
I think the job is probably running for the first time and once running, the other ItemUpdated events are coming in and finding the existing Job definition. It then tries to Update this definition even though it is currently being used. Should I make a new Job Definition name so that it doesn't step on top of the first? Or raise the time to a minute?
I solved this myself by just setting the delay to a minutes time from now regardless of whether a definition is found. This way, while it is busy, it will keep pushing back the scheduling of the job until it is done processing
This is because the event is asynchronous. You'll need to rethink exactly what you're trying to solve with this code and potentially re-factor it.
Maybe you should try using "lock" on the timer job object?

Resources