def password(self): if version.StrictVersion(self.release_version)\ < version.StrictVersion('7.0'): self._password = self.get_conf_values().strip() return self._password if self._password is None: self._password = self.get_hiera_values(hiera_hash='rabbit', hash_key='password') # FIXME(mattmymo): Remove this after merging # https://review.openstack.org/#/c/276797/ if not self._password: self._password = self.get_hiera_values(hiera_hash='rabbit_hash', hash_key='password') return self._password
def _init_version(self): '''Initializes functions for serie builders that are specific to different versions of InfluxDB. In InfluxDB v0.11.0 the SHOW SERIES output changed. See, https://github.com/influxdata/influxdb/blob/master/CHANGELOG.md#v0110-2016-03-22 ''' try: influxdb_version = self._get_influxdb_version() if influxdb_version < version.StrictVersion('0.11.0'): self._version = 'to_0.11.0' LOG.info('Initialize InfluxDB serie builders < v0.11.0') else: self._version = 'from_0.11.0' LOG.info('Initialize InfluxDB serie builders >= v0.11.0') except (requests.exceptions.ConnectionError, requests.exceptions.ConnectTimeout): # these errors mean that the backend is not ready yet, we shall try # to build series on each request LOG.warning('influxdb is not ready yet') except Exception as ex: LOG.exception(ex) # Initialize the serie builders to v0_11_0. Not sure when SHOW DIAGNOSTICS added # support for a version string so to address backward compatibility initialize # InfluxDB serie builders < v0.11.0 self._version = 'to_0.11.0' LOG.info('Initialize InfluxDB serie builders < v0.11.0')
def version_key(string): """Returns a version representation useful for version comparison""" # remove the trailing '-<release>' number if any string = string.split('-', 1)[0] return version.StrictVersion(string)
def validate_provision(cls, cluster, attrs): # NOTE(agordeev): disable classic provisioning for 7.0 or higher if version.StrictVersion(cluster.release.environment_version) >= \ version.StrictVersion(consts.FUEL_IMAGE_BASED_ONLY): provision_data = attrs['editable'].get('provision') if provision_data: if provision_data['method']['value'] != \ consts.PROVISION_METHODS.image: raise errors.InvalidData( u"Cannot use classic provisioning for adding " u"nodes to environment", log_message=True) else: raise errors.InvalidData( u"Provisioning method is not set. Unable to continue", log_message=True)
def parse_sdk_name(name, current_version): """Returns a filename or URL for the SDK name. The name can be a version string, a remote URL or a local path. """ # Version like x.y.z, return as-is. try: version = dist_version.StrictVersion(name) if version == current_version: # get from current. url = CURRENT_VERSION_URL elif version > LAST_OLD_VERSION: # newer SDK, not on code.google.com url = NEW_DEPRECATED_URL % ''.join(name.split('.')) else: # old SDK in code.google.com url = OLD_VERSION_URL return url % name except ValueError: # this means we couldn't parse as x.y.z pass # A network location. url = urlparse.urlparse(name) if url.scheme: return name # Else must be a filename. return os.path.abspath(name)
def _validate_min_version(min_version): """Validates the extension version matches the requested version. Args: min_version: Minimum version passed as a query param when establishing the connection. Returns: An ExtensionVersionResult indicating validation status. If there is a problem, the error_reason field will be non-empty. """ if min_version is not None: try: parsed_min_version = version.StrictVersion(min_version) except ValueError: return ExtensionVersionResult( error_reason=ExtensionValidationError. UNPARSEABLE_REQUESTED_VERSION, requested_extension_version=min_version) if parsed_min_version > HANDLER_VERSION: return ExtensionVersionResult( error_reason=ExtensionValidationError.OUTDATED_VERSION, requested_extension_version=str(parsed_min_version)) return ExtensionVersionResult(error_reason=None, requested_extension_version=min_version)
def sniff_compiler_version(cc): try: ver = subprocess.check_output([cc, "--version"]).decode("utf-8") except (subprocess.CalledProcessError, UnicodeDecodeError): return CompilerInfo("unknown", version.LooseVersion("unknown")) if ver.startswith("gcc"): compiler = "gcc" elif ver.startswith("clang"): compiler = "clang" elif ver.startswith("Apple LLVM"): compiler = "clang" elif ver.startswith("icc"): compiler = "intel" else: compiler = "unknown" ver = version.LooseVersion("unknown") if compiler in ["gcc", "icc"]: try: ver = subprocess.check_output([cc, "-dumpversion"]).decode("utf-8") ver = version.StrictVersion(ver.strip()) except (subprocess.CalledProcessError, UnicodeDecodeError): pass return CompilerInfo(compiler, ver)
def main(args: argparse.Namespace) -> None: check_path() rel = version.LooseVersion(args.release) print("Release:", rel) if len(rel.version) == 3: # Major release major, minor, patch = version.StrictVersion(args.release).version rc = None rc_ver = None else: # RC release major, minor, patch, rc, rc_ver = cast(Tuple[int, int, int, str, int], rel.version) assert rc == "rc" release = str(major) + "." + str(minor) + "." + str(patch) branch = "release_" + release git.clean("-xdf") git.checkout(branch) git.pull("origin", branch) git.submodule("update") commit_hash = latest_hash() download_r_packages(release, "" if rc is None else rc + str(rc_ver), commit_hash) download_py_packages(major, minor, commit_hash)
def __init__(self, **kwargs): super(Compiler, self).__init__(**kwargs) self.suffix = kwargs.get('suffix') self.cc = self.CC if kwargs.get('cpp', False) is False else self.CPP self.cc = self.cc if self.suffix is None else ('%s-%s' % (self.cc, self.suffix)) self.ld = self.cc # Wanted by the superclass self.cflags = ['-O3', '-g', '-fPIC', '-Wall', '-std=c99'] self.ldflags = ['-shared'] self.include_dirs = [] self.libraries = [] self.library_dirs = [] self.defines = [] self.undefines = [] self.src_ext = 'c' if kwargs.get('cpp', False) is False else 'cpp' self.lib_ext = 'so' if self.suffix is not None: try: self.version = version.StrictVersion(str(float(self.suffix))) except (TypeError, ValueError): self.version = version.LooseVersion(self.suffix) else: # Knowing the version may still be useful to pick supported flags self.version = sniff_compiler_version(self.CC)
def _get_names(csi_version, plugin_name): # In spec < 1.0 name must follow reverse domain name notation reverse = version.StrictVersion(csi_version) < '1.0' if reverse: data = [defaults.REVERSE_NAME, plugin_name] regex = r'^[A-Za-z]{2,6}(\.[A-Za-z0-9-]{1,63})+$' # In spec 1.0 the name must be domain name notation else: data = [plugin_name, defaults.NAME] regex = r'^([A-Za-z0-9-]{1,63}\.)+?[A-Za-z]{2,6}$' # For backward compatibility, accept full name if 'ember-csi' in plugin_name: name = plugin_name else: name = '.'.join(filter(None, data)) if len(name) > 63: LOG.error('Plugin name %s too long (max %s)' % (plugin_name, 63 - len(defaults.NAME))) exit(constants.ERROR_PLUGIN_NAME) if not re.match(regex, name): LOG.error('Invalid plugin name %s' % plugin_name) exit(constants.ERROR_PLUGIN_NAME) if not plugin_name: project_name = 'default' else: project_name = name.split('.')[-1 if reverse else 0] return name, project_name
def test_get_session_endpoint_identity(self, get_session_mock): session_mock = mock.Mock() get_session_mock.return_value = session_mock self.op_cloud.get_session_endpoint('identity') # occ > 1.26.0 fixes keystoneclient construction. Unfortunately, it # breaks our mocking of what keystoneclient does here. Since we're # close to just getting rid of ksc anyway, just put in a version match occ_version = du_version.StrictVersion(occ.__version__) if occ_version > du_version.StrictVersion('1.26.0'): kwargs = dict( interface='public', region_name='RegionOne', service_name=None, service_type='identity') else: kwargs = dict(interface=ksa_plugin.AUTH_INTERFACE) session_mock.get_endpoint.assert_called_with(**kwargs)
def main(args: argparse.Namespace) -> None: check_path() rel = version.StrictVersion(args.release) platforms = [ "win_amd64", "manylinux2014_x86_64", "manylinux2014_aarch64", "macosx_10_14_x86_64.macosx_10_15_x86_64.macosx_11_0_x86_64", ] print("Release:", rel) major, minor, patch = rel.version branch = "release_" + str(major) + "." + str(minor) + ".0" git.clean("-xdf") git.checkout(branch) git.pull("origin", branch) git.submodule("update") commit_hash = lastest_hash() dir_URL = PREFIX + str(major) + "." + str(minor) + ".0" + "/" src_filename_prefix = "xgboost-" + args.release + "%2B" + commit_hash + "-py3-none-" target_filename_prefix = "xgboost-" + args.release + "-py3-none-" if not os.path.exists(DIST): os.mkdir(DIST) filenames = download_wheels(platforms, dir_URL, src_filename_prefix, target_filename_prefix) print("List of downloaded wheels:", filenames) print(""" Following steps should be done manually: - Generate source package by running `python setup.py sdist`. - Upload pypi package by `python3 -m twine upload dist/<Package Name>` for all wheels. - Check the uploaded files on `https://pypi.org/project/xgboost/<VERSION>/#files` and `pip install xgboost==<VERSION>` """)
def _support_array_reduction(cls, compiler): # Not all backend compilers support array reduction! # Here are the known unsupported ones: if isinstance(compiler, GNUCompiler) and \ compiler.version < version.StrictVersion("6.0"): return False return True
def _get_influxdb_version(self): '''If Version found in the result set, return the InfluxDB Version, otherwise raise an exception. InfluxDB has changed the format of their result set and SHOW DIAGNOSTICS was introduced at some point so earlier releases of InfluxDB might not return a Version. ''' try: result = self.influxdb_client.query('SHOW DIAGNOSTICS') except InfluxDBClientError as ex: LOG.exception(ex) raise if 'series' not in result.raw: LOG.exception('series not in result.raw') raise Exception('Series not in SHOW DIAGNOSTICS result set') for series in result.raw['series']: if 'columns' not in series: continue columns = series['columns'] if u'Version' not in series['columns']: continue if u'values' not in series: continue for value in series[u'values']: version_index = columns.index(u'Version') version_str = value[version_index] return version.StrictVersion(version_str) raise Exception('Version not found in SHOW DIAGNOSTICS result set')
def _validate_type_version(self, field, value): try: version.StrictVersion(value) except ValueError: self._error( field, '{} is not a valid python strict version.'.format(value))
def __init__(self, *args, **kwargs): super(IntelCompiler, self).__init__(*args, **kwargs) self.cflags += ["-xhost"] language = kwargs.pop('language', configuration['language']) platform = kwargs.pop('platform', configuration['platform']) if platform is SKX: # Systematically use 512-bit vectors on skylake self.cflags += ["-qopt-zmm-usage=high"] try: if self.version >= version.StrictVersion("15.0.0"): # Append the OpenMP flag regardless of configuration['language'], # since icc15 and later versions implement OpenMP 4.0, hence # they support `#pragma omp simd` self.ldflags += ['-qopenmp'] except (TypeError, ValueError): if language == 'openmp': # Note: fopenmp, not qopenmp, is what is needed by icc versions < 15.0 self.ldflags += ['-fopenmp'] # Make sure the MPI compiler uses `icc` underneath -- whatever the MPI distro is if kwargs.get('mpi'): ver = check_output([self.MPICC, "--version"]).decode("utf-8") if not ver.startswith("icc"): warning("The MPI compiler `%s` doesn't use the Intel " "C/C++ compiler underneath" % self.MPICC)
def test_sensu_go_older_than_5_21_0(self, mocker, check): client = mocker.Mock() client.version = version.StrictVersion("5.20.0") with pytest.raises(errors.SensuError): user.update_password_hash(client, '/path', 'user', 'hash', check) client.put.assert_not_called()
def sniff_compiler_version(cc): """ Try to detect the compiler version. Adapted from: :: https://github.com/OP2/PyOP2/ """ try: ver = check_output([cc, "--version"]).decode("utf-8") except (CalledProcessError, UnicodeDecodeError): return version.LooseVersion("unknown") if ver.startswith("gcc"): compiler = "gcc" elif ver.startswith("clang"): compiler = "clang" elif ver.startswith("Apple LLVM"): compiler = "clang" elif ver.startswith("icc"): compiler = "icc" else: compiler = "unknown" ver = version.LooseVersion("unknown") if compiler in ["gcc", "icc"]: try: # gcc-7 series only spits out patch level on dumpfullversion. ver = check_output([cc, "-dumpfullversion"], stderr=DEVNULL).decode("utf-8") ver = version.StrictVersion(ver.strip()) except CalledProcessError: try: ver = check_output([cc, "-dumpversion"], stderr=DEVNULL).decode("utf-8") ver = version.StrictVersion(ver.strip()) except (CalledProcessError, UnicodeDecodeError): pass except UnicodeDecodeError: pass # Pure integer versions (e.g., ggc5, rather than gcc5.0) need special handling try: ver = version.StrictVersion(float(ver)) except TypeError: pass return ver
def is_compliant_with_domogik(self, pkg_version=None): """ check if the package is compliant with the domogik installed """ dmg_version = version.StrictVersion(DMG_VERSION) if pkg_version == None: pkg_compliant_version = version.StrictVersion( self.json['identity']['domogik_min_version']) else: pkg_compliant_version = version.StrictVersion(pkg_version) if pkg_compliant_version <= dmg_version: return True else: self.log.error( "The package is not compliant with the current Domogik installation ({0}). Minimum expected version is {1}" .format(DMG_VERSION, pkg_compliant_version)) return False
def is_updatable(item): if isinstance(item, Available): return False elif item.installable is None: return False else: inst, dist = item try: v1 = version.StrictVersion(dist.version) v2 = version.StrictVersion(inst.version) except ValueError: pass else: return v1 < v2 return (version.LooseVersion(dist.version) < version.LooseVersion( inst.version))
def test_password(self, mock_getpass, mock_stdin): mock_stdin.encoding = "utf-8" # default output of empty tables differs depending between prettytable # versions if (hasattr(prettytable, '__version__') and dist_version.StrictVersion(prettytable.__version__) < dist_version.StrictVersion('0.7.2')): ex = '\n' else: ex = ( '+----+------+--------+------------+-------------+----------+\n' '| ID | Name | Status | Task State | Power State | Networks |\n' '+----+------+--------+------------+-------------+----------+\n' '+----+------+--------+------------+-------------+----------+\n' ) self.make_env(exclude='OS_PASSWORD') stdout, stderr = self.shell('list') self.assertEqual((stdout + stderr), ex)
def sniff_compiler_version(cc): try: ver = subprocess.check_output([cc, "--version"]).decode("utf-8") except (subprocess.CalledProcessError, UnicodeDecodeError): return CompilerInfo("unknown", version.LooseVersion("unknown")) if ver.startswith("gcc"): compiler = "gcc" elif ver.startswith("clang"): compiler = "clang" elif ver.startswith("Apple LLVM"): compiler = "clang" elif ver.startswith("icc"): compiler = "icc" else: compiler = "unknown" ver = version.LooseVersion("unknown") if compiler == "gcc": try: ver = subprocess.check_output( [cc, "-dumpversion"], stderr=subprocess.DEVNULL).decode("utf-8") try: ver = version.StrictVersion(ver.strip()) except ValueError: # A sole digit, e.g. 7, results in a ValueError, so # append a "do-nothing, but make it work" string. ver = version.StrictVersion(ver.strip() + ".0") if compiler == "gcc" and ver >= version.StrictVersion("7.0"): try: # gcc-7 series only spits out patch level on dumpfullversion. fullver = subprocess.check_output( [cc, "-dumpfullversion"], stderr=subprocess.DEVNULL).decode("utf-8") fullver = version.StrictVersion(fullver.strip()) ver = fullver except (subprocess.CalledProcessError, UnicodeDecodeError): pass except (subprocess.CalledProcessError, UnicodeDecodeError): pass return CompilerInfo(compiler, ver)
def test_filelock(self): """ Check that file lock doesn't get lost after an MDS restart """ a_version_str = get_package_version(self.mount_a.client_remote, "fuse") b_version_str = get_package_version(self.mount_b.client_remote, "fuse") flock_version_str = "2.9" version_regex = re.compile(r"[0-9\.]+") a_result = version_regex.match(a_version_str) self.assertTrue(a_result) b_result = version_regex.match(b_version_str) self.assertTrue(b_result) a_version = version.StrictVersion(a_result.group()) b_version = version.StrictVersion(b_result.group()) flock_version = version.StrictVersion(flock_version_str) flockable = False if (a_version >= flock_version and b_version >= flock_version): log.info("testing flock locks") flockable = True else: log.info( "not testing flock locks, machines have versions {av} and {bv}" .format(av=a_version_str, bv=b_version_str)) lock_holder = self.mount_a.lock_background(do_flock=flockable) self.mount_b.wait_for_visible("background_file-2") self.mount_b.check_filelock(do_flock=flockable) self.fs.mds_fail_restart() self.fs.wait_for_state('up:active', timeout=MDS_RESTART_GRACE) self.mount_b.check_filelock(do_flock=flockable) # Tear down the background process lock_holder.stdin.close() try: lock_holder.wait() except (CommandFailedError, ConnectionLostError): # We killed it, so it raises an error pass
def _configure_network_feature_enabled( self, section_name="network-feature-enabled"): if "neutron" in self.available_services: neutronclient = self.clients.neutron() # NOTE(ylobankov): We need the if/else block here because # the list_ext method has different number of arguments in # different Neutron client versions. cl_ver = nc_version.__version__ if version.StrictVersion(cl_ver) >= version.StrictVersion("4.1.0"): # Neutron client version >= 4.1.0 extensions = neutronclient.list_ext("extensions", "/extensions", retrieve_all=True) else: # Neutron client version < 4.1.0 extensions = neutronclient.list_ext("/extensions") aliases = [ext["alias"] for ext in extensions["extensions"]] aliases_str = ",".join(aliases) self.conf.set(section_name, "api_extensions", aliases_str)
def test_sensu_go_newer_than_5_21_0_check_mode(self, mocker): client = mocker.Mock() client.version = version.StrictVersion("5.21.0") changed = user.update_password_hash( client, '/path', 'user', 'pass', True, ) assert changed is True client.put.assert_not_called()
def _get_influxdb_version(self): '''New versions of InfluxDB implements the method ping() which returns the version. In case that the method isn't present, the query SHOW DIAGNOSTICS will be used. If Version found in the result set, return the InfluxDB Version, otherwise raise an exception. InfluxDB has changed the format of their result set and SHOW DIAGNOSTICS was introduced at some point so earlier releases of InfluxDB might not return a Version. ''' try: result = self.influxdb_client.ping() LOG.info("Found Influxdb version {0}".format(result)) return version.StrictVersion(result) except Exception as ex: LOG.warn(ex) LOG.warn("Getting version from method ping failed," " now trying with SHOW DIAGNOSTICS") try: result = self.influxdb_client.query('SHOW DIAGNOSTICS') except InfluxDBClientError as ex: LOG.exception(ex) raise if 'series' not in result.raw: LOG.exception('series not in result.raw') raise Exception('Series not in SHOW DIAGNOSTICS result set') for series in result.raw['series']: if 'columns' not in series: continue columns = series['columns'] if u'Version' not in series['columns']: continue if u'values' not in series: continue for value in series[u'values']: version_index = columns.index(u'Version') version_str = value[version_index] return version.StrictVersion(version_str) raise Exception('Version not found in SHOW DIAGNOSTICS result set')
def test_password(self, mock_getpass, mock_stdin, m_requests): mock_stdin.encoding = "utf-8" # default output of empty tables differs depending between prettytable # versions if (hasattr(prettytable, '__version__') and dist_version.StrictVersion(prettytable.__version__) < dist_version.StrictVersion('0.7.2')): ex = '\n' else: ex = '\n'.join([ '+----+------+--------+------------+-------------+----------+', '| ID | Name | Status | Task State | Power State | Networks |', '+----+------+--------+------------+-------------+----------+', '+----+------+--------+------------+-------------+----------+', '' ]) self.make_env(exclude='OS_PASSWORD') self.register_keystone_discovery_fixture(m_requests) stdout, stderr = self.shell('list') self.assertEqual((stdout + stderr), ex)
def check_if_outdated(current_version=None, remote_version=None, source_url="https://nf-co.re/tools_version"): """ Check if the current version of nf-core is outdated """ # Exit immediately if disabled via ENV var if os.environ.get("NFCORE_NO_VERSION_CHECK", False): return True # Set and clean up the current version string if current_version == None: current_version = nf_core.__version__ current_version = re.sub("[^0-9\.]", "", current_version) # Build the URL to check against source_url = os.environ.get("NFCORE_VERSION_URL", source_url) source_url = "{}?v={}".format(source_url, current_version) # Fetch and clean up the remote version if remote_version == None: response = requests.get(source_url, timeout=3) remote_version = re.sub("[^0-9\.]", "", response.text) # Check if we have an available update is_outdated = version.StrictVersion(remote_version) > version.StrictVersion(current_version) return (is_outdated, current_version, remote_version)
def _is_flockable(self): a_version_str = get_package_version(self.mount_a.client_remote, "fuse") b_version_str = get_package_version(self.mount_b.client_remote, "fuse") flock_version_str = "2.9" version_regex = re.compile(r"[0-9\.]+") a_result = version_regex.match(a_version_str) self.assertTrue(a_result) b_result = version_regex.match(b_version_str) self.assertTrue(b_result) a_version = version.StrictVersion(a_result.group()) b_version = version.StrictVersion(b_result.group()) flock_version=version.StrictVersion(flock_version_str) if (a_version >= flock_version and b_version >= flock_version): log.info("flock locks are available") return True else: log.info("not testing flock locks, machines have versions {av} and {bv}".format( av=a_version_str,bv=b_version_str)) return False
def factory(self): """Return different resource module according to RSD API Version :returns: a resource module """ rsd_version = version.StrictVersion(self._rsd_api_version) if rsd_version < version.StrictVersion("2.2.0"): # Use the interface of RSD API 2.1.0 to interact with RSD 2.1.0 and # all previous version. return v2_1.RSDLibV2_1(self._conn, self._root_prefix, redfish_version=self._redfish_version) elif version.StrictVersion("2.2.0") <= rsd_version \ and rsd_version < version.StrictVersion("2.3.0"): # Specific interface for RSD 2.2 version return v2_2.RSDLibV2_2(self._conn, self._root_prefix, redfish_version=self._redfish_version) elif version.StrictVersion("2.3.0") <= rsd_version \ and rsd_version < version.StrictVersion("2.4.0"): # Specific interface for RSD 2.2 version return v2_3.RSDLibV2_3(self._conn, self._root_prefix, redfish_version=self._redfish_version) else: raise NotImplementedError( "The rsd-lib library doesn't support RSD API " "version {0}.".format(self._rsd_api_version))