def copy_and_create_metadata(location, config_file): """ Copies config file as params.ini, creates a metadata file of current git hash. Args: location (str): location in which all files are copied / created config_file (str): config file to be copied. Return: None. """ # copy parameter file cmd = "cp {0} {1}".format(config_file, os.path.join(location, "params.ini")) lib.call(cmd, "could not copy params file.") # copy "copyall.sh" script cmd = "cp {0} {1}".format(COPYALL_SH, os.path.join(location, "copyall.sh")) lib.call(cmd, "could not copy copyall.sh") # create git hash file with open(os.path.join(location, "git_commit_hash.txt"), "w") as f: git_commit_hash = bash_imitation.git_commit_hash() f.write("commit_hash: " + git_commit_hash) submodule = "vendor" git_submodule_hash = bash_imitation.git_submodule_commit_hash( submodule) f.write("\nsubmodule_commit_hash: " + git_submodule_hash)
def driver(baseline_file, override_file, csv_dir, csv_file): """ Calls driver script.""" cmd = ("{0} --benchmark --driver_node localhost " "--ini_files {1} " "--override {2} " "--csv_path {3} " "--csv_file {4}").format(DRIVER_EXECUTABLE, baseline_file, override_file, csv_dir, csv_file) lib.call(cmd, "driver script failed")
def gnuplot(gnuplot_script, *args): """ Calls gnuplot script on input csv and dumps generated graphs in output_graph_dir. Args: gnuplot_script (str): abs path of gnuplot script args (str): args of the script Returns: None. """ cmd = "gnuplot -c {0}".format(gnuplot_script) for arg in args: cmd += " " + str(arg) lib.call(cmd, "gnuplot script failed bash_imitation")
def describe(self): path = self.path() os.chdir(path) tag_query = lib.call('git describe --abbrev=0 --match release/*') last_tag = "0.0.0" if tag_query.returncode == 0: last_tag = tag_query.stdout.read().strip() last_version_number = last_tag.split('/')[-1] return last_version_number
def describe(self, ref=''): path = self.path() os.chdir(path) tag_query = lib.call('git describe --abbrev=0 --match release/* %s' % ref) last_tag = "0.0.0" if tag_query.returncode == 0: last_tag = tag_query.stdout.read().strip() last_version_number = last_tag.split('/')[-1] return last_version_number
def call_latency_throughput(baseline_file, lt_file, params_file, csv_file, skew, use_manual_sampling): """ Calls the latency throughput script. Args: baseline_file (str): original params config file, abs path lt_file (str): latency throughput params config, abs path params_file (str): abs path of param output file csv_file (str): abs path of csv file skew (double) Returns: None. """ # call lt script cmd = "{0} {1} {2} {3} {4} {5}".format(LT_EXECUTABLE, baseline_file, lt_file, params_file, csv_file, skew) if use_manual_sampling: cmd += " --use_manual_sampling" lib.call(cmd, "lt_driver script failed")
parser.add_argument("--verbose", action="store_true", help="Should tests be run in verbose mode?") args = parser.parse_args() print("\nRunning integration test(s) '" + args.test + "'...\n") client_logs = os.path.join(env.client_binary_path, "Logs") lib.rm(os.path.join(client_logs, "client_logs.txt")) lib.mkdirs(client_logs) driver_logs = os.path.join(env.driver_jar_path, "logs") lib.rm(os.path.join(driver_logs, "driver_logs.txt")) lib.mkdirs(driver_logs) lib.call([env.script("build_unity_client.py")]) lib.call([env.script("build_driver_jar.py")]) client = subprocess.Popen([ os.path.join(env.client_binary_path, "Contents", "MacOS", "dungeonstrike"), "-batchmode", "--port", "59009", ]) print("Started client with pid " + str(client.pid) + "\n") verbose = ["--verbose"] if args.verbose else [] lib.call([ "java", "-jar", os.path.join(env.driver_jar_path, "driver.jar"), "--crash-on-exceptions",
#!/usr/bin/env python2.7 import sys import re import lib env = lib.init() env.check_assets_version() branch = lib.output(["git", "branch"]).rstrip() all_args = sys.argv[1:] if branch != "* master": print("Not on master, aborting.") lib.call(["git", "commit", "-a", "--amend"] + all_args) exit() lib.call([env.script("presubmit.py")]) time = lib.output(["date", "+%Y-%m-%d %H:%M"]) key = lib.output(["md5", "-q", "-s", time]).rstrip() previous_message = lib.output(["git", "log", "-1", "--pretty=%B"]).rstrip() without_key = re.sub(r"KEY:.*", "", previous_message).rstrip() print("Creating commit...") lib.call( ["git", "commit"] + all_args + ["-a", "--amend", "-m", without_key, "-m", "KEY: " + key] )
#!/usr/bin/env python2.7 import lib import os env = lib.init() print("\nRunning driver tests...\n") env.lein(["test"]) print("\nRunning effects tests...\n") cwd = os.getcwd() os.chdir(env.effects_root) lib.call(["lein", "test"], failure_message = "Effects tests failed!") os.chdir(cwd)
def fn(): lib.call([env.script(name)] + args) time_duration(fn)
def play(self,commands): (options,args) = self.parser.parse_args(commands) if options.settings_path is not None: self.conf.load(options.settings_path) (ffmpeg_path,player_path,ffmpeg_loglevel) = self.conf.validate(options.ffmpeg_path,options.player_path,options.ffmpeg_loglevel) if options.override_settings: if not self.conf.updated(ffmpeg_path,player_path,ffmpeg_loglevel): logger.warn(u"No updated setting.") else: self.conf.dump(options.settings_path,ffmpeg_path,player_path,ffmpeg_loglevel) a_length = len(args) if a_length == 0: logger.error(self.parser.get_usage()) return url = args[0] if not options.by_src: stream = self.get_stream(url) if stream is None: logger.error("{0} is an invalid URL.".format(url)) return title = stream.title if title is None: logger.warn(u"No title.") else: logger.info(u'Title:{0}'.format(title)) if stream.parent is None: logger.error(u"No parent manifest.") return if not stream.has_srcs(): logger.error("No source for {0}.".format(stream.parent)) return logger.info(u"Enable qualities:{0}".format(",".join(stream.get_qualities()))) if a_length >= 2: quality = args[1] src = stream.get_src(quality) if src is None: logger.error(u"{0} is an invalid quality.".format(quality)) return elif stream.allow_no_quality: src = stream.parent else: return format = stream.FORMAT ext = stream.EXT else: title = None src = url format = base.Stream.FORMAT ext = base.Stream.EXT logger.info(u"Source:{0}".format(src)) if options.print_only: return if options.direct: if HLSConfig.is_invalid(player_path): logger.error(u"No player path.") return lib.call([player_path,src]) else: if HLSConfig.is_invalid(ffmpeg_path): logger.error(u"No ffmpeg path.") return if HLSConfig.is_invalid(ffmpeg_loglevel): ffmpeg_loglevel = "fatal" if options.output is None: if HLSConfig.is_invalid(player_path): logger.error(u"No player path.") return cmd = self.get_cmd(src,"pipe:1",ffmpeg_loglevel,ffmpeg_path,format) lib.pipe(cmd,[player_path,"-"]) else: output = options.output (root,ext) = os.path.splitext(output) if len(ext) == 0: output = output + ext cmd = self.get_cmd(src,output,ffmpeg_loglevel,ffmpeg_path,format) lib.call(cmd) return
def test_call(self): result = call("echo Expected") self.assertEqual(result.returncode, 0) self.assertEqual(result.stdout.read().strip(), "Expected") self.assertNotEqual(call("Thisisnotabashscript").returncode, 0)
def fn(): lib.call([os.path.join(env.staging_path, "scripts", name)] + args) time_duration(fn)
#!/usr/bin/env python2.7 import os import shutil import lib env = lib.init() print("Updating checksums...") lib.call(["find", ".", "-name", ".DS_Store", "-delete"]) third_party = os.path.join(env.client_root, 'Assets/ThirdParty') for directory in os.listdir(third_party): path = os.path.join(third_party, directory) if not os.path.isdir(path): continue if directory == "Plugins": continue print path lib.call(["cfv", "-C", "-rr", "-p", path]) sfv = os.path.join(path, directory + ".sfv") newPath = os.path.join(env.checksums_root, directory + ".svf") os.rename(sfv, newPath) lib.call(["perl", "-p", "-i", "-e", "s/Generated.*//g", newPath]) print("\nChecksums updated. Updating asset_version.md5...") metasum = lib.output([env.script("metasum.py")]).rstrip() version_path = os.path.join(env.client_root, "assets_version.md5") with open(version_path, "w") as assets_version: assets_version.write(metasum) print("asset_version.md5 updated")
#!/usr/bin/env python2.7 import os import lib env = lib.init() print("\nCopying all project files to staging directory...\n") lib.call([ "rsync", "--archive", "--delete", "--quiet", env.project_root + os.sep, # Need trailing / to make rsync not create a subdir env.staging_path ])
#!/usr/bin/env python2.7 import os import shutil import lib env = lib.init() print("Extracing third party archive...") with open(os.path.join(env.client_root, "assets_version.md5")) as version: hash = version.read().rstrip() third_party = os.path.join(env.client_root, "Assets", "ThirdParty") if os.path.exists(third_party): shutil.rmtree(third_party) lib.mkdirs(third_party) lib.call([ "7z", "x", os.path.join(env.third_party_path, hash + ".zip"), "-o" + os.path.join(env.client_root, 'Assets') ])
def test_tag(self): git = Git(root_dir_local, test_repo_dir) git.clone() git.tag(git.latest_commit_id(), "release/1.2.3") tag_query = lib.call("git describe --abbrev=0 --match release/*") self.assertEqual(tag_query.stdout.read().strip(), "release/1.2.3")
#!/usr/bin/env python import os import lib env = lib.init() print("\nValidating checksums...\n") third_party = os.path.join(env.client_root, 'Assets/ThirdParty') for directory in os.listdir(third_party): path = os.path.join(third_party, directory) if not os.path.isdir(path): continue if directory == "Plugins": continue checksum_file = os.path.join(env.checksums_root, directory + ".svf") lib.call(["cfv", "-rr", "-VV", "-p", path, '-f', checksum_file]) print(directory + " OK") print("ALL OK")
#!/usr/bin/env python2.7 import sys import lib env = lib.init() env.check_assets_version() branch = lib.output(["git", "branch"]).rstrip() all_args = sys.argv[1:] if branch != "* master": print("Not on master, aborting.") lib.call(["git", "commit"] + all_args) exit() lib.call([env.script("presubmit.py")]) time = lib.output(["date", "+%Y-%m-%d %H:%M"]) key = lib.output(["md5", "-q", "-s", time]) print("Creating commit...") lib.call(["git", "commit"] + all_args + ["-m", "KEY: " + key])
def test_tag(self): git = Git(root_dir_local, test_repo_dir) git.clone() git.tag(git.latest_commit_id(), "release/1.2.3") tag_query = lib.call('git describe --abbrev=0 --match release/*') self.assertEqual(tag_query.stdout.read().strip(), "release/1.2.3")