On Thursday 27 April 2006 14:35, Michael 'buk' Scherer wrote: > Hey folks. > > I just started fiddling with those "new" Python options and wonder if its > possible to execute something like a console-command through Python? > I don't want to do this by executing some external shell scripts but maybe > through something of the "bacula" pyobj I don't know (yet). > > In my example I want to prune/purge a tape from within the NewVolume-Event.
I think this should be completely possible, but I have not implemented it because it could potentially have problems of recursion. For example, a NewVolume event is generated, you call back, and another NewVolume event is generated, ... I think that can be avoided, but it will require a small amount of thought an a lot of testing. The currently implemented Python code can call back and start a job, but in that case, I was relatively sure it would not lead to recursion. In fact, there are three things I would like to implement: 1. A new FileSet Options directive that causes all file/directive names to be passed to a Python method (a Bacula event), and Python returns a yes or no saying the file matches (much like Wild or Regex), and depending on whether or not Exclude is set, the file would then either be accepted or excluded. This should be trivial to do, and would allow users to implement whatever they way, including ideas that I find a security problem -- that is reading a special file in a directory to decide what files in that directory should be backed up. 2. Implement a Python console command that creates an event and simply passes the command line argument to Python as a string: python "some string" This would allow you to run a Python script from the console, or do anything. 3. Allow Python to submit any console command and get back the output, which is what you requested. This coupled with the above would mean you could do full scripting with Python by submitting a single command line. Of course, it probably means you could get into a lot of trouble too. I'll probably do item 1 in 1.39, but the other two items will either need to be contributed or wait until the next release cycle. They will not require an enormous amount of code, but will need a *lot* of debugging and probably require a lot of fixing to stabalize them. -- Best regards, Kern ("> /\ V_V ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users