[TIP] coverage for any python process that run (regardless of user)

Ned Batchelder ned at nedbatchelder.com
Wed Feb 1 16:46:19 PST 2012


On 2/1/2012 7:07 PM, Dustin Lee wrote:
> I'm attempting to set up coverage to run for *any* python process that 
> runs on a specific server.
>
> currently I have the following in sitecustomize.py
>
> import os
> os.environ['COVERAGE_PROCESS_START']='/home/dlee/.coveragerc'
> import sys
> sys.path.append('/home/dlee/downloads/python/coverage-3.5.1/')
> import coverage
> coverage.process_startup()
>
>
> The problem is that some of the processes run as root and some run as 
> particular users.  This was causing the non-root processes to fail due 
> to the fact that they couldn't write to the .coverage file.
>
> Is there some way to automagically open up .coverage to be writable by 
> anything?  (Does coverage manage perms at all or should I just do this 
> with umask maybe?  (I don't want to mess with this and change how 
> particular programs behave))
>
Coverage.py does no manipulation of permissions for the data file.  It 
tries to write it, and either can or can't.  You'll have to use the OS 
tools to make sure it can.
> Is there some easy way to have each process write to a different file 
> so they don't stomp on each other?  I see there is a  --parallel-mode 
> switch but is there a way to set this up automatically?  My goal is to 
> have ALL processes run coverage.py nolens volens.
I would think parallel mode is exactly what you want.  You can enable it 
in the .coveragerc file with:  [run]\n parallel=True

--Ned.
>
> thanks,
>
> dustin
>
> -- 
> Dustin Lee
> qhfgva=rot13(dustin)
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20120201/0b4dc173/attachment.htm>


More information about the testing-in-python mailing list