Hello All, I am trying to use the Python scripting facility in Bacula.
An initial test (in the JobEvents class per the DirStartup.py example file distributed with Bacula)... def NewVolume(self, job): job.JobReport = "Python: in NewLabel method (1)" job.JobReport = "Python: in NewLabel method (2)" print "Python: in NewLabel method (3)" job.VolumeName = str(job.JobId) + ".bac" return 1 produces the log output: 21-Jun 14:53 soga-dir JobId 1397: Start Backup JobId 1397, Job=SogaBkup.2011-06-21_14.53.12_03 21-Jun 14:53 soga-dir JobId 1397: Python: in NewLabel method (1) 21-Jun 14:53 soga-dir JobId 1397: Using Device "FileStorage" 21-Jun 14:53 soga-sd JobId 1397: Labeled new Volume "1397.bac" on device "FileStorage" (/d2/bacula/new). ... 1. What happened to the "Python: in NewLabel method (2)" message?! The examples file clearly shows multiple uses of job.JobReport. (And secondarily, I presume .JobReport is a Python property, yes? Otherwise, were it an ordinary Python attribute, multiple assignments would not only be ineffective, but the last assignment, not the first, would win.) What is wrong with either: a) my code, or b) my understanding, or c) Bacula? 2. What happened to the "Python: in NewLabel method (3)" message? Again, the examples show print statements being used but the documentation is silent on what effect they have. One could guess looking at the sys.stdout = events # send stdout to Bacula line in the example BaculaEvents.JobStart method that they also go to the log, but then what is the difference between "print" and JobReport? If anyone has used the Python interface and can shine some enlightenment on me, I will be very grateful. ~~~~ Using Bacula 5.0.3, Python 2.7.1, both as packaged by Fedora-15. Here is my entire DirStartup.py file for reference: import sys, bacula class BaculaEvents(object): def __init__(self): pass def JobEnd(self, job): pass def Exit(self, job): pass def JobStart(self, job): events = JobEvents() # create instance of Job class events.job = job # save Bacula's job pointer job.set_events(events) # register events desired sys.stderr = events # send error output to Bacula sys.stdout = events # send stdout to Bacula bacula.set_events(BaculaEvents()) # register daemon events desired class JobEvents(object): def __init__(self): pass def JobInit(self, job): pass def JobRun(self, job): pass def VolumePurged(self, job): pass def write(self, text): pass [*] def open(self, file): pass def read(self, mem): pass def close(self): pass def NewVolume(self, job): job.JobReport = "Python: in NewLabel method (1)" job.JobReport = "Python: in NewLabel method (2)" print "Python: in NewLabel method (3)" job.VolumeName = str(job.JobId) + ".bac" return 1 [*] I tried this as "pass" as shown and also as defined in the examples file, "self.job.write(text)", but it made no difference in the results above. ------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users