def update(target: str, alicemin: str, backup: bool): if target not in ['hotfix', 'feature', 'major']: click.echo("Only 'hotfix', 'feature' or 'major' supported for target") return checkBackup(backup) aliceMinVersion = Version.fromString(alicemin) if alicemin else None if aliceMinVersion and str(aliceMinVersion) == '0.0.0-0': click.echo('Invalid min alice version, aborting') return for installFile in installFiles(): doBackup(backup, installFile) data = json.loads(installFile.read_text()) version = Version.fromString(data['version']) if target == 'hotfix': version.hotfix += 1 elif target == 'feature': version.hotfix = 0 version.updateVersion += 1 elif target == 'major': version.hotfix = 0 version.updateVersion = 0 version.mainVersion += 1 data['version'] = str(version) if aliceMinVersion: data['aliceMinVersion'] = str(aliceMinVersion) installFile.write_text(json.dumps(data, indent=4, ensure_ascii=False)) click.echo(f'Rewritten "{installFile.stem}"')
def verify(self): """ Verify integrity of the license file is integral, cnippet's version, and expiration date. """ secret = '$*we#j238@#WA!%' h = hashlib.sha1() h.update(secret[10:12]) h.update(base64.b64encode(self.product)) h.update(secret[1:4]) h.update(self.version[0]) h.update(secret[6:9]) h.update(self.email) h.update(self.expiration) digest = h.hexdigest() # If the hash doesn't match, data has been corrupted. if self.key != digest: sys.exit(DiagnosticReporter.fatal(CORRUPTED_LICENSE_FILE)) # Verify product version. if int(self.version[0]) != Version().major: sys.exit( DiagnosticReporter.fatal(INCOMPATIBLE_LICENSE_PRODUCT_VERSION)) # Verify expiration. exp_date = datetime.datetime.strptime(self.expiration, '%d/%B/%Y') if datetime.datetime.today() > exp_date: sys.exit(DiagnosticReporter.fatal(LICENSE_EXPIRED))
def __init__(self, application_name, version, node_name, nonce, node_address, timestamp): v = Version(version) address = NetworkAddress.from_string(node_address) address_bytes = address.get_bytes() address_bytes_len = len(address_bytes) application_name_bytes = bytes(application_name, "utf-8") application_name_bytes_len = len(application_name_bytes) node_name_bytes = bytes(node_name, "utf-8") node_name_bytes_len = len(node_name_bytes) handshake_struct = struct.Struct( self.handshake_struct_template.format( application_name_length=application_name_bytes_len, node_name_length=node_name_bytes_len, address_length=address_bytes_len)) handshake = handshake_struct.pack( application_name_bytes_len, *application_name_bytes, v.major, v.minor, v.patch, node_name_bytes_len, *node_name_bytes, nonce, address_bytes_len, *address_bytes, timestamp) super().__init__(handshake)
def main(argv): # Calls Version class version = Version("http://..." + argv + "/", "amazon", {}, "repo").get_version() # Prints the retrieved information to be used when making repo print(argv) print(version)
def __init__(self): """Initializes the service.""" super().__init__("1234", "MyService", Version("1.2.3"), "Default Service", True, ServiceKind.TRANSFORMATION_SERVICE) Registry.services['1234'] = self Registry.receivers['1234_Rec13'] = self.receiveRec13 Registry.asyncTransformers['1234_Rec12'] = self.transformRec12Rec12 Registry.syncTransformers['1234_Rec13'] = self.transformRec13Rec13 Registry.asyncTransformers['1234_S'] = self.transformStringString
def version(): # Declare global variables locally global corretto_version global new_version global url_beginning # URL of corretto update downloads url = "https://docs.aws.amazon.com/corretto/latest/corretto-" + str(corretto_version) + "-ug/downloads-list.html" # Calls version class new_version = Version(url, url_beginning, {"https": "https://..."}, "corretto").get_version()
def execute(self, *args, **kwargs): masterTbl = MasterTbl() version = Version() epoch = time.time() masterTbl['testreportLoc'] = 'testreports' masterTbl['testReportDir'] = os.path.join(masterTbl['projectDir'], masterTbl['testreportLoc']) masterTbl['testRptExt'] = '.rtm' masterTbl['descriptExt'] = '.desc' masterTbl['ThemisVersion'] = 'Themis ' + version.tag() masterTbl['currentEpoch'] = epoch masterTbl['origEpoch'] = masterTbl['currentEpoch'] masterTbl['target'] = os.environ.get("TARG_SUMMARY") or "" masterTbl['errors'] = 0 masterTbl['diffCount'] = 0 masterTbl['failCount'] = 0 masterTbl['resultMaxLen'] = 12 masterTbl['minNP'] = 0 masterTbl['maxNP'] = sys.maxsize #------------------------------------------------------------ # Add projectDir to PYTHONPATH for user functions sys.path.append(masterTbl['projectDir']) unameT = get_platform() currentUUID = full_date_string(epoch) + "-" + unameT['os_mach'] for k in unameT: masterTbl[k] = unameT[k] masterTbl['hostname'] = unameT['machine'] #------------------------------------------------------------ # Setup gauntlet masterTbl['gauntlet'] = Gauntlet(GauntletData()) # masterTbl['gauntlet'] = None --> for later masterTbl['candidateTstT'] = {} masterTbl['tstT'] = {} masterTbl['rptT'] = {}
def test(): test_cases = [ (Version(version_strings[0]), Version(version_strings[1])) for version_strings in greater + greater_edge + equal + equal_edge + lesser_edge + lesser ] # build pairs of Version objects from tuples in the concatenation of test_data arrays test_oracles = (1, ) * (len(greater) + len(greater_edge)) + (0, ) * ( len(equal) + len(equal_edge)) + (-1, ) * ( len(lesser_edge) + len(lesser)) # commas necessary test_results = {"pass": 0, "fail": 0} for i, test_case in enumerate(test_cases): oracle = test_oracles[i] print( "\nTest case {}:\nComparing version string '{}' with version string '{}'" .format(i + 1, *test_case), end=' ' ) # spread the two Version objects in the test_case tuple into the positional parameters of format as their str representation try: version_compare_validator(test_case, oracle) print("passed", end=' ') test_results["pass"] += 1 except AssertionError: print("failed", end=' ') test_results["fail"] += 1 print("(expected {}).".format({ "1": "> 1", "0": "0", "-1": "< 1" }[str(oracle)])) assert test_results["pass"] + test_results["fail"] == len( test_cases) # ensure all tests have been completed print("\nTest results:\n{} completed, {} failed".format( len(test_cases), test_results["fail"])) # display results
def __init__(self, file): """Creates an instance by reading relevant information from file. Parameters: - file -- the file to read from """ f = open(file) dict = yaml.load(f, Loader=yaml.FullLoader) self.id = dict.get("id") self.name = dict.get("name") self.version = Version(dict.get("version")) services = dict.get("services") self.services = [] for s in services: id = s.get("id") name = s.get("name") version = Version(s.get("version")) description = s.get("description") kind = ServiceKind[s.get("kind")] deployable = s.get("deployable") self.services.append( YamlService(id, name, version, description, kind, deployable)) f.close()
def __init__(self): """Initializes the service.""" super().__init__("1234", "MyService", Version("1.2.3"), "Default Service", True, ServiceKind.TRANSFORMATION_SERVICE)
def version_action(): """ Show version action """ sys.exit(Version().get_full_version())
def update_action(): """ Update action """ Version.update() exit()
def load_data(self): versions = Versions(self.versions_path) versions.load_data() if 'data_date' in versions.data: versions.data = versions.data.sort_values('data_date', ascending=False) versions.is_changed = False versions.data_updated = [] table_info = Table_info(self.table_info_path, self.path_name) table_info.load_data() if not table_info.is_loaded(): table_info.create(versions) if(table_info.db_or_table_name_changed()): table_info.update_table_and_db_name(self.all_current_variables_path) table_info.create(versions) database_info = Database_info(self.database_info_path, self.path_name) database_info.load_data() if not database_info.is_loaded(): database_info.create() database_info.save_to_all_databases(self.all_databases_path) nb_iter = -1 for i, version_data in versions.data.iterrows(): nb_iter += 1 versions.data_updated.append(version_data) version = Version(version_data) version.load_data() version.is_current = nb_iter == 0 if not version.is_loaded(): log('error: cannot load version ' + version.path) continue version.filter_unnamed_cols() version.set_last_modif_datetime(self.var_info_path) if not version.is_update_to_do() \ and not io_file.is_missing_files(self.files) \ and not version.is_vars_info_changed(self.var_info_path): continue log('updating_table', version.name) versions.is_changed = True versions.data_updated[nb_iter]['name'] = version.name versions.data_updated[nb_iter]['data_date'] = version.data_date versions.data_updated[nb_iter]['data_last_modif'] = version.data_last_modif versions.data_updated[nb_iter]['meta_last_modif'] = version.meta_last_modif versions.data_updated[nb_iter]['nb_row'] = len(version.data.index) vars_info = Vars_info(self.var_info_path) vars_info.update_data(version.data) vars_info.load_data() versions.data_updated[nb_iter]['info_last_modif'] = io_file.get_last_modif_datetime(self.var_info_path) vars_meta = Vars_meta(version) vars_meta.get_vars_data(vars_info.data, version.data) modalities_meta = Modalities_meta() correlation_info = Correlation_info(self.correlation_info_path, self.path_name) correlation_info.load_data() correlation_info.correlation_num_num(version.data) if version.is_current: vars_meta.save_current_variables(self.current_variables_path) modalities_meta.save_current(self.current_modalities_path, version.data) table_info.add_nb_row(len(version.data.index)) vars_meta.save_historic_variables(self.historic_variables_path) modalities_meta.save_historic(self.historic_modalities_path) if versions.is_changed: versions.update() table_info.save_to_all_tables(self.all_tables_path) self.is_changed = versions.is_changed
def version_compare(version_string1: str, version_string2: str): """Public library function to return if a version string greater than, equal, or less than the other. Accepts 2 version strings as input arguments. Returns an integer > 0 if the first version string was greater than the other, an integer < 0 if the first version string was lesser than the other, and 0 if the version string parameters were equal.""" return Version(version_string1).compare_with( Version(version_string2)) # create anonymous objects
def _parse_input(): """ Parse input, identify options, the host compiler and command. """ parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.RawDescriptionHelpFormatter, description='\tcnippet - the compiler for C snippets\n', epilog='examples:\n' ' $cnip gcc file.c\n' ' $cnip -f gcc file.c -o exe\n' ' $cnip -f --no-stdlib gcc -c file.c\n') version_str = '%s' % Version() copyright_str = 'Copyright 2017 Leandro T. C. Melo' parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + version_str + '\n' + copyright_str, help="Show program's version number and exit.") parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS, help='Show this help message and exit.') parser.add_argument( '--no-heuristic', action='store_true', help='Disable heuristics upon unresolved ambiguous syntax.') parser.add_argument( '--no-typedef', action='store_true', help="Forbid 'typedef','struct', and 'union' declarations.") parser.add_argument('--no-stdlib', action='store_true', help="Don't attempt to match stdlib names.") parser.add_argument('-f', '--non-commercial', action='store_true', help="Specify non-commercial use of cnippet.") parser.add_argument( '-t', '--trace', action='append', help="The componet to be traced -- 'all' for every one.") parser.add_argument('--trace-level', choices=['info', 'detail'], default='info', help='Enable tracing.') parser.add_argument('CC', help="The host C compiler (e.g., 'gcc' or 'clang').") parser.add_argument('command', metavar='...', nargs=argparse.REMAINDER, help='The command to be forwarded to the C compiler.') # Hidden arguments. parser.add_argument('-d', '--dev', action='store_true', help=argparse.SUPPRESS) return parser.parse_args()
def version(self): return Version.get(self.instructions['cloud_input_path'])
def _parse_input(): """ Parse input, identify options, the host compiler and command. """ parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.RawDescriptionHelpFormatter, description='\tcnippet - the compiler for C snippets\n', epilog='examples:\n' ' $cnip gcc file.c\n' ' $cnip -f gcc file.c -o exe\n' ' $cnip -f --no-stdlib gcc -c file.c\n') version_str = '%s' % Version() copyright_str = 'Copyright 2017 Leandro T. C. Melo' parser.add_argument('-v', '--version', action='version', version='%(prog)s ' + version_str + '\n' + copyright_str, help="Show program's version number and exit.") parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS, help='Show this help message and exit.') parser.add_argument( '--no-heuristic', action='store_true', help='Disable heuristics upon unresolved ambiguous syntax.') parser.add_argument( '--no-typedef', action='store_true', help="Forbid 'typedef','struct', and 'union' declarations.") parser.add_argument('--no-stdlib', action='store_true', help="Don't attempt to match stdlib names.") parser.add_argument( '-s', '--only-omissive', action='store_true', help='Only consider "omissive" functions for inference.') parser.add_argument('-p', '--generics', action='store_true', help='Enable parmetric polimorphism.') parser.add_argument('-f', '--non-commercial', action='store_true', help="Specify non-commercial use.") parser.add_argument('-g', '--debug', action='append', choices=['all'], help='Debug specified component(s).') parser.add_argument('-x', '--trace-external', action='store_true', help='Trace invocation of external processes.') parser.add_argument('CC', help="The host C compiler (e.g., 'gcc' or 'clang').") parser.add_argument('cc_cmd_line', metavar='...', nargs=argparse.REMAINDER, help='The command to be forwarded to the C compiler.') # Hidden arguments. parser.add_argument('-d', '--dev', action='store_true', help=argparse.SUPPRESS) return parser.parse_args()
def fromString(cls, versionString: str) -> Version: skillVersion, aliceMinVersion = str(versionString).split('_') return cls(Version.fromString(skillVersion), Version.fromString(aliceMinVersion))
from Version import Version from pathlib import Path import subprocess from datetime import datetime import os import json import requests subprocess.run( ['git', 'fetch', '--depth=1', 'origin', '+refs/tags/*:refs/tags/*']) results = subprocess.run(['git', 'tag'], capture_output=True).stdout.decode().split() version = max(Version.fromString(tag) for tag in results) if results else Version.fromString('') # get current commit hash for tag commit = subprocess.run(['git', 'rev-parse', 'HEAD'], capture_output=True).stdout.decode().strip() with open('VERSION') as f: new_version_string = f.readline() new_version = Version.fromString(new_version_string) print(f'current version: {version}') print(f'commit version: {new_version}') if new_version > version: print(f'::set-output name=new_tag::v{new_version}') print(f'::set-output name=current_version::{new_version}')