Browse Source

extended controls refactor: rename engine_id -> primary_engine_id

Fabian Peter Hammerle 6 years ago
parent
commit
1e1bf3c49d
3 changed files with 7 additions and 7 deletions
  1. 2 2
      scripts/tooncher-extend-controls
  2. 1 1
      tooncher/__init__.py
  3. 4 4
      tooncher/controls.py

+ 2 - 2
scripts/tooncher-extend-controls

@@ -9,7 +9,7 @@ import tooncher.controls
 def run(engine_pid,
         toggle_keysym_name=tooncher.controls.EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME):
     ec = tooncher.controls.ExtendedControls(
-        engine_pid=engine_pid,
+        primary_engine_pid=engine_pid,
         toggle_keysym_name=toggle_keysym_name,
     )
     ec.run()
@@ -24,7 +24,7 @@ def _init_argparser():
     argparser.add_argument(
         'engine_pid',
         type=int,
-        help="process id",
+        help="process id of engine to attach to",
     )
     argparser.add_argument(
         '--toggle', '-t',

+ 1 - 1
tooncher/__init__.py

@@ -152,7 +152,7 @@ def launch(engine_path, username, password, validate_ssl_certs=True,
         if enable_extended_keyboard_controls:
             try:
                 tooncher.controls.ExtendedControls(
-                    engine_pid=p.pid,
+                    primary_engine_pid=p.pid,
                     toggle_keysym_name=extended_keyboard_control_toggle_keysym_name,
                 ).run()
             except Exception as e:

+ 4 - 4
tooncher/controls.py

@@ -88,7 +88,7 @@ def x_wait_for_event(xdisplay, timeout_seconds):
 
 class ExtendedControls:
 
-    def __init__(self, engine_pid,
+    def __init__(self, primary_engine_pid,
                  toggle_keysym_name=EXTENDED_CONTROLS_DEFAULT_TOGGLE_KEYSYM_NAME):
         if not psutil:
             raise Exception('\n'.join([
@@ -106,7 +106,7 @@ class ExtendedControls:
                 'or',
                 '\t$ pip3 install --user xlib',
             ]))
-        self._engine_pid = engine_pid
+        self._primary_engine_pid = primary_engine_pid
         self._xdisplay = Xlib.display.Display()
         self._toggle_keysym = XK.string_to_keysym(toggle_keysym_name)
         if self._toggle_keysym == X.NoSymbol:
@@ -128,7 +128,7 @@ class ExtendedControls:
 
     @property
     def engine_running(self):
-        return psutil.pid_exists(self._engine_pid)
+        return psutil.pid_exists(self._primary_engine_pid)
 
     @property
     def xdisplay(self):
@@ -143,7 +143,7 @@ class ExtendedControls:
         while self.engine_running and (time.time() - start_epoch) <= timeout_seconds:
             windows = x_find_window_by_pid(
                 self._xdisplay,
-                self._engine_pid,
+                self._primary_engine_pid,
             )
             assert len(windows) <= 1
             if len(windows) == 1: