diff options
author | nfnty <git@nfnty.se> | 2017-01-20 12:07:53 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-20 12:07:53 +0100 |
commit | 1c90e610de6591e8052a1056c775219b5e767002 (patch) | |
tree | 69b56f67dee1d6dfcea869de897846baaded3fa6 /examples/plugin_ipc.py | |
parent | e26d163debc9f55a89a27f94a43771526d2ff0b7 (diff) | |
parent | 03ee065e35c6a8f0e0dc1e66d8f4c3e83c51f315 (diff) | |
download | ranger-1c90e610de6591e8052a1056c775219b5e767002.tar.gz |
Merge branch 'lint'
Diffstat (limited to 'examples/plugin_ipc.py')
-rw-r--r-- | examples/plugin_ipc.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/examples/plugin_ipc.py b/examples/plugin_ipc.py index 47fb1c84..99637272 100644 --- a/examples/plugin_ipc.py +++ b/examples/plugin_ipc.py @@ -7,17 +7,20 @@ # Example: # $ echo tab_new ~/images > /tmp/ranger-ipc.1234 +from __future__ import (absolute_import, print_function) + import ranger.api -old_hook_init = ranger.api.hook_init + +HOOK_INIT_OLD = ranger.api.hook_init def hook_init(fm): try: # Create a FIFO. import os - IPC_FIFO = "/tmp/ranger-ipc." + str(os.getpid()) - os.mkfifo(IPC_FIFO) + ipc_fifo = "/tmp/ranger-ipc." + str(os.getpid()) + os.mkfifo(ipc_fifo) # Start the reader thread. try: @@ -30,7 +33,7 @@ def hook_init(fm): with open(filepath, 'r') as fifo: line = fifo.read() fm.execute_console(line.strip()) - thread.start_new_thread(ipc_reader, (IPC_FIFO,)) + thread.start_new_thread(ipc_reader, (ipc_fifo,)) # Remove the FIFO on ranger exit. def ipc_cleanup(filepath): @@ -39,10 +42,12 @@ def hook_init(fm): except IOError: pass import atexit - atexit.register(ipc_cleanup, IPC_FIFO) + atexit.register(ipc_cleanup, ipc_fifo) except IOError: # IPC support disabled pass finally: - old_hook_init(fm) + HOOK_INIT_OLD(fm) + + ranger.api.hook_init = hook_init |