Re: FW: python import sys.path

2009-01-02 Thread Fuzzyman
On Jan 2, 2:28 pm, John Machin  wrote:
> On Jan 3, 1:09 am, "Kelly, Brian"  wrote:> After 
> following your suggestions I was able to confirm that the 2.5
> > interpreter was being invoked. So then I grepped for all instances of python
> > in the scripts that were imported as modules: from bacula_conf import *
>
> > The calling script cleanup.py is invoking purge_client.py like an external
> > script:
>
> > def purgeAll(options, computer_name):
> >     cmd = "python purge_client.py %s" % computer_name
> >     if options.pretend <> True:
>
> Who wrote that?
>
> >         error = os.system(cmd)
> >     else:
> >         _log.info("Done. No changes made due to --pretend flag.")
>
>             error is not defined in this branch>     if not error:  
> Splat!
> >         return True
> >     else:
> >         return False
>
>  AArrgh! Try:
>
>    return not error
>

That will still blow up with a NameError when the path doing the
logging is invoked.

How about:


def purgeAll(options, computer_name):
cmd = "python purge_client.py %s" % computer_name
if options.pretend != True:  # if not options.pretend (assuming it
is a bool)
error = os.system(cmd)
return not error

_log.info("Done. No changes made due to --pretend flag.")
return True


Michael
--
http://www.ironpythoninaction.com/
--
http://mail.python.org/mailman/listinfo/python-list


Re: FW: python import sys.path

2009-01-02 Thread John Machin
On Jan 3, 1:09 am, "Kelly, Brian"  wrote:
> After following your suggestions I was able to confirm that the 2.5
> interpreter was being invoked. So then I grepped for all instances of python
> in the scripts that were imported as modules: from bacula_conf import *
>
> The calling script cleanup.py is invoking purge_client.py like an external
> script:
>
> def purgeAll(options, computer_name):
>     cmd = "python purge_client.py %s" % computer_name
>     if options.pretend <> True:
Who wrote that?


>         error = os.system(cmd)
>     else:
>         _log.info("Done. No changes made due to --pretend flag.")
    error is not defined in this branch
>     if not error:  Splat!
>         return True
>     else:
>         return False
 AArrgh! Try:

   return not error

> When I saw the imports I assumed the functions in purge_client.py were being
> referenced from the calling scripts symbol table.

What does that mean??

--
http://mail.python.org/mailman/listinfo/python-list