Hi,

26.10.2007 16:56,, Rich wrote::
> On 2007.10.26. 14:04, Rich wrote:
>> i've recompiled bacula 2.2.5 with python. configure output claims it is 
>> enabled :
>> Python support:             yes
>>
>> but even starting director with -f -d90 doesn't produce any messages - 
>> manual claims that a message should be printed :
>>
>> 09-Jun 15:14 bacula-dir: ERROR in pythonlib.c:131 Could not import
>> Python script /etc/bacula/scripts/DirStartUp. Python disabled.
>>
>> i did not do 'make clean' after enabling python - was that required ?
> 
> ok, this didn't help. even after a clean compile bacula dos not attempt 
> to use scripts.
> i even tried with strace -e file, not even a single attempt to load any 
> python script.
> 
> turns out, i must explicitly add "Scripts Directory" parameter... from 
> manual, i understood that bacula would be looking in /etc/bacula/scripts 
> by default - it says "normal default /etc/bacula/scripts".
> 
> so, some suggestions/problems i noticed :)
> 
> 1. "(normal default /etc/bacula/scripts," - unclosed parenthesis in the 
> manual.
> also, this paragraph probably should note that the directive has to be 
> added and no actual default is enabled.

That should be added to the manual...

> 2. if "Scripts Directory" is specified in director configuration file, 
> director can't be stopped with ctrl+c, when run in foreground;

I don't know if this qualifies as a bug - because, in normal 
circumstances, you should only run the DIR in foreground under the 
debugger (Kern says ;-) - but I don't think this is serious.

> 3. if bacula is compiled with python support, maybe it is worth adding 
> this parameter to the default director configuration file ?
> ------------------------------------------

Probably. The packagers should take care of this, too.

> now, for the actual scripts...
> 
> 1. the example is using both lines with spacing and without spacing 
> around equal sign (a=b and a = b). which would be a better style choice ?

I prefer the spaces around operators because it creates much better 
readability. Others disagree.

> 2. it seems that i got it partially working by using the following lines :
>       Vol = "%s_%s-%s-%d" % (job.Pool, job.Job, job.Level, numvol)
>       job.JobReport = "Exists=%d %s" % (job.DoesVolumeExist(Vol), Vol)
>       job.VolumeName=Vol
> 
> are there any huge mistakes ?

No, this looks about correct.

> 3. can i somehow avoid this %d, %s thing and specifying variables after 
> that ? like, writing someting like {job.Pool)_{job.Job}-{job.Level} etc.

You could concatenate the job attributes and the extra characters like 
"str(job.Pool) + '_' + str(job.Job) + ... (or something similar - I 
don't have access to any python documentation and examples currently) 
but the original syntax is moch more easy to read IMO.

> 4. does somebody have example on writing out datetime string that would 
> reproduce behaviour that label format currently produces for 
> "${Year}.${Month:p/2/0/r}.${Day:p/2/0/r}-${Hour:p/2/0/r}.${Minute:p/2/0/r}" 
> ?

Again, no examples, manuals, or even working code, but something like

import datetime

now = datetime.datetime.now()

Vol = "%4d.%2d.%2d-%2d.%2d" % (now.year, now.month, now.day, now.hour, 
now.minute)

should work.

> 5. a (slightly modified) line reads :
> job.JobReport = "Exists=%d %s" % (job.DoesVolumeExist(Vol), Vol)
> 
> if i understand correctly, it would only add a line to the report and 
> proceed, right ?

Yup.

> it seems that in such a case job simply stucks, waiting for a manual 
> volume specification.
> can i make a check that would error out if such a volume already exists ?

Sure. Check the volume name you just created using DoesVolumeExist, 
and if it already exists, append or modify a suffix and loop. 
Otherwise, continue.

Hope this helps,

Arno

-- 
Arno Lehmann
IT-Service Lehmann
www.its-lehmann.de

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bacula-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to