Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeaz committed May 26, 2024
1 parent 0ea667a commit ca441b1
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions arsenal/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ def __call__(self, parser, namespace, values, option_string=None):
raise ValueError("Not a PANE_PATH")
setattr(namespace, self.dest, values)

class App:


class App:
tmux_server = None
tmux_session = None

Expand Down Expand Up @@ -173,36 +172,7 @@ def start(self, args, cheatsheets):
self.prefil_shell_cmd(cmd)
break
elif args.tmux_new:
pane_path = args.tmux_new.split(":")
new_window = False
import libtmux
try:
window = self.tmux_session.select_window(pane_path[1])
except libtmux.exc.LibTmuxException:
window = self.tmux_session.new_window(attach=False, window_name=pane_path[1])
new_window = True
if new_window:
pane = window.panes[0]
elif pane_path[2] == "": # all panes
pane = None
elif int(pane_path[2]) > len(window.panes):
pane = window.split_window(attach=False)
time.sleep(0.3)
else:
pane = window.panes[int(pane_path[2])]
if pane:
if args.exec:
pane.send_keys(cmd.cmdline)
else:
pane.send_keys(cmd.cmdline, enter=False)
pane.select_pane()
else:
for pane in window.panes:
if args.exec:
pane.send_keys(cmd.cmdline)
else:
pane.send_keys(cmd.cmdline, enter=False)
pane.select_pane()
self.process_tmux(args, cmd.cmdline)
break
# DEFAULT: Prefill Shell CMD
else:
Expand Down Expand Up @@ -250,7 +220,37 @@ def check_tmux(self, args):
except libtmux._internal.query_list.ObjectDoesNotExist:
raise RuntimeError(f"Could not find session {pane_path[0]}") from None


def process_tmux(self, args, cmdline):
pane_path = args.tmux_new.split(":")
new_window = False
import libtmux
try:
window = self.tmux_session.select_window(pane_path[1])
except libtmux.exc.LibTmuxException:
window = self.tmux_session.new_window(attach=False, window_name=pane_path[1])
new_window = True
if new_window:
pane = window.panes[0]
elif pane_path[2] == "": # all panes
pane = None
elif int(pane_path[2]) > len(window.panes):
pane = window.split_window(attach=False)
time.sleep(0.3)
else:
pane = window.panes[int(pane_path[2])]
if pane:
if args.exec:
pane.send_keys(cmdline)
else:
pane.send_keys(cmdline, enter=False)
pane.select_pane()
else:
for pane in window.panes:
if args.exec:
pane.send_keys(cmdline)
else:
pane.send_keys(cmdline, enter=False)
pane.select_pane()
def main():
try:
App().run()
Expand Down

0 comments on commit ca441b1

Please sign in to comment.