def VM_SSH(name): """open a shell to a virtual machine Open an SSH session to a running virtual machine. """ vm = VM.find(name) if not vm.running(): raise fail("VM is not running: {}", vm.name) vm.forward(22) host = "linux-vm" if vm.system == 'windows': host = "windows-vm" with env(debug=True): exe("ssh -F %s %s" % (CTL_DIR + "/ssh_config", host))
def CLIENT(engine, name=None): """start a native database client Run `cogs client <engine> [<name>]` to start a native database client on a regression database. If the database name is not specified, the client is started with administrative rights against the default database. To get a list of supported engines and databases, run: `cogs help createdb` """ command = make_client(engine, name) with env(debug=True): exe(command)
def unpack_iso(self, iso_path, target_path): # Unpack an ISO image. assert os.path.isfile(iso_path) if not os.path.exists(target_path): mktree(target_path) debug("unpacking: {} => {}", iso_path, target_path) listing = pipe("isoinfo -i %s -R -f" % iso_path) for entry in listing.splitlines(): filename = target_path + entry dirname = os.path.dirname(filename) if not os.path.exists(dirname): mktree(dirname) with env(debug=False): content = pipe("isoinfo -i %s -R -x '%s'" % (iso_path, entry)) if not content: continue #debug("extracting: {} => {}", entry, filename) stream = open(filename, 'w') stream.write(content) stream.close()
def pyflakes(command): # Run `pyflakes <command>`. with env(debug=True): sh(env.pyflakes_path + " " + command)
def coverage_py(command, environ=None): # Run `coverage <command>`. path = env.coverage_path with env(debug=True): sh(path + " " + command, environ=environ)
def exe_htsql_ctl(command, environ=None): # Execute `htsql-ctl <command>`. with env(debug=True): exe(env.ctl_path + " " + command, environ=environ)
def exe_regress(command): # Run `pbbt test/regress.yaml <command>`. variables = make_variables() with env(debug=True): exe(env.pbbt_path + " test/regress.yaml -E test/regress.py " + variables + command)
def LINT(): """detect errors in the source code with PyFlakes""" with env(debug=True): exe("pyflakes src/cogs")
def htsql_ctl(command, environ=None): # Run `htsql-ctl <command>`. with env(debug=True): sh(env.ctl_path + " " + command)
def PURGE_TEST(): """purge stale output records from regression tests""" with env(debug=True): exe("pbbt test/input.yaml test/output.yaml -q --train --purge")
def TRAIN(): """run regression tests in the train mode""" with env(debug=True): exe("pbbt test/input.yaml test/output.yaml --train")
def TEST(): """run regression tests""" with env(debug=True): exe("pbbt test/input.yaml test/output.yaml -q")
def sphinx(command, cd=None): # Run `sphinx-build <command>`. with env(debug=True): sh(env.sphinx_path + " " + command, cd=cd)
def python(command, cd=None): # Run `python <command>`. with env(debug=True): sh(env.python_path + " " + command, cd=cd)