def test_create_command_with_custom_gphome(self): self.subject = Command("my name", "my command string", ctxt=REMOTE, remoteHost="someHost", gphome="/new/gphome") self.assertIn("/new/gphome", self.subject.exec_context.gphome)
def __init__(self): super().__init__() self.name = 'device' self.description = '📈 Statistics about your device' self.commands = { 'battery': Command( description='🔋 see information about the state of your battery' ), 'reboot': Command(description='⚡ safely reboot your device'), 'shutdown': Command(description='🔌 safely shutdown your device', flags=[ Flag(['-r', '--reboot'], 'An alternate way to reboot your device', dtype='bool') ]), 'settings': Command(description='⚙️ open the Settings app', flags=[ Flag(['-c', '--close'], 'Closes the settings application', dtype='bool') ]) }
def __init__(self): super().__init__() self.name = 'debug' self.description = 'de-🐛-ing tools' self.commands = {'controlsd': Command(description='🔬 logs controlsd to /data/output.log by default', flags=[Flag(['-o', '--output'], 'Name of file to save log to', dtype='str')]), 'reload': Command(description='🔄 kills the current openpilot session and restarts it (all without rebooting)')}
def __init__(self): super().__init__() self.name = 'fork' self.description = '🍴 Manage installed forks, or install a new one' self.fork_params = ForkParams() self.remote_defaults = { 'commaai': RemoteInfo('openpilot', ['stock', 'origin'], 'release2'), 'dragonpilot-community': RemoteInfo('dragonpilot', ['dragonpilot'], 'devel-i18n') } # devel-i18n isn't most stable, but its name remains the same self.comma_origin_name = 'commaai' self.comma_default_branch = self.remote_defaults[ 'commaai'].default_branch self.commands = { 'switch': Command( description='🍴 Switch between any openpilot fork', flags=[ Flag( 'username', '👤 The username of the fork\'s owner to switch to, will use current fork if not provided', required=False, dtype='str'), Flag( ['-b', '--branch'], '🌿 Branch to switch to, will use default branch if not provided', required=False, dtype='str'), Flag( ['-r', '--repo'], 'The repository name of the fork, if its name isn\'t openpilot', required=False, dtype='str'), Flag([ '-f', '--force' ], '💪 Similar to checkout -f, force checks out new branch overwriting any changes' ) ]), 'list': Command(description='📜 See a list of installed forks and branches', flags=[ Flag('fork', '🌿 See branches of specified fork', dtype='str') ]) }
def __init__(self): super().__init__() self.name = 'panda' self.description = '🐼 panda interfacing tools' self.commands = { 'flash': Command( description= '🐼 flashes panda with make recover (usually works with the C2)' ), 'flash2': Command( description= '🎍 flashes panda using Panda module (usually works with the EON)' ) }
def __init__(self): super().__init__() self.name = 'debug' self.description = 'de-🐛-ing tools' self.commands = { 'controlsd': Command( description='🔬 logs controlsd to /data/output.log by default', flags=[ Flag(['-o', '--output'], 'Name of file to save log to', dtype='str') ]) } self.default_path = '/data/output.log'
class CommandTest(GpTestCase): def setUp(self): self.subject = Command("my name", "my command string") def test_get_stdout_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_stdout() def test_get_stdout_after_running_returns_stdout(self): self.subject.set_results(CommandResult(0, "my stdout", "", True, False)) self.assertEqual(self.subject.get_stdout(), "my stdout") def test_get_stdout_after_running_returns_stripped_stdout(self): self.subject.set_results(CommandResult(0, " my stdout\n", "", True, False)) self.assertEqual(self.subject.get_stdout(), "my stdout") def test_get_stdout_after_running_with_no_strip_returns_unstripped_stdout(self): self.subject.set_results(CommandResult(0, " my stdout\n", "", True, False)) self.assertEqual(self.subject.get_stdout(strip=False), " my stdout\n") def test_get_return_code_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_return_code() def test_get_stdout_after_running_returns_rc(self): self.subject.set_results(CommandResult(-23, "my stdout", "", True, False)) self.assertEqual(self.subject.get_return_code(), -23) def test_get_stderr_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_stderr() def test_get_stderr_after_running_returns_stderr(self): self.subject.set_results(CommandResult(0, "", "my stderr", True, False)) self.assertEqual(self.subject.get_stderr(), "my stderr") def test_create_command_with_default_gphome(self): self.subject = Command("my name", "my command string", ctxt=REMOTE, remoteHost="someHost") self.assertEquals(GPHOME, self.subject.exec_context.gphome) def test_create_command_with_custom_gphome(self): self.subject = Command("my name", "my command string", ctxt=REMOTE, remoteHost="someHost", gphome="/new/gphome") self.assertIn("/new/gphome", self.subject.exec_context.gphome) def test_running_command_remembers_pid(self): self.subject = Command("my name", "ls") self.subject.pid = -1 self.subject.run() self.assertTrue(self.subject.pid > 0)
def test_running_command_remembers_pid(self): self.subject = Command("my name", "ls") self.subject.pid = -1 self.subject.run() self.assertTrue(self.subject.pid > 0)
def test_create_command_with_default_gphome(self): self.subject = Command("my name", "my command string", ctxt=REMOTE, remoteHost="someHost") self.assertEquals(GPHOME, self.subject.exec_context.gphome)
def setUp(self): self.subject = Command("my name", "my command string")
def __init__(self, engine): Command.__init__(self, engine) self.cleverbot = Session()
def __init__(self, bot): Command.__init__(self, bot) self.polls = {} self.pollids = {} self.currentPoll = ""
def __init__(self, engine): Command.__init__(self, engine)
class CommandTest(GpTestCase): def setUp(self): self.subject = Command("my name", "my command string") def test_get_stdout_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_stdout() def test_get_stdout_after_running_returns_stdout(self): self.subject.set_results(CommandResult(0, "my stdout", "", True, False)) self.assertEqual(self.subject.get_stdout(), "my stdout") def test_get_stdout_after_running_returns_stripped_stdout(self): self.subject.set_results( CommandResult(0, " my stdout\n", "", True, False)) self.assertEqual(self.subject.get_stdout(), "my stdout") def test_get_stdout_after_running_with_no_strip_returns_unstripped_stdout( self): self.subject.set_results( CommandResult(0, " my stdout\n", "", True, False)) self.assertEqual(self.subject.get_stdout(strip=False), " my stdout\n") def test_get_return_code_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_return_code() def test_get_stdout_after_running_returns_rc(self): self.subject.set_results( CommandResult(-23, "my stdout", "", True, False)) self.assertEqual(self.subject.get_return_code(), -23) def test_get_stderr_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_stderr() def test_get_stderr_after_running_returns_stderr(self): self.subject.set_results(CommandResult(0, "", "my stderr", True, False)) self.assertEqual(self.subject.get_stderr(), "my stderr") def test_create_command_with_default_gphome(self): self.subject = Command("my name", "my command string", ctxt=REMOTE, remoteHost="someHost") self.assertEquals(GPHOME, self.subject.exec_context.gphome) def test_create_command_with_custom_gphome(self): self.subject = Command("my name", "my command string", ctxt=REMOTE, remoteHost="someHost", gphome="/new/gphome") self.assertIn("/new/gphome", self.subject.exec_context.gphome) def test_running_command_remembers_pid(self): self.subject = Command("my name", "ls") self.subject.pid = -1 self.subject.run() self.assertTrue(self.subject.pid > 0)
class CommandTest(GpTestCase): def setUp(self): self.subject = Command("my name", "my command string") def test_get_stdout_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_stdout() def test_get_stdout_after_running_returns_stdout(self): self.subject.set_results(CommandResult(0, "my stdout", "", True, False)) self.assertEqual(self.subject.get_stdout(), "my stdout") def test_get_stdout_after_running_returns_stripped_stdout(self): self.subject.set_results( CommandResult(0, " my stdout\n", "", True, False)) self.assertEqual(self.subject.get_stdout(), "my stdout") def test_get_stdout_after_running_with_no_strip_returns_unstripped_stdout( self): self.subject.set_results( CommandResult(0, " my stdout\n", "", True, False)) self.assertEqual(self.subject.get_stdout(strip=False), " my stdout\n") def test_get_return_code_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_return_code() def test_get_stdout_after_running_returns_rc(self): self.subject.set_results( CommandResult(-23, "my stdout", "", True, False)) self.assertEqual(self.subject.get_return_code(), -23) def test_get_stderr_before_running_raises(self): with self.assertRaisesRegexp(Exception, "command not run yet"): self.subject.get_stderr() def test_get_stderr_after_running_returns_stderr(self): self.subject.set_results(CommandResult(0, "", "my stderr", True, False)) self.assertEqual(self.subject.get_stderr(), "my stderr")