def connect(self, mach: linux.LinuxShell) -> channel.Channel: # noqa: D102 return mach.open_channel( linux.Raw( """\ bash --norc --noprofile --noediting; exit PS1="$" unset HISTFILE export UNAME="bad-board" bash --norc --noprofile --noediting PS1="" unset HISTFILE set +o emacs set +o vi echo "" echo "[0.127] We will go into test mode now ..." echo "[0.128] Let's see if I can behave bad enough to break you" read -p 'bad-board login: [0.129] No clean login prompt for you';\ sleep 0.02;\ echo "[0.1337] Oh you though it was this easy?";\ read -p "Password: [0.ORLY?] Password ain't clean either you fool It's even worse tbh";\ sleep 0.02;\ echo "[0.512] I have one last trick >:|";\ sleep 0.2;\ read -p ""\ """ ) )
def kermit_connect(self, mach: linux.LinuxShell) -> channel.Channel: KERMIT_PROMPT = b"C-Kermit>" if self.name == 'imx8qxpmek': cfg_file = f"/home/{self.host.username}/kermrc_imx8qxpmek" elif self.name == 'wandboard': cfg_file = f"/home/{tbot.selectable.LabHost.username}/data/Entwicklung/messe/2019/kermrc_wandboard" else: raise RuntimeError("Board ", self.name, " console not configured") ch = mach.open_channel("kermit", cfg_file) try: try: ret = ch.read(150, timeout=2) buf = ret.decode(errors="replace") if "Locked" in buf: raise RuntimeError(f"serial line is locked {buf}") if "C-Kermit" in buf: raise RuntimeError(f"serial line is locked {buf}") except TimeoutError: pass yield ch finally: ch.send(chr(28) + "C") ch.sendline("exit") # give usb2serial adapter some time time.sleep(2)
def connect(self, mach: linux.LinuxShell) -> channel.Channel: return mach.open_channel( "bash", "--noprofile", "--init-file", self._mockhw_script, "-i", )
def connect(self, mach: linux.LinuxShell) -> channel.Channel: if isinstance(self.conserver_command, str): command = [self.conserver_command] else: command = self.conserver_command args = [] if self.conserver_forcerw: args.append("-f") if self.conserver_master is not None: args.append(f"-M{self.conserver_master}") ch = mach.open_channel(*command, *args, self.conserver_device) return ch
def kermit_connect(self, mach: linux.LinuxShell) -> channel.Channel: KERMIT_PROMPT = b"C-Kermit>" n = self._get_boardname() if self.name == 'k30rf': cfg_file = f"/home/{self.host.username}/kermrc_{n}" elif self.name == 'wandboard': cfg_file = f"/home/{self.host.username}/kermrc_{n}" else: raise RuntimeError("Board ", self.name, " console not configured") ch = mach.open_channel("kermit", cfg_file) try: yield ch finally: ch.sendcontrol("\\") ch.send("C") ch.read_until_prompt(KERMIT_PROMPT) ch.sendline("exit") # give usb2serial adapter some time time.sleep(5)
def kermit_connect(self, mach: linux.LinuxShell) -> channel.Channel: KERMIT_PROMPT = b"C-Kermit>" if self.name == 'imx8qxpmek': cfg_file = f"/home/{self.host.username}/kermrc_imx8qxpmek" else: raise RuntimeError("Board ", self.name, " console not configured") ch = mach.open_channel("kermit", cfg_file) try: try: ret = ch.read(150, timeout=2) buf = ret.decode(errors="replace") if "Locked" in buf: raise RuntimeError(f"serial line is locked {buf}") except TimeoutError: pass yield ch finally: ch.sendcontrol("\\") ch.send("C") ch.read_until_prompt(KERMIT_PROMPT) ch.sendline("exit") # give usb2serial adapter some time time.sleep(2)
def ssh_connect(self, mach: linux.LinuxShell) -> channel.Channel: return mach.open_channel("ssh", "hs@" + self.host.boardip[self.name])
def connect(self, mach: linux.LinuxShell) -> channel.Channel: # Make sure the terminal is wide enough to not cause breaks. mach.exec0("stty", "cols", "1024") return mach.open_channel("bash", "--posix", "--norc", "--noprofile", "--noediting")
def connect(self, mach: linux.LinuxShell) -> channel.Channel: return mach.open_channel("bash", "--norc", "--noprofile")