mirror of
https://github.com/powerline/powerline.git
synced 2025-07-26 23:35:04 +02:00
Some fixes for flake8, remove executable bit and shebang
This commit is contained in:
parent
559b5caef2
commit
5d1089f252
@ -1,16 +1,20 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# vim:fileencoding=UTF-8:noet
|
# vim:fileencoding=UTF-8:noet
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os, sys, errno, time
|
import os
|
||||||
|
import sys
|
||||||
|
import errno
|
||||||
|
import time
|
||||||
from threading import RLock
|
from threading import RLock
|
||||||
|
|
||||||
|
|
||||||
class INotifyError(Exception):
|
class INotifyError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class INotifyWatch(object):
|
class INotifyWatch(object):
|
||||||
|
|
||||||
is_stat_based = False
|
is_stat_based = False
|
||||||
@ -58,7 +62,8 @@ class INotifyWatch(object):
|
|||||||
NONBLOCK = 0x800
|
NONBLOCK = 0x800
|
||||||
|
|
||||||
def __init__(self, inotify_fd, add_watch, rm_watch, read, expire_time=10):
|
def __init__(self, inotify_fd, add_watch, rm_watch, read, expire_time=10):
|
||||||
import ctypes, struct
|
import ctypes
|
||||||
|
import struct
|
||||||
self._add_watch, self._rm_watch = add_watch, rm_watch
|
self._add_watch, self._rm_watch = add_watch, rm_watch
|
||||||
self._read = read
|
self._read = read
|
||||||
# We keep a reference to os to prevent it from being deleted
|
# We keep a reference to os to prevent it from being deleted
|
||||||
@ -194,6 +199,7 @@ class INotifyWatch(object):
|
|||||||
del self._rm_watch
|
del self._rm_watch
|
||||||
del self._inotify_fd
|
del self._inotify_fd
|
||||||
|
|
||||||
|
|
||||||
def get_inotify(expire_time=10):
|
def get_inotify(expire_time=10):
|
||||||
''' Initialize the inotify based file watcher '''
|
''' Initialize the inotify based file watcher '''
|
||||||
import ctypes
|
import ctypes
|
||||||
@ -226,14 +232,13 @@ def get_inotify(expire_time=10):
|
|||||||
read = prototype(('read', libc), (
|
read = prototype(('read', libc), (
|
||||||
(1, "fd"), (1, "buf"), (1, "count")), use_errno=True)
|
(1, "fd"), (1, "buf"), (1, "count")), use_errno=True)
|
||||||
|
|
||||||
|
|
||||||
inotify_fd = init1(INotifyWatch.CLOEXEC | INotifyWatch.NONBLOCK)
|
inotify_fd = init1(INotifyWatch.CLOEXEC | INotifyWatch.NONBLOCK)
|
||||||
if inotify_fd == -1:
|
if inotify_fd == -1:
|
||||||
raise INotifyError(os.strerror(ctypes.get_errno()))
|
raise INotifyError(os.strerror(ctypes.get_errno()))
|
||||||
return INotifyWatch(inotify_fd, add_watch, rm_watch, read, expire_time=expire_time)
|
return INotifyWatch(inotify_fd, add_watch, rm_watch, read, expire_time=expire_time)
|
||||||
|
|
||||||
class StatWatch(object):
|
|
||||||
|
|
||||||
|
class StatWatch(object):
|
||||||
is_stat_based = True
|
is_stat_based = True
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -266,6 +271,7 @@ class StatWatch(object):
|
|||||||
with self.lock:
|
with self.lock:
|
||||||
self.watches = {}
|
self.watches = {}
|
||||||
|
|
||||||
|
|
||||||
def create_file_watcher(use_stat=False, expire_time=10):
|
def create_file_watcher(use_stat=False, expire_time=10):
|
||||||
'''
|
'''
|
||||||
Create an object that can watch for changes to specified files. To use:
|
Create an object that can watch for changes to specified files. To use:
|
||||||
@ -300,4 +306,3 @@ if __name__ == '__main__':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
watcher.close()
|
watcher.close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user