Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from hupper.watchdog import WatchdogFileMonitor
kw['monitor_factory'] = WatchdogFileMonitor
if opts.watchman:
from hupper.watchman import WatchmanFileMonitor
kw['monitor_factory'] = WatchmanFileMonitor
if opts.reload_interval:
kw['reload_interval'] = opts.reload_interval
hupper.start_reloader(__name__ + '.main', **kw)
if hupper.is_active():
hupper.get_reloader().watch_files([os.path.join(here, 'foo.ini')])
hupper.get_reloader().watch_files(opts.watch_files)
if opts.callback_file:
with open(opts.callback_file, 'ab') as fp:
fp.write('{:d}\n'.format(int(time.time())).encode('utf8'))
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
if opts.watchdog:
from hupper.watchdog import WatchdogFileMonitor
kw['monitor_factory'] = WatchdogFileMonitor
if opts.watchman:
from hupper.watchman import WatchmanFileMonitor
kw['monitor_factory'] = WatchmanFileMonitor
if opts.reload_interval:
kw['reload_interval'] = opts.reload_interval
hupper.start_reloader(__name__ + '.main', **kw)
if hupper.is_active():
hupper.get_reloader().watch_files([os.path.join(here, 'foo.ini')])
hupper.get_reloader().watch_files(opts.watch_files)
if opts.callback_file:
with open(opts.callback_file, 'ab') as fp:
fp.write('{:d}\n'.format(int(time.time())).encode('utf8'))
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
kw['monitor_factory'] = lambda cb: PollingFileMonitor(cb, **pkw)
if opts.watchdog:
from hupper.watchdog import WatchdogFileMonitor
kw['monitor_factory'] = WatchdogFileMonitor
if opts.watchman:
from hupper.watchman import WatchmanFileMonitor
kw['monitor_factory'] = WatchmanFileMonitor
if opts.reload_interval:
kw['reload_interval'] = opts.reload_interval
hupper.start_reloader(__name__ + '.main', **kw)
if hupper.is_active():
hupper.get_reloader().watch_files([os.path.join(here, 'foo.ini')])
hupper.get_reloader().watch_files(opts.watch_files)
if opts.callback_file:
with open(opts.callback_file, 'ab') as fp:
fp.write('{:d}\n'.format(int(time.time())).encode('utf8'))
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
def make_proxy(monitor_factory, callback, logger):
from hupper.reloader import FileMonitorProxy
proxy = FileMonitorProxy(callback, logger)
proxy.monitor = monitor_factory(proxy.file_changed)
return proxy
def test_ignore_files():
class DummyMonitor(object):
paths = set()
def add_path(self, path):
self.paths.add(path)
from hupper.reloader import FileMonitorProxy
cb = DummyCallback()
proxy = FileMonitorProxy(cb, None, {'/a/*'})
monitor = proxy.monitor = DummyMonitor()
path = 'foo.txt'
assert path not in monitor.paths
proxy.add_path(path)
assert path in monitor.paths
path = '/a/foo.txt'
assert path not in monitor.paths
proxy.add_path(path)
assert path not in monitor.paths
def test_interval_parser():
assert interval_parser("5") == 5
def test_interval_parser_errors(value):
with pytest.raises(argparse.ArgumentTypeError):
interval_parser(value)
@hupper.watch(verbose=1)
def myfunc():
pass
kw['monitor_factory'] = lambda cb: PollingFileMonitor(cb, **pkw)
args = sys.argv[1:]
opts = parse_options(args)
if opts.reload:
kw = {}
if opts.poll:
from hupper.polling import PollingFileMonitor
pkw = {}
if opts.poll_interval:
pkw['poll_interval'] = opts.poll_interval
kw['monitor_factory'] = lambda cb: PollingFileMonitor(cb, **pkw)
if opts.watchdog:
from hupper.watchdog import WatchdogFileMonitor
kw['monitor_factory'] = WatchdogFileMonitor
if opts.watchman:
from hupper.watchman import WatchmanFileMonitor
kw['monitor_factory'] = WatchmanFileMonitor
if opts.reload_interval:
kw['reload_interval'] = opts.reload_interval
hupper.start_reloader(__name__ + '.main', **kw)
if hupper.is_active():
hupper.get_reloader().watch_files([os.path.join(here, 'foo.ini')])
hupper.get_reloader().watch_files(opts.watch_files)
if opts.callback_file: