See these resources:

http://docs.python.org/tutorial/modules.html#executing-modules-as-scripts
http://docs.python.org/using/cmdline.html#interface-options (-m)
http://www.5dollarwhitebox.org/drupal/node/75
________________________________________
Von: Hans Sebastian [[email protected]]
Gesendet: Donnerstag, 17. Februar 2011 16:59
An: Jürgen Hermann
Cc: ML - python-projects
Betreff: Re: [Python-projects] pylint exits with too many open files

2011/2/16 Jürgen Hermann 
<[email protected]<mailto:[email protected]>>
> My task is basically to find all python scripts in the source repository and 
> run pylint on each.

The best way to do that is to make your scripts (almost) look like any other 
module in your package, and then either start them via "python -m 
yourpkg.scripts.foo", or use "console_scripts" entry points (which conveniently 
causes setuptools/distribute to auto-generate wrapper scripts for the target 
platform).

I don't quite get what you mean here. Currently in the source tree there are a 
few places where there are dirs that are python modules with submodules and 
classes. In some other places, there are python scripts that lie on its own as 
a one-off script. Do you mean I make those one-off scripts like any other 
module? How can I do that. Ideally I would like to run pylint without making 
any edits. Meanwhile, let me research further on these topics.

Currently, I do this and seems to have eliminated some of the import errors:
        targetfile = args[0]
        targetfiledir = os.path.dirname(targetfile)
        if dir not in sys.path
            sys.path.insert(1, dir)
        try:
            lint.Run(args)
        except OSError, e:

It can also be, perhaps, some python codes are obsolete and import modules that 
are not there so I am talking to the code owners to find out. Thanks for the 
help


For pylint the scripts then ARE like any other module. Just make sure you 
follow the __name__ == "__main__" idiom, i.e. have your scripts importable and 
w/o any top-level logic.
_______________________________________________
Python-Projects mailing list
[email protected]<mailto:[email protected]>
http://lists.logilab.org/mailman/listinfo/python-projects

_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to