On Tue, Feb 16, 2016 at 10:06 PM, Ritesh Raj Sarraf wrote: > When you say use apt's settings, you mean use the output of its path? > Or determine at runtime ?
Either use the output of apt-config or the python-apt equivalents, depending on which apt-offline backend you are using. # apt-config version for the apt backend import subprocess command = """ # Unset variables in case they are set already unset trusted unset trustedparts # Get the variables from apt eval $(apt-config shell trusted Dir::Etc::trusted/f) eval $(apt-config shell trustedparts Dir::Etc::trustedparts/d) # Securely pass the variables back to python-apt printf "%s\\0%s" "$trusted" "$trustedparts" """ process = subprocess.Popen(['sh'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) output = process.communicate(input=command)[0] trusted, trustedparts = output.split('\x00') # python-apt version for the python-apt backend import apt_pkg apt_pkg.init() trusted = apt_pkg.config.find_file('Dir::Etc::trusted') trustedparts = apt_pkg.config.find_dir('Dir::Etc::trustedparts') -- bye, pabs https://wiki.debian.org/PaulWise