def test_cli1(): cwd = '.' cmd = ['rosrun', 'easy_algo', 'summary'] system_cmd_result(cwd, cmd, display_stdout=True, display_stderr=True, raise_on_error=True)
def run(which, expect): v = False cwd = create_tmpdir('run-regression') try: cmd = [ 'rosrun', 'easy_regression', 'run', '--expect', expect, '--test', which, '-c', 'rmake' ] system_cmd_result(cwd, cmd, display_stdout=v, display_stderr=v, raise_on_error=True) finally: shutil.rmtree(cwd)
def check(self): initial = 'duckiebot-not-configured' cmd = 'iwconfig' try: res = system_cmd_result(None, cmd, display_stdout=False, display_stderr=False, raise_on_error=True, capture_keyboard_interrupt=False, env=None) except CmdException as e: msg = 'The command failed\n' msg += '\n' + indent(e, ' >') raise CheckError(msg) if initial in res.stdout: msg = 'The robot is creating a network %r.' % initial l = 'According to iwconfig, you are creating a network %r.' % initial l += '\nThis means that you have failed to properly configure the robot.' l += '\nIt is likely the people around you are trying to connect to your robot.' l += '\n\nEntire output of iwconfig:\n\n' + indent( res.stdout, ' > ') raise CheckFailed(msg, l)
def check(self): expect = '4.4.38-v7+' cmd = ['uname', '-r'] try: res = system_cmd_result(None, cmd, display_stdout=False, display_stderr=False, raise_on_error=True, capture_keyboard_interrupt=False, env=None) except CmdException as e: msg = 'The command failed\n' msg += '\n' + indent(e, ' >') raise CheckError(msg) found = res.stdout.strip() if found != expect: msg = 'You are running kernel %r instead of %r.' % (found, expect) l = 'The kernel version is important because otherwise the Edimax\n' l += 'driver will not work correctly and needs to be recompiled.\n' l += '\n' l += 'Please report this error because we thought that the kernel\n' l += 'was prevented to update.' raise CheckFailed(msg, l)
def check(self): cmd = ['ssh', '-T', '*****@*****.**'] res = system_cmd_result( '.', cmd, display_stdout=False, display_stderr=False, raise_on_error=False, capture_keyboard_interrupt=True, # XXX? env=None) expect = 'successfully authenticated' if res.ret == 1 and expect in res.stderr: # ok return if res.ret == 255 and 'denied' in res.stderr: msg = 'You do not have access to Github. ' l = summary_of_cmdres(res) raise CheckFailed(msg, l) msg = 'There is something wrong with contacting Github.' raise_CheckError_from_CommandResult(res, msg)
def git_cmd(cmd): cwd = get_duckietown_root() res = system_cmd_result(cwd, cmd, display_stdout=False, display_stderr=False, raise_on_error=True) return res.stdout.strip()
def test_cli2(): cwd = '.' cmd = ['rosrun', 'what_the_duck', 'what-the-duck'] res = system_cmd_result(cwd, cmd, display_stdout=True, display_stderr=True, raise_on_error=False) assert res.ret > 0
def test_cli2(): cwd = '.' cmd = ['rosrun', 'what_the_duck', 'what-the-duck'] res = system_cmd_result(cwd, cmd, display_stdout=True, display_stderr=True, raise_on_error=False) if not (res.ret == 0): raise Exception(str(res))
def get_active_groups(username): cmd = ['groups', username] try: res = system_cmd_result('.', cmd, display_stdout=False, display_stderr=False, raise_on_error=True, capture_keyboard_interrupt=False, env=None) except CmdException as e: raise CheckError(str(e)) active_groups = res.stdout.split() # XXX return active_groups
def check(self): cmd = ['git', 'lfs'] res = system_cmd_result('.', cmd, display_stdout=False, display_stderr=False, raise_on_error=False, capture_keyboard_interrupt=True, # XXX? env=None) if res.ret != 0: msg = '`git lfs` returned non-zero.' raise CheckFailed(msg)
def dropbox_links_main(query): logger.info('NOTE: Run this inside ~/Dropbox/duckietown-data. ') logger.info( 'NOTE: There are some hard-coded paths to modify in dropbox_links.py') output = get_urls_path() if os.path.exists(output): urls = yaml.safe_load(open(output).read()) for k, v in list(urls.items()): if not v.startswith('http'): del urls[k] else: urls = {} command = '/home/andrea/bin/dropbox' base = '/mnt/dorothy-duckietown-data/' db = get_easy_logs_db() logs = db.query(query) logger.info('Found %d logs.' % len(logs)) for logname, log in logs.items(): if logname in urls: logger.info('Already have %s' % logname) continue filename = log.filename only = filename.replace(base, '') cmd = [command, 'sharelink', only] res = system_cmd_result(cwd='.', cmd=cmd, display_stdout=False, display_stderr=True, raise_on_error=True, write_stdin='', capture_keyboard_interrupt=False, env=None) link = res.stdout.strip() if 'responding' in link: logger.debug('Dropbox is not responding, I will stop here.') break logger.info('link : %s' % link) urls[logname] = link yaml.default_flow_style = True # yaml.indent(mapping=2, sequence=4, offset=2) with open(output, 'w') as f: yaml.dump(urls, f)
def is_package_installed(package_name): if '\n' in package_name or ' ' in package_name: raise ValueError(package_name) cmd = [ 'dpkg-query', '--show', "--showformat='${db:Status-Status}\n'", package_name ] res = system_cmd_result(None, cmd, display_stdout=False, display_stderr=False, raise_on_error=False, capture_keyboard_interrupt=False, env=None) return (res.ret == 0) and ('installed' in res.stdout)
def fail_if_stdout_contains(cwd, cmd, substring): try: res = system_cmd_result(cwd, cmd, display_stdout=False, display_stderr=False, raise_on_error=True, capture_keyboard_interrupt=False, env=None) except CmdException as e: msg = 'The command failed\n' msg += '\n' + indent(e, ' >') raise CheckError(msg) if substring in res.stdout: compact = ('I found the string "%s" in output of `%s`' % (substring, " ".join(cmd))) long_explanation = 'Complete output is:\n\n' + indent( res.stdout.strip(), ' > ') raise CheckFailed(compact, long_explanation)