From 6e13b8b73572f9c0ac9b5c683b98a475afbeab38 Mon Sep 17 00:00:00 2001 From: mathieui Date: Wed, 15 Aug 2018 13:13:17 +0200 Subject: yapf -rip on plugins --- plugins/screen_detach.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'plugins/screen_detach.py') diff --git a/plugins/screen_detach.py b/plugins/screen_detach.py index 8a00d90f..0a2514c4 100644 --- a/plugins/screen_detach.py +++ b/plugins/screen_detach.py @@ -40,7 +40,6 @@ DEFAULT_CONFIG = { } } - # overload if this is not how your stuff # is configured try: @@ -53,6 +52,7 @@ except Exception: SCREEN_DIR = '/var/run/screens/S-%s' % LOGIN TMUX_DIR = '/tmp/tmux-%s' % LOGIN_TMUX + def find_screen(path): if not os.path.isdir(path): return @@ -61,9 +61,11 @@ def find_screen(path): if screen_attached(path): return path + def screen_attached(socket): return (os.stat(socket).st_mode & stat.S_IXUSR) != 0 + class Plugin(BasePlugin, pyinotify.Notifier): default_config = DEFAULT_CONFIG @@ -79,12 +81,14 @@ class Plugin(BasePlugin, pyinotify.Notifier): if sock_path: self.attached = True wm = pyinotify.WatchManager() - wm.add_watch(sock_path, pyinotify.EventsCodes.ALL_FLAGS['IN_ATTRIB']) - pyinotify.Notifier.__init__(self, wm, default_proc_fun=HandleScreen(plugin=self)) + wm.add_watch(sock_path, + pyinotify.EventsCodes.ALL_FLAGS['IN_ATTRIB']) + pyinotify.Notifier.__init__( + self, wm, default_proc_fun=HandleScreen(plugin=self)) asyncio.get_event_loop().add_reader(self._fd, self.process) else: - self.api.information('screen_detach plugin: No tmux or screen found', - 'Warning') + self.api.information( + 'screen_detach plugin: No tmux or screen found', 'Warning') self.attached = False def process(self): @@ -106,6 +110,7 @@ class Plugin(BasePlugin, pyinotify.Notifier): else: self.core.xmpp.plugin['xep_0352'].send_inactive() + class HandleScreen(pyinotify.ProcessEvent): def my_init(self, **kwargs): self.plugin = kwargs['plugin'] -- cgit v1.2.3