Support simple software output (without patch).

This commit is contained in:
Andris Raugulis 2016-09-28 16:58:58 +03:00
parent 15d24cde08
commit 1fda7b2a3e

View File

@ -517,15 +517,15 @@ class SSH(object):
return -1 return -1
elif self.version > oversion: elif self.version > oversion:
return 1 return 1
spatch = self.patch spatch = self.patch or ''
if self.product == SSH.Product.DropbearSSH: if self.product == SSH.Product.DropbearSSH:
if not re.match(r'^test\d.*$', opatch): if not re.match(r'^test\d.*$', opatch):
opatch = 'z{0}'.format(opatch) opatch = 'z{0}'.format(opatch)
if not re.match(r'^test\d.*$', self.patch): if not re.match(r'^test\d.*$', spatch):
spatch = 'z{0}'.format(self.patch) spatch = 'z{0}'.format(spatch)
elif self.product == SSH.Product.OpenSSH: elif self.product == SSH.Product.OpenSSH:
mx1 = re.match(r'^p\d(.*)', opatch) mx1 = re.match(r'^p\d(.*)', opatch)
mx2 = re.match(r'^p\d(.*)', self.patch) mx2 = re.match(r'^p\d(.*)', spatch)
if not (mx1 and mx2): if not (mx1 and mx2):
if mx1: if mx1:
opatch = mx1.group(1) opatch = mx1.group(1)
@ -544,23 +544,27 @@ class SSH(object):
return False return False
return True return True
def __str__(self): def display(self, full=True):
out = '{0} '.format(self.vendor) if self.vendor else '' out = '{0} '.format(self.vendor) if self.vendor else ''
out += self.product out += self.product
if self.version: if self.version:
out += ' {0}'.format(self.version) out += ' {0}'.format(self.version)
patch = self.patch if full:
if self.product == SSH.Product.OpenSSH: patch = self.patch or ''
mx = re.match('^(p\d)(.*)$', self.patch) if self.product == SSH.Product.OpenSSH:
if mx is not None: mx = re.match('^(p\d)(.*)$', patch)
out += mx.group(1) if mx is not None:
patch = mx.group(2).strip() out += mx.group(1)
if patch: patch = mx.group(2).strip()
out += ' ({0})'.format(self.patch) if patch:
if self.os: out += ' ({0})'.format(patch)
out += ' running on {0}'.format(self.os) if self.os:
out += ' running on {0}'.format(self.os)
return out return out
def __str__(self):
return self.display()
def __repr__(self): def __repr__(self):
out = 'vendor={0} '.format(self.vendor) if self.vendor else '' out = 'vendor={0} '.format(self.vendor) if self.vendor else ''
if self.product: if self.product: