flow-controller
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: flow-controller | ||
| Version: 1.0.2 | ||
| Version: 1.0.3 | ||
| Summary: package for managing pipelines with simple commands | ||
@@ -5,0 +5,0 @@ Home-page: UNKNOWN |
@@ -1,1 +0,1 @@ | ||
| pynput | ||
| keyboard |
@@ -1,19 +0,21 @@ | ||
| from pynput.keyboard import Key, Listener | ||
| import threading | ||
| import time | ||
| import ctypes | ||
| from keyboard import is_pressed | ||
| def action_wrapper(target_key, cls): | ||
| def on_action(key): | ||
| if key == target_key: | ||
| def action_check(target_key, cls): | ||
| while 1: | ||
| if not cls.is_alive() or not cls.quit_thread.is_alive(): | ||
| return | ||
| if is_pressed(target_key): | ||
| cls.val = not cls.val | ||
| print(f'Val value has been switched to {cls.val}') | ||
| return on_action | ||
| time.sleep(3) | ||
| def quit_wrapper(target_key): | ||
| def on_action(key): | ||
| if key == target_key: | ||
| def quit_check(target_key, cls): | ||
| while cls.is_alive(): | ||
| if is_pressed(target_key): | ||
| return False | ||
| return on_action | ||
@@ -26,9 +28,8 @@ class key_press(threading.Thread): | ||
| self.val = True | ||
| self.active = True | ||
| self.action_thread = threading.Thread(target=action_check, args=(self.action_key, self)) | ||
| self.quit_thread = threading.Thread(target=quit_check, args=(self.quit_key, self)) | ||
| def run(self): | ||
| with Listener(on_press=action_wrapper(self.action_key, self), | ||
| on_release=quit_wrapper(self.quit_key)) as listener: | ||
| listener.join() | ||
| self.active = False | ||
| self.action_thread.start() | ||
| self.quit_thread.start() | ||
@@ -50,3 +51,2 @@ def get_id(self): | ||
| ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, 0) | ||
| print('Exception raise failure') | ||
| print('Exception raise failure') |
| import threading | ||
| from flow_controller.keyboard import key_press | ||
| from pynput.keyboard import Key, KeyCode | ||
| from keyboard import is_pressed | ||
| import time | ||
@@ -32,7 +32,6 @@ from datetime import datetime | ||
| def is_active(self): | ||
| self.handle() | ||
| return self.trigger.active | ||
| return self.trigger.quit_thread.is_alive() | ||
| def handle(self): | ||
| if not self.trigger.active: | ||
| if not self.trigger.quit_thread.is_alive(): | ||
| self.trigger.stop() | ||
@@ -81,4 +80,3 @@ self.trigger.join() | ||
| q, z = KeyCode(char='q'), KeyCode(char='z') | ||
| p = Pause(key_press(q, z)) | ||
| p = Pause(key_press('q', 'z')) | ||
@@ -85,0 +83,0 @@ start = time.time() |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: flow_controller | ||
| Version: 1.0.2 | ||
| Version: 1.0.3 | ||
| Summary: package for managing pipelines with simple commands | ||
@@ -5,0 +5,0 @@ Home-page: UNKNOWN |
+2
-2
@@ -9,8 +9,8 @@ #!/usr/bin/env python | ||
| name='flow_controller', | ||
| version='1.0.2', | ||
| version='1.0.3', | ||
| author='Ignace Konig', | ||
| description='package for managing pipelines with simple commands', | ||
| license='MIT', | ||
| install_requires=['pynput'], | ||
| install_requires=['keyboard'], | ||
| packages=setuptools.find_packages()) | ||
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
5875
0.82%112
-2.61%