Re: [Tutor] pydoc introspecting info via OptionParser?

2008-03-15 Thread Neal McBurnett
On Fri, Mar 14, 2008 at 10:43:08AM -0700, Neal McBurnett wrote:
 I'm trying to do nice clean documentation for a python script I run
 from the command-line, and I'd like pydoc or a similar program to
 document it well.  But I don't want to duplicate option information by
 putting it both in my docstring and in optparse.
 
 I would think that pydoc might notice an OptionParser instance at the
 module level and show the options defined there, but it doesn't seem
 to.  Would it be hard to add to pydoc?  Do any other documentation
 programs do that?

For now I've instead put this quasi-template-tag in my docstring in
an appropriate place: %InsertOptionParserUsage%

and added this code to the module to incorporate the usage into the
docstring after it is defined:

# incorporate OptionParser usage documentation in our docstring
__doc__ = __doc__.replace(%InsertOptionParserUsage%\n, parser.format_help())

That gets me pretty close.  The biggest problem is that when pydoc
prints it, the usage statement starts with Usage: pydoc [options]
rather than Usage: myprogram [options].  I could set the
OptionParser prog option to override that, but I prefer that in real
life the program provide usage referencing sys.argv[0] rather than
hard-coding it, in case it gets deployed under a different name.

Comments?

Neal McBurnett http://mcburnett.org/neal/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pydoc introspecting info via OptionParser?

2008-03-14 Thread Neal McBurnett
I'm trying to do nice clean documentation for a python script I run
from the command-line, and I'd like pydoc or a similar program to
document it well.  But I don't want to duplicate option information by
putting it both in my docstring and in optparse.

I would think that pydoc might notice an OptionParser instance at the
module level and show the options defined there, but it doesn't seem
to.  Would it be hard to add to pydoc?  Do any other documentation
programs do that?

I know that on aspn there is a library to parse a docstring and pass
options to optparse:
 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278844

But it has limitations (doesn't support all of optparse, won't work
with -OO) and is a bit uglier.

Cheers,

Neal McBurnett http://mcburnett.org/neal/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python-based system programming and admin?

2006-01-22 Thread Neal McBurnett
On Sun, Jan 22, 2006 at 06:19:55PM -0600, Hugo González Monteverde wrote:
 I used to do perl on linux until I found Python, I find it very easy to 
 run quick scripts and system stuff without having to learn BASH, sed, 
 awk, etc separately, taht way I can do regexp, listings, recursion on 
 directories, batch jobs, etc.
 
My question is exactly how to let someone do that securely on a remote
machine.  I've looked at ipython now, and I think it is ideal for the
purpose - I just have to tell the user to ssh in and run 'ipython' to
get a familiar and flexible environment.

 I'm thinking that perhaps allowing him to run idle and exporting X 
 display to the Mac could be an option?

The system is a server - doesn't even need X libraries, which are a
significant source of security concerns.

Thanks,

Neal McBurnett http://bcn.boulder.co.us/~neal/
Signed and/or sealed mail encouraged.  GPG/PGP Keyid: 2C9EBA60
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python-based system programming and admin?

2006-01-20 Thread Neal McBurnett
I'm an experienced linux guy, with lots of python interest and some
python experience.

I'm helping a colleague develop software to run on our linux server.
He has python skill, but doesn't know the shell or linux very well at
all.

I'd like to give him a secure, safe, flexible development environment
on the serve, (which does audio streaming and other fun things).

At the moment, he has an account and can connect from his mac via ssh,
and copy files back and forth (ftp-like stuff - I forget which ssh
client).  But he doesn't want to log in to a bash shell and learn a
whole new way to do things.  But he does want to run programs.

Editing python scripts spawned by cron is one of the goals.
But developing them by waiting for cron to fire and send the output
via email is pretty painful

The server currently doesn't need to run a web server, and I'm
reluctant to introduce new services that have much security risk
associated with them, but something like that seems like a
possibility.

One idea that just popped in my brain is to give him a python login
shell on linux - any advice on how to do that?

Other possibilities, I guess:

 - An https-based web server with and mod-python, somehow configured
   so that his jobs run as him.

 - a pure-python server (via twisted?) running as him

 - moinmoin or the like

 - zope or plone (not sounding very simple any more, but I've done a
   bit of this )

What would be the safest, simplest solution that was adequate for
providing a reasonable development environment?

Any ideas I haven't thought of yet?

Cheers,

Neal McBurnett http://bcn.boulder.co.us/~neal/
Signed and/or sealed mail encouraged.  GPG/PGP Keyid: 2C9EBA60
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor