[Piuparts-devel] Chroot.create_apt_conf

Herbert Fortes terberh at gmail.com
Sat Feb 23 12:35:51 GMT 2019


On 2/21/19 1:17 PM, Herbert Fortes wrote:
> On 2/21/19 11:37 AM, Andreas Beckmann wrote:
>> Did someone consider using
>>
>> apt-config dump Acquire::http::Proxy
>>
> 
> What I should did at first.


Patch with Andreas tips:

https://github.com/hpfn-d/piuparts_3/pull/23/commits/d1ec2798d4a170efaab739fe7988de5e8e056d8b

proxy will be '' or the entire text (PY2 and Py3).

>>> import subprocess
>>> p = subprocess.Popen(['apt-config', 'dump', 'Acquire::http::Proxy'], stdout=subprocess.PIPE, encoding='utf-8')
>>> s, _ = p.communicate()
>>> if s: print(s)
... 
Acquire::http::Proxy "http://www.proxy.com:89/";

>>> 

In version 3.3 timeout was added to p.communicate()
https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate



Regards,
Herbert

obs: lines does not need to be a list(). Or at least 
     the first 4 lines.append() are not necessary.

     The way it was written looks like a string '+='.  Using
     a string concat, the "''.join()" is not needed when 
     'create_file()'.
     
     IMO string concat is better than a list() in this case.



More information about the Piuparts-devel mailing list