Best Python code snippet using autotest_python
gitversion.py
Source:gitversion.py
...19 f.close()20 return version.strip()21 except:22 return None23def write_release_version(version):24 script_dir = path.abspath(path.join(__file__ ,"../.."))25 with open(script_dir + "/acc_provision/RELEASE-VERSION", "w") as f:26 f.write("%s\n" % version)27 f.close()28def get_git_version():29 # Read in the version that's currently in RELEASE-VERSION.30 release_version = read_release_version()31 version, version_formatted = call_git_rev_parse()32 # If that doesn't work, fall back on the value that's in33 # RELEASE-VERSION.34 if version is None:35 version = release_version36 if version is None:37 write_release_version("Release info not in the current build.")38 # If the current version is different from what's in the39 # RELEASE-VERSION file, update the file to be current.40 elif version != release_version:41 write_release_version(version)42 if version_formatted is None:43 version_formatted = "Release info not in the current build."44 ...
version.py
Source:version.py
1import configparser2import subprocess3def write_release_version(version, commit):4 with open("version.txt", "w") as f:5 f.write(f"{version}\n\n{commit}\n\n"6 "Version number and commit hash are <auto-generated> "7 "for external release. \n"8 "DO NOT CHANGE! \n")9def read_release_version():10 try:11 with open("version.txt", "r") as f:12 version = f.readlines()[0]13 return version.strip()14 except:15 return None16def get_version_from_txt():17 version = read_release_version()18 if version is None:19 raise ValueError("Cannot find the version number!")20 return version21def get_version_from_pyproject():22 config = configparser.ConfigParser()23 config.read('pyproject.toml')24 if 'tool.poetry' not in config.sections():25 raise ValueError("Invalid pyproject.toml")26 return config['tool.poetry'].get('version', '0').strip('"')27def get_commit_hash():28 res = subprocess.check_output(['git', 'rev-parse', 'HEAD'])29 return res.strip().decode()30def check_update_current_version():31 previous_version = get_version_from_txt()32 current_version = get_version_from_pyproject()33 current_commit = get_commit_hash()34 write_release_version(current_version, current_commit)35 return previous_version, current_version36if __name__ == "__main__":37 print(f"Version check: v{get_version_from_txt()} "38 f"-> v{get_version_from_pyproject()}")...
versions.py
Source:versions.py
1# -*- coding: utf-8 -*-2# Author: Douglas Creager <dcreager@dcreager.net>3# This file is placed into the public domain.4from subprocess import Popen, PIPE5def write_release_version(version):6 f = open('RELEASE-VERSION.txt', 'w')7 f.write('%s\n' % version)8 f.close()9def get_latest_tag_version():10 git = Popen(['git', 'describe', '--abbrev=0', '--tags'],11 stdout=PIPE, stderr=PIPE)12 git.stderr.close()13 lines = git.stdout.readlines()14 if len(lines) == 0:15 raise Exception('No tag found')16 line = lines[0].decode('utf-8').strip()17 write_release_version(line)18if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!