rcslib.py doesn't like dot in revision numbers?

2005-07-22 Thread Chris Shenton
[Disclaimer: I'm a python newbie.]

I'm using rcslib.py to massage an RCS repo.  The code uses a
"name_rev" object which acts two ways:

1. if it's a string, represents the head version of the file
2. if a tuple (name, rev) represents a name and a revision

Works fine if I use it like:

  checkout('myfile.txt')

but if I invoke it with a version like:

  checkout('myfile.txt', '1.1')

it complains about a bad character in the revision.  The code which
 checks this is here:  

  if c not in self.okchars:
   raise ValueError, "bad char in rev"

and the chars that it thinks are OK are defined as:

  okchars = string.ascii_letters + string.digits + '-_=+'

These okchars do not include '.' so normal numeric revision numbers
are not accessible.  

Am I missing something? I can't find any doc on the library.  I'm
using the one from http://www.darkcoding.net/projects/rcslibtext.py
which is newer than the allegedly abandoned under Python's pdist
directory of tools, but these both have the same behavior on this. Is
there some other facility I should be using instead of rcslib, like
rcsclient.py?

Thanks for any pointers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Logging: how to suppress default output when adding handlers?

2007-06-05 Thread Chris Shenton
I am setting up handlers to log DEBUG and above to a rotating file and
ERROR and above to console.  But if any of my code calls a logger
(e.g., logging.error("foo")) before I setup my handlers, the logging
system will create a default logger that *also* emits logs, which I
can't seem to get rid of.  Is there a way I can suppress the creation
of this default logger, or remove it when I 'm setting up my handlers?
Thanks.

Sample code:

  import sys, logging, logging.handlers

  if len(sys.argv) > 1:
  logging.warning("Logging before setting handlers adds unwanted default 
logger")

  logging.getLogger().setLevel(logging.DEBUG)

  console = logging.StreamHandler()
  console.setLevel(logging.ERROR)
  console.setFormatter(logging.Formatter('%(levelname)-8s %(module)s: 
%(message)s'))
  logging.getLogger().addHandler(console)

  filelog = logging.handlers.RotatingFileHandler("/tmp/logtest2.log")
  filelog.setFormatter(logging.Formatter('%(asctime)s %(levelname)-8s 
%(module)s: %(message)s'))
  filelog.setLevel(logging.DEBUG)  # NOP since default above is DEBUG, but 
OK
  logging.getLogger().addHandler(filelog)

  logging.debug("TEST debug")
  logging.warning("TEST warning")
  logging.error("TEST error")


Sample runs, first without initial log call (good), then with one
showing the default log messages in the mix (bad); I'm showing the
console and tailing the logfile so they're mixed together but the
timestamp indicates the file logs:

  [EMAIL PROTECTED]:/tmp<103> tail -f /tmp/logtest2.log &

  [EMAIL PROTECTED]:/tmp<118> python /tmp/logtest2.py 
  2007-06-05 09:36:27,234 DEBUGlogtest2: TEST debug
  2007-06-05 09:36:27,234 WARNING  logtest2: TEST warning
  ERRORlogtest2: TEST error
  2007-06-05 09:36:27,239 ERRORlogtest2: TEST error

  [EMAIL PROTECTED]:/tmp<119> python /tmp/logtest2.py  this gives ugly logger
  WARNING:root:Logging before setting handlers adds unwanted default logger
  DEBUG:root:TEST debug
  2007-06-05 09:36:30,069 DEBUGlogtest2: TEST debug
  WARNING:root:TEST warning
  2007-06-05 09:36:30,072 WARNING  logtest2: TEST warning
  ERROR:root:TEST error
  ERRORlogtest2: TEST error
  2007-06-05 09:36:30,073 ERRORlogtest2: TEST error
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Logging: how to suppress default output when adding handlers?

2007-06-05 Thread Chris Shenton
Vinay Sajip <[EMAIL PROTECTED]> writes:

> The default handler is created because you are calling the convenience
> functions of the logging package: logging.error, etc. If you don't
> want the default handler to be created, either
>
> (a) Configure the logging system yourself before any logging call is
> made (I'm not sure why you're not doing this - it could be done in
> your main script before anything else happens) - or

Yeah, I think this is the cause.  Unfortunately I'm using a couple
dozen files and a bunch more libraries and if they're doing a
logging.debug() or whatnot they're creating this.  

Do you have any ideas how I can trace where the first call is made?
This seems a newbie question but if I have a bunch of other files
which do stuff like "from sqlalchemy import *" they might be invoking
a logging call so I'm not sure how to chase these down.

> (b) Make calls on a specific named logger, e.g.
> logging.getLogger("logtest2").error("foo"), rather than
> logging.error("foo") which is for casual/unsophisticated use only.

I'm dreading having to be so verbose with my (copious) loggers, which
is why I was curious if there was a way to nuke any auto-created
ones.  I thought calling logging.shutdown() before configuring my
loggers might do this but it didn't.  

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


RSA SecurID token authentication?

2007-05-29 Thread Chris Shenton
Anyone doing python application authentication using RSA SecurID
tokens?  We have a Pylons app that needs this.   

I've written code against RSA's API and found the docs terrible and
the libraries painful to use.   RSA has a RADIUS server fronting their
server so I expect I could use that instead, might be easier.  This is
on Solaris10 x86 which supports PAM but I've never accessed PAM from
Python, any pointers?

I've done RADIUS before (Cistron, Ascend, FreeRADIUS) but not with
Python. Any suggestions? I see a pyrad library, last updated in March
2006; any experience with it? Any other suggestions?

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


python setup.py: how to override a setup.cfg value ?

2007-08-23 Thread Chris Shenton
I'm building python-ldap and need to change values of library and
include paths that are in the setup.cfg file.  This is an automated
build (using "buildit") so I'd prefer not to have edit the .cfg by hand,
with sed, or even with buildit's Substitute().

I'd like to be able to do something like I'd do with "make", specify a
value on the command line like:

  make -Dprefix=/usr/local

or in this case

  python setup.py -Dlibs="ldap lber" build   [Does NOT work]

I cannot see how to do this from the --help or from googling.  
The closest I've gotten is to do:

  python setup.py setopt --command=_ldap --option=libs --set-value="ldap lber"

but that overwrites the python.cfg, a bit rude it seems to me. 

Am I missing something? is there a way to override a .cfg value on the
command line while running a setup.py command like "build" or "install"?

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


TimedRotatingFileHandler() isn't rotating at midnight?

2007-01-31 Thread Chris Shenton
I set this up 3 days ago and have not seen any of the logs I've
created this way being rotated.  I expected them to rotate every
midnight.  I'm calling the code that uses this logger many times, each
a separate run, if that matters.

Am I doing something stupid? I can't find anything on google and don't
see anything in the code that would prevent rotating. 

Thanks.

import logging, logging.handlers
logging.getLogger().setLevel(logging.DEBUG) # override default of WARNING

logfile = logging.handlers.TimedRotatingFileHandler(filename, 'midnight', 1, 
backupCount=14)
logfile.setLevel(logging.DEBUG)
logfile.setFormatter(logging.Formatter('%(asctime)s %(levelname)-8s %(module)s: 
%(message)s'))
logging.getLogger().addHandler(logfile)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TimedRotatingFileHandler() isn't rotating at midnight?

2007-02-09 Thread Chris Shenton
"Vinay Sajip" <[EMAIL PROTECTED]> writes:

> It might. I assume you have a long-running process which runs past
> midnight - that's the scenario that TimedRotatingFileHandler is meant
> for. Can you post a complete minimal example which shows the problem?

> Rotating should happen when the logging process creates the handler
> before midnight and makes a logging call destined for that handler
> after midnight.

Ah, then maybe I'm expecting the wrong thing.  The python code is
invoked from cron every 10 minutes or so, it's not long-running.
Each time it opens the same log file.  Sounds like this isn't going to
do what I want.

Thanks for the clarification. 
-- 
http://mail.python.org/mailman/listinfo/python-list