Merge lp:~ryan-c-ahearn/backintime/callback_exit_feature into lp:backintime/1.0

Proposed by Ryan Ahearn
Status: Merged
Merged at revision: not available
Proposed branch: lp:~ryan-c-ahearn/backintime/callback_exit_feature
Merge into: lp:backintime/1.0
Diff against target: None lines
To merge this branch: bzr merge lp:~ryan-c-ahearn/backintime/callback_exit_feature
Reviewer Review Type Date Requested Status
Back In Time Team Pending
Dan Pending
Review via email: mp+11323@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ryan Ahearn (ryan-c-ahearn) wrote :

This change in usercallbackscript.py outputs the stdout and stderr of user.callback into syslog and will exit the backup if user.callback returns a non-0 exit code.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/usercallbackplugin.py'
2--- plugins/usercallbackplugin.py 2009-05-26 10:03:17 +0000
3+++ plugins/usercallbackplugin.py 2009-09-07 18:13:23 +0000
4@@ -22,6 +22,8 @@
5 import tools
6 import logger
7 import gettext
8+from subprocess import Popen
9+from subprocess import PIPE
10
11 _=gettext.gettext
12
13@@ -39,7 +41,17 @@
14
15 def notify_callback( self, args = '' ):
16 logger.info( "[UserCallbackPlugin.notify_callback] %s" % args )
17- os.system( "sh \"%s\" %s" % ( self.callback, args ) )
18+ try:
19+ callback = Popen( "\"%s\" %s" % ( self.callback, args ), shell=True, stdout=PIPE, stderr=PIPE )
20+ output = callback.communicate()
21+ if output[0]:
22+ logger.info( "[UserCallbackPlugin.notify_callback callback output] %s" % output[0] )
23+ if output[1]:
24+ logger.error( "[UserCallbackPlugin.notify_callback callback error] %s" % output[1] )
25+ if callback.returncode != 0:
26+ exit()
27+ except OSError:
28+ logger.error( "[UserCallbackPlugin.notify_callback] Exception when trying to run user callback" )
29
30 def on_process_begins( self ):
31 self.notify_callback( '1' )

Subscribers

People subscribed via source and target branches