def test_get_latest_version_timeout(self): '''Make sure everything works in error scenario. ''' self.setup(psuccess=1.) responses.add_callback(responses.GET, self.dst_url, callback=self.timeout_callback, content_type='application/json') t0 = time.time() version = get_version(self.version) t1 = time.time() self.assertLessEqual(t1 - t0, 1.10) self.assertEqual(version, self.version)
v0 = [int(n) for n in v0.split('.')][::-1] v1 = [int(n) for n in v1.split('.')][::-1] pairs = list(zip(v0, v1))[::-1] for x, y in pairs: if x < y: return -1 if x > y: return 1 return 0 # message if current version is not latest version def pretty_print_latest_version(latest_version, width=70): lines = [ 'There is a newer version of the package available.', 'For compatability reasons, please upgrade your current version.', '> pip install lightly=={}'.format(latest_version), ] print('-' * width) for line in lines: print('| ' + line + (width - len(line) - 3) * " " + "|") print('-' * width) # check for latest version from lightly.api import get_version latest_version = get_version(__version__) if latest_version is not None: if version_compare(__version__, latest_version) < 0: # local version is behind latest version # pretty_print_latest_version(latest_version) pass