]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/examples/python/FDStartUp.py
Fix #1648 about make_catalog_backup.pl with multiple catalog
[bacula/bacula] / bacula / examples / python / FDStartUp.py
index 0ef8ea993b80fa98aa454c79efe7d89d0b8fe3a4..4d53e33bfc987463154dc79803fb72d6aea8673f 100644 (file)
@@ -6,7 +6,7 @@ import sys, bacula
 
 # This is the list of Bacula daemon events that you
 #  can receive.
-class BaculaEvents:
+class BaculaEvents(object):
   def __init__(self):
      # Called here when a new Bacula Events class is
      #  is created. Normally not used 
@@ -23,20 +23,20 @@ class BaculaEvents:
      job.set_events(events)       # register events desired
      sys.stderr = events          # send error output to Bacula
      sys.stdout = events          # send stdout to Bacula
-     jobid = job.get("JobId")
-     client = job.get("Client")
-     job.set(JobReport="Python FD StartJob: JobId=%d Client=%s \n" % (jobid,client))
+     jobid = job.JobId
+     client = job.Client
+     job.JobReport="Python FD JobStart: JobId=%d Client=%s \n" % (jobid,client)
      return 1
 
   # Bacula Job is going to terminate
   def JobEnd(self, job):    
-     jobid = job.get("JobId")
-     client = job.get("Client") 
-     job.set(JobReport="Python FD EndJob output: JobId=%d Client=%s.\n" % (jobid, client))
-     return 1
+     jobid = job.JobId
+     client = job.Client 
+     job.JobReport="Python FD JobEnd output: JobId=%d Client=%s.\n" % (jobid, client)
+     
 
   # Called here when the Bacula daemon is going to exit
-  def Exit(self, job):
+  def Exit(self):
       noop = 1
      
 bacula.set_events(BaculaEvents()) # register daemon events desired
@@ -44,7 +44,7 @@ bacula.set_events(BaculaEvents()) # register daemon events desired
 """
   There are the Job events that you can receive.
 """
-class JobEvents:
+class JobEvents(object):
   def __init__(self):
      # Called here when you instantiate the Job. Not
      # normally used
@@ -55,21 +55,20 @@ class JobEvents:
      self.job.write(text)
 
   # Open file to be backed up. file is the filename
-  def open(self, file):
+  def Python_open(self, file):
      print "Open %s called" % file
-     self.fd = open('m.py', 'rb')
-     jobid = self.job.get("JobId")
-     print "Open: JobId=%d" % jobid
-     print "name=%s" % bacula.name
-
+     self.fd = open(file, 'rb')
+     jobid = self.job.JobId
+     print "Open: %s" % file
   # Read file data into Bacula memory buffer (mem)
   #  return length read. 0 => EOF, -1 => error
-  def read(self, mem):
+  def Python_read(self, mem):
      print "Read called\n"
      len = self.fd.readinto(mem)
      print "Read %s bytes into mem.\n" % len
      return len
 
   # Close file
-  def close(self):
+  def Python_close(self):
      self.fd.close()