Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
with open(os.path.join(os.getcwd(), args.html_output_dir, 'index.html'), 'w') as f:
f.write(index_html)
except Exception:
traceback.print_exc(file=sys.stderr)
sys.exit(-1)
sys.exit()
# Watch for any changes in the docs or style directories.
dn_watch_files = []
observer = None
if watch_changes:
observer = Observer()
observer.schedule(ReloadHandler(app), path=dir_documents, recursive=True)
observer.start()
dn_watch_files = build_reload_files_list([__name__, dir_style])
# Run the server.
if args.set_host:
try:
print('Attempting set sevelopment server listen on public IP address: ' + args.set_host)
print('WARNING: The Docnado development environment is intended to be used as a development tool ONLY, '
'and is not recommended for use in a production environment.')
app.run(debug=flask_debug, port=PORT_NUMBER, extra_files=dn_watch_files, host=args.set_host)
except OSError as e:
print(e)
print(f'Error initialising server.')
except KeyboardInterrupt:
pass
def _watch(self, handler, data):
file_handler = FileHandler(
filename=self.filename,
handler=handler,
file_type='yaml'
)
observer = Observer()
directory = os.path.dirname(self.filename)
observer.schedule(file_handler, directory, recursive=False)
observer.start()
observer.join()
RUN_RELOADER = True
FILE_MODIFIED = 1
I18N_MODIFIED = 2
STATIC_MODIFIED = 3
_exception = None
_error_files = []
_cached_modules = set()
_cached_filenames = []
_cached_folders = set()
_cached_static_folders = None
class BlockingObserver(Observer):
last_event = None
def run(self):
print 'observer.run'
pass
def process_next_event(self):
print 'process next event:'
done = False
while not done:
print ' not done'
event, watch = self.event_queue.get(block=True, timeout=None)
print ' event:', event
print ' watch:', watch
event.root = watch.path
if self.last_run and self.last_run > time.time() - 0.01:
# Prevent random duplicate events with inotify
return
print(u'Compiling assets ... ', end='')
self.last_run = compile_assets()
class VersionChangeHandler(PatternMatchingEventHandler):
def on_any_event(self, event):
update_version()
asset_handler = PathChangeHandler(patterns=['*.coffee', '*.scss', '*.handlebars', '*.js'])
version_handler = VersionChangeHandler(patterns=['*/version.yml'])
observer = Observer()
observer.start()
observer.schedule(asset_handler, path='./app/', recursive=True)
observer.schedule(version_handler, path='./', recursive=False)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
def __init__(self, base_dir, inst_data=None):
'''Note that idempotent initialization of the SQLite database is done on a per-run_id
basis in the body of connect, since each run is stored in a separate database.'''
self._base_dir = os.path.abspath(check.str_param(base_dir, 'base_dir'))
mkdir_p(self._base_dir)
self._watchers = {}
self._obs = Observer()
self._obs.start()
self._inst_data = check.opt_inst_param(inst_data, 'inst_data', ConfigurableClassData)
try:
return apply(cmd, args)
except Exception as e:
puts(colored.red('Ouch. Something\'s wrong with "%s":' % args[0]))
log.exception('SAFERUN: Got exception when processing %s', args)
errors.update( {args[0]:e} )
return False
if mode == 'archive':
event_handler = ArchiveEventHandler(jfs, topdir)
elif mode == 'sync':
event_handler = SyncEventHandler(jfs, topdir)
#event_handler = LoggingEventHandler()
elif mode == 'share':
event_handler = ShareEventHandler(jfs, topdir)
observer = Observer()
observer.schedule(event_handler, topdir, recursive=True)
observer.start()
try:
puts(colored.green('Starting JottaCloud monitor'))
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
puts(colored.red('JottaCloud monitor stopped'))
observer.join()
args.command = None
if args.debug_force_polling:
from watchdog.observers.polling import PollingObserver as Observer
else:
from watchdog.observers import Observer
patterns, ignore_patterns = parse_patterns(args.patterns,
args.ignore_patterns)
handler = ShellCommandTrick(shell_command=args.command,
patterns=patterns,
ignore_patterns=ignore_patterns,
ignore_directories=args.ignore_directories,
wait_for_process=args.wait_for_process,
drop_during_process=args.drop_during_process)
observer = Observer(timeout=args.timeout)
observe_with(observer, handler, args.directories, args.recursive)
def _watch(self, app, arguments, builder):
# By default we're watching for events in content directory.
watch_paths = [
app.conf['paths']['content'],
]
# But it'd be nice to watch themes directories either.
for theme in app._themes:
if os.path.exists(theme):
watch_paths.append(theme)
observer = Observer()
for path in watch_paths:
observer.schedule(
_ChangeWatcher(builder, ignore=[
os.path.abspath(arguments.conf),
]),
path, recursive=True)
# We also should watch for user's settings explicitly, because
# they may located not in the content directory.
if os.path.exists(arguments.conf):
observer.schedule(
_ChangeWatcher(builder, recreate_app=True, watch_for=[
os.path.abspath(arguments.conf),
]),
os.path.abspath(os.path.dirname(arguments.conf)))
def __init__(self, paths, bml):
self.observer = Observer()
if not isinstance(paths, list):
paths = [paths]
evh = AIOEventHandler(bml)
for path in paths:
self.observer.schedule(evh, path, recursive=False)
# Listen for Fast5 files in dir
# This must be setup from short read assemblie information
# Setup initial counter
N50_list = [90152]
reads_list = [0]
scaffold_list = [44]
global counter
# counter = short_assembly(args.short_reads)
counter = [0, N50_list, reads_list, scaffold_list, None]
# start_bokeh_server()
bokeh_plots(counter)
# create and start observer
observer1 = Observer()
observer1.schedule(Fast5Handler(), path=args.watch)
observer1.start()
while not completed:
time.sleep(1)
print('Completed!')
observer1.stop()
observer1.join()