def test_should_not_allow_to_compare_version_with_int(): v1 = VersionInfo(major=3, minor=4, patch=5, prerelease="pre.2", build="build.4") with pytest.raises(TypeError): v1 > 1 with pytest.raises(TypeError): 1 > v1 with pytest.raises(TypeError): v1.compare(1)
def _parse_and_validate_pulumi_version(min_version: VersionInfo, current_version: str, opt_out: bool) -> Optional[VersionInfo]: """ Parse and return a version. An error is raised if the version is not valid. If *current_version* is not a valid version but *opt_out* is true, *None* is returned. """ try: version: Optional[VersionInfo] = VersionInfo.parse(current_version) except ValueError: version = None if opt_out: return version if version is None: raise InvalidVersionError( f"Could not parse the Pulumi CLI version. This is probably an internal error. " f"If you are sure you have the correct version, set {_SKIP_VERSION_CHECK_VAR}=true." ) if min_version.major < version.major: raise InvalidVersionError( f"Major version mismatch. You are using Pulumi CLI version {version} with " f"Automation SDK v{min_version.major}. Please update the SDK.") if min_version.compare(version) == 1: raise InvalidVersionError( f"Minimum version requirement failed. The minimum CLI version requirement is " f"{min_version}, your current CLI version is {version}. " f"Please update the Pulumi CLI.") return version
def _validate_pulumi_version(min_version: VersionInfo, current_version: VersionInfo): if min_version.major < current_version.major: raise InvalidVersionError(f"Major version mismatch. You are using Pulumi CLI version {current_version} with " f"Automation SDK v{min_version.major}. Please update the SDK.") if min_version.compare(current_version) == 1: raise InvalidVersionError(f"Minimum version requirement failed. The minimum CLI version requirement is " f"{min_version}, your current CLI version is {current_version}. " f"Please update the Pulumi CLI.")
def installBee(ver: VersionInfo = None, folder: str = None): """ this will install/update BEE, when called, the function will download the latest version based on the os is running on and unzip it """ if not beeIsPresent() or ver is not None: # the progress dialog dialog = wx.ProgressDialog(parent=wx.GetTopLevelWindows()[0], title='Installing BEE2..', message='Downloading application..', maximum=100) logger.info('downloading BEE2...') # get the zip binary data link: str = None if ver is None: link = config.dynConfig['beeUpdateUrl'] else: for tag in get(beeApiUrl.replace('/latest', '')).json(): if ver.compare(tag['tag_name']) == 0: link = tag['assets'][0]['browser_download_url'] request = get(link, stream=True) # download BEE # working variables zipdata = io.BytesIO() dialog.Show(True) dialog.Update(0) dl = 0 total_length = int(request.headers.get('content-length')) # download! for data in request.iter_content(chunk_size=1024): dl += len(data) zipdata.write(data) done = int(100 * dl / total_length) print(f'total: {total_length}, dl: {dl}, done: {done}') dialog.Update(done) logger.info('extracting...') dialog.Pulse('Extracting..') # read the data as bytes and then create the zipfile object from it ZipFile(zipdata).extractall( config.load('beePath') if folder is None else folder) # extract BEE logger.info('BEE2.4 application installed!') dialog.Close() # install default package pack dialog = wx.ProgressDialog(parent=wx.GetTopLevelWindows()[0], title='Installing BEE2..', message='Downloading default packages..', maximum=100) # get the url link = get(beePackagesApiUrl).json()['assets'][0]['browser_download_url'] # get the zip as bytes logger.info('downloading default package pack...') request = get(link, stream=True) # working variables zipdata = io.BytesIO() dialog.Update(0) dl = 0 total_length = int(request.headers.get('content-length')) # download! for data in request.iter_content(chunk_size=1024): dl += len(data) zipdata.write(data) done = int(100 * dl / total_length) print(f'total: {total_length}, dl: {dl}, done: {done}') dialog.Update(done) logger.info('extracting...') dialog.Pulse('Extracting..') # convert to a byte stream, then zipfile object and then extract ZipFile(zipdata).extractall( config.load('beePath') if folder is None else folder) dialog.Close() logger.info('finished extracting!') # check things logger.info('checking games config file..') if Path( os.getenv('APPDATA').replace('\\', '/') + '/BEEMOD2/config/games.cfg').exists(): logger.info("config file exist, checking if has P2..") if not configManager.hasGameWithID(620): logger.warning("config doesn't have P2!") logger.info('adding portal 2 to config!') configManager.addGame(path=config.portalDir()) else: logger.warning("config file doesn't exist!") configManager.createAndAddGame(path=config.portalDir()) logger.info('finished installing BEE!')