diff options
author | nfnty <git@nfnty.se> | 2016-12-21 05:06:55 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-17 05:59:02 +0100 |
commit | b3d031a913814900467358b2adf20a148bf6de1a (patch) | |
tree | 6f5b435817ec9cbe850fb73485a7e6c77da28c14 /examples/plugin_ipc.py | |
parent | 76791a70467d7223a966aa9f12f5583b01d704a8 (diff) | |
download | ranger-b3d031a913814900467358b2adf20a148bf6de1a.tar.gz |
linting: pylint and flake8
Diffstat (limited to 'examples/plugin_ipc.py')
-rw-r--r-- | examples/plugin_ipc.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/examples/plugin_ipc.py b/examples/plugin_ipc.py index 47fb1c84..ef87c3c5 100644 --- a/examples/plugin_ipc.py +++ b/examples/plugin_ipc.py @@ -9,15 +9,16 @@ 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 +31,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 +40,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 |