Jump to content


Remote debug triggers and brokers howto

trigger broker script python howto

  • Please log in to reply
2 replies to this topic

#1 phopkins

phopkins

    Advanced Member

  • Members
  • PipPipPip
  • 97 posts

Posted 27 August 2014 - 05:30 AM

So I've asked before about peoples workflow on server side scripts, and from what I can gather everyone is happy to debug local and do a lot of 'printf' when necessary. Not exactly the kind of way I like to develop.

So sharing this method which gives me excellent remote debugging of scripts when they execute on a server.
  - I use python
  - I use eclipse
  - My server is linux, but eclipse client can be eclipse or windows.

Basically follow this guide here http://pydev.org/man...e_debugger.html

I had to add two lines to my sometrigger.dev.py script

import pydevd;
pydevd.settrace('x.x.x.') #my client machine running eclipse

And 1 line to my bash wrapper script sometrigger.dev.sh

export PYTHONPATH=$PYTHONPATH:/p4/common/bin/triggers/pydev

And copy the contents of pydev into /p4/common/bin/triggers/pydev

So now on any client when I do a 'p4 mytriggercommand' , it connects back to my eclipse client and I have full eclipse python debugging at my disposal.

I don't know if python has any built in remote development, but if it did it might be good for Perforce to enable it in the p4python library. For now using pydev gets it done for me.

Enjoy,
Pete

#2 Mailman Sync

Mailman Sync

    Advanced Member

  • Maillist Aggregator
  • 2495 posts

Posted 27 August 2014 - 11:05 AM

Originally posted to the perforce-user mailing list by: Michael Mirman


I do something similar. Our triggers are in perl, but this may work in other cases:

the line of the trigger I need to debug is changed to something like
xterm -display myhost:0 -e perlpath -d usual-trigger-goes-here

(On myhost, I obviously do something like xhost +).

For obvious reasons, I don’t do this against the production.
Fortunately, we have a test infrastructure where this method comes handy once in a while.

--Michael Mirman
MathWorks, Inc.
3 Apple Hill Drive, Natick, MA 01760
508-647-7555


-----Original Message-----
From: perforce-user-bounces@perforce.com [mailto:perforce-user-bounces@perforce.com] On Behalf Of phopkins
Sent: Wednesday, August 27, 2014 1:35 AM
To: perforce-user@perforce.com
Subject: [p4] Remote debug triggers and brokers howto


Posted on behalf of forum user 'phopkins'.

So I've asked before about peoples workflow on server side scripts, and from
what I can gather everyone is happy to debug local and do a lot of
'printf' when necessary. Not exactly the kind of way I like to develop.

So sharing this method which gives me excellent remote debugging of scripts when
they execute on a server.
��- I use python
��- I use eclipse
��- My server is linux, but eclipse client can be eclipse or windows.

Basically follow this guide here  
http://pydev.org/man...e_debugger.html

I had to add two lines to my sometrigger.dev.py script

import pydevd; pydevd.settrace('x.x.x.') #my client machine running
eclipse  
And 1 line to my bash wrapper script sometrigger.dev.sh

export PYTHONPATH=$PYTHONPATH:/p4/common/bin/triggers/pydev  
And copy the contents of pydev into /p4/common/bin/triggers/pydev

So now on any client when I do a 'p4 mytriggercommand' , it connects
back to my eclipse client and I have full eclipse python debugging at my
disposal.

I don't know if python has any built in remote development, but if it did it
might be good for Perforce to enable it in the p4python library. For now using
pydev gets it done for me.

Enjoy,
Pete



--
Please click here to see the post in its original format:
  http://forums.perfor...d-brokers-howto
_______________________________________________
perforce-user mailing list  -  perforce-user@perforce.com
http://maillist.perf...o/perforce-user


#3 Robert Cowham

Robert Cowham

    Advanced Member

  • PCP
  • 270 posts
  • LocationLondon, UK

Posted 27 August 2014 - 02:47 PM

Thanks for sharing - looks useful.

My advice for trigger writing is:
  • pass in stuff like p4port/p4user as part of trigger definition
  • ensure your framework detects and reports key issues in a helpful manner (this includes environment parameters, especially P4 related things such as port/user/password/p4tickets location etc)
  • have a good test harness - typically using the "rsh trick" for local p4d testing - so your tests can be easily run locally through a real local p4d
  • have a test environment for final testing

Co-Author of "Learning Perforce SCM", PACKT Publishing, 25 September 2013, ISBN 9781849687645

"It's wonderful to see a new book about Perforce, especially one written by Robert Cowham and Neal Firth. No one can teach Perforce better than these seasoned subject matter experts"
  • Laura Wingerd, author of Practical Perforce, former VP of Product Technology at Perforce





Also tagged with one or more of these keywords: trigger, broker, script, python, howto

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users