Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Adam Mercer
On Fri, Aug 9, 2013 at 8:42 AM, Antoon Pardon wrote: > That is probably beside the point. I suspect Adam is just giving a > minimal example to show the kind of thing he is trying to do. > > Nit picking the specific example instead of advising on the problem > is likely to be less than helpful. I

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Adam Mercer
On Fri, Aug 9, 2013 at 8:29 AM, Chris Angelico wrote: > You shouldn't need to use 'echo' here. Just provide tee with the text > on its standard input, and don't bother with the pipe at all. Thanks, that's much better! Cheers Adam -- http://mail.python.org/mailman/listinfo/python-list

Re: Using sudo to write to a file as root from a script

2013-08-09 Thread Adam Mercer
On Thu, Aug 8, 2013 at 11:47 PM, David wrote: > At a quick glance, I have a couple of suggestions. > >> command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] > > sudo doesn't work like this. It doesn't read from standard input. You > need to supply the command as an argument to sud

Using sudo to write to a file as root from a script

2013-08-08 Thread Adam Mercer
Hi I'm trying to write a script that writes some content to a file root through sudo, but it's not working at all. I am using: channel = 'stable' config_file = '/opt/ldg/etc/channel.conf' command = ['echo', '-n', channel, '|', 'sudo', 'tee', config_file] p = subprocess.Popen(command, stdo

Re: ValueError: I/O operation on closed file. with python3

2013-06-12 Thread Adam Mercer
On Wed, Jun 12, 2013 at 2:26 AM, Peter Otten <__pete...@web.de> wrote: > Applying these findings to your script: > > from contextlib import contextmanager > try: > # python-2.x > from urllib2 import urlopen > from ConfigParser import ConfigParser > > @contextmanager > def my_urlopen(url)

ValueError: I/O operation on closed file. with python3

2013-06-11 Thread Adam Mercer
Hi I'm trying to update one of my scripts so that it runs under python2 and python3, but I'm running into an issue that the following example illustrates: $ cat test.py try: # python-2.x from urllib2 import urlopen from ConfigParser import ConfigParser except ImportError: # python-3.x f

Re: Determining version of OpenSSL linked against python?

2012-01-25 Thread Adam Mercer
On Wed, Jan 25, 2012 at 15:21, Anssi Saari wrote: > I suppose you could use ctypes to load the library and call SSLeay() > which returns the OpenSSL version number as a C long. > > Like this: > > from ctypes import * > libssl = cdll.LoadLibrary("libssl.so") > openssl_version = libssl.SSLeay() > p

Re: Determining version of OpenSSL linked against python?

2012-01-25 Thread Adam Mercer
On Wed, Jan 25, 2012 at 14:56, Nick Dokos wrote: > One other possibility is to parse the output of ssh -V: > > , > | $ ssh -V > | OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010 > | $ python > | Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) > | [GCC 4.5.2] on linux2 > | Type "he

Re: Determining version of OpenSSL linked against python?

2012-01-25 Thread Adam Mercer
On Wed, Jan 25, 2012 at 14:04, Terry Reedy wrote: > If you are not willing to tell Debian Squeeze users to install 2.7, or that > they cannot run your program, ask the bug reporter to tell you what version > of OpenSSL the system comes with and code it into your program. I would like to only sup

Re: Determining version of OpenSSL linked against python?

2012-01-25 Thread Adam Mercer
Hi Is this possible at all? Cheers Adam On Mon, Jan 23, 2012 at 14:01, Adam Mercer wrote: > Hi > > I'm trying to write a script that determines the version of OpenSSL > that python is linked against, using python-2.7 this is easy as I can > use: > >    import ss

Determining version of OpenSSL linked against python?

2012-01-23 Thread Adam Mercer
Hi I'm trying to write a script that determines the version of OpenSSL that python is linked against, using python-2.7 this is easy as I can use: import ssl ssl.OPENSSL_VERSION but unfortunately I need to support python-2.6, from an older script I used the following: import _ssl

Re: Determining version of OpenSSL

2011-04-04 Thread Adam Mercer
On Mon, Apr 4, 2011 at 16:44, Martin v. Loewis wrote: >> is there a way that this can be done in python2.4? It's annoying but I >> need to support python2.4 for a while yet :-( > > ldd /usr/lib/python2.4/lib-dynload/_ssl.so > [...] >        libssl.so.0.9.8 => /usr/lib/libssl.so.0.9.8 (0x7f6a5

Determining version of OpenSSL

2011-04-04 Thread Adam Mercer
Hi I'm trying to determine the version of OpenSSL that a given python is compiled against, with python2.7 I can do this with: import ssl ssl.OPENSSL_VERSION is there a way that this can be done in python2.4? It's annoying but I need to support python2.4 for a while yet :-( Cheers Adam -- http

Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-17 Thread Adam Mercer
On Sat, Jul 17, 2010 at 15:20, Heikki Toivonen wrote: > I was actually planning on doing a release by the end of June, but life > happened. Maybe by the end of August... Know what whats like :-) I've backported the OpenSSL patches for the MacPorts port so for the time being this particular fire

Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-16 Thread Adam Mercer
On Fri, Jul 16, 2010 at 02:09, Heikki Toivonen wrote: > That version of M2Crypto does not work with OpenSSL 1.0.x because OpenSSL > changed APIs. M2Crypto trunk works, as will the next M2Crypto release. So at > this time, you should check out M2Crypto from the Subversion repository. See > http://

Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-15 Thread Adam Mercer
On Thu, Jul 15, 2010 at 14:10, John Nagle wrote: >   I had a similar problem back in 2007.  See > > http://bytes.com/topic/python/answers/613336-more-m2crypto-build-problems > > Also see > > http://bytes.com/topic/python/answers/711381-m2crypto-0-18-new-version-same-old-build-bugs > >   There have

Re: M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-14 Thread Adam Mercer
Anyone have any ideas about this? Cheers Adam On Tue, Jul 13, 2010 at 16:18, Adam Mercer wrote: > Hi > > I'm trying to build M2Crypto on Mac OS X 10.6.4 against python2.5 > (python2.6 fails in the same way), with SWIG 2.0.0 and OpenSSL 1.0.0a > and it is failing with th

M2Crypto-0.20.2, SWIG-2.0.0, and OpenSSL-1.0.0a build problem

2010-07-13 Thread Adam Mercer
Hi I'm trying to build M2Crypto on Mac OS X 10.6.4 against python2.5 (python2.6 fails in the same way), with SWIG 2.0.0 and OpenSSL 1.0.0a and it is failing with the following: 105 :info:build swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c 106 :info:build swig -python -I/opt/local/Lib