backportpackage: Run lsb_release as command if the Python module is not available

This commit is contained in:
Gioele Barabucci 2022-09-28 08:18:52 +02:00 committed by Stefano Rivera
parent 05af489f64
commit a3c87e78aa

View File

@ -27,7 +27,10 @@ import sys
import tempfile
from urllib.parse import quote
import lsb_release
try:
import lsb_release
except ImportError:
lsb_release = None
from httplib2 import Http, HttpLib2Error
from distro_info import DebianDistroInfo, UbuntuDistroInfo
@ -396,11 +399,17 @@ def main(args):
Launchpad.login_anonymously(service=opts.lpinstance)
if not opts.dest_releases:
distinfo = lsb_release.get_distro_information()
try:
current_distro = distinfo['ID']
except KeyError:
error('No destination release specified and unable to guess yours.')
if lsb_release:
distinfo = lsb_release.get_distro_information()
try:
current_distro = distinfo['ID']
except KeyError:
error('No destination release specified and unable to guess yours.')
else:
err, current_distro = subprocess.getstatusoutput('lsb_release --id --short')
if err:
error('Could not run lsb_release to retrieve distribution')
if current_distro == "Ubuntu":
opts.dest_releases = [UbuntuDistroInfo().lts()]
if current_distro == "Debian":