342
344
[navigation.scan_url, next_page_revno], **params)
347
def directory_breadcrumbs(path, is_root, view):
349
Generate breadcrumb information from the directory path given
351
The path given should be a path up to any branch that is currently being
355
path -- The path to convert into breadcrumbs
356
is_root -- Whether or not loggerhead is serving a branch at its root
357
view -- The type of view we are showing (files, changes etc)
359
# Is our root directory itself a branch?
361
if view == 'directory':
369
# Create breadcrumb trail for the path leading up to the branch
371
'dir_name': "(root)",
376
dir_parts = path.strip('/').split('/')
377
for index, dir_name in enumerate(dir_parts):
379
'dir_name': dir_name,
380
'path': '/'.join(dir_parts[:index + 1]),
383
# If we are not in the directory view, the last crumb is a branch,
384
# so we need to specify a view
385
if view != 'directory':
386
breadcrumbs[-1]['suffix'] = '/' + view
390
def branch_breadcrumbs(path, inv, view):
392
Generate breadcrumb information from the branch path given
394
The path given should be a path that exists within a branch
397
path -- The path to convert into breadcrumbs
398
inv -- Inventory to get file information from
399
view -- The type of view we are showing (files, changes etc)
401
dir_parts = path.strip('/').split('/')
402
inner_breadcrumbs = []
403
for index, dir_name in enumerate(dir_parts):
404
inner_breadcrumbs.append({
405
'dir_name': dir_name,
406
'file_id': inv.path2id('/'.join(dir_parts[:index + 1])),
407
'suffix': '/' + view ,
409
return inner_breadcrumbs
345
412
def decorator(unbound):
346
413
def new_decorator(f):
445
512
overrides = dict((k, v) for (k, v) in overrides.iteritems() if k in _valid)
446
513
map.update(overrides)
517
class Reloader(object):
519
This class wraps all paste.reloader logic. All methods are @classmethod.
522
_reloader_environ_key = 'PYTHON_RELOADER_SHOULD_RUN'
525
def _turn_sigterm_into_systemexit(self):
527
Attempts to turn a SIGTERM exception into a SystemExit exception.
533
def handle_term(signo, frame):
535
signal.signal(signal.SIGTERM, handle_term)
538
def is_installed(self):
539
return os.environ.get(self._reloader_environ_key)
543
from paste import reloader
544
reloader.install(int(1))
547
def restart_with_reloader(self):
548
"""Based on restart_with_monitor from paste.script.serve."""
549
print 'Starting subprocess with file monitor'
551
args = [sys.executable] + sys.argv
552
new_environ = os.environ.copy()
553
new_environ[self._reloader_environ_key] = 'true'
557
self._turn_sigterm_into_systemexit()
558
proc = subprocess.Popen(args, env=new_environ)
559
exit_code = proc.wait()
561
except KeyboardInterrupt:
562
print '^C caught in monitor process'
566
and hasattr(os, 'kill')):
569
os.kill(proc.pid, signal.SIGTERM)
570
except (OSError, IOError):
573
# Reloader always exits with code 3; but if we are
574
# a monitor, any exit code will restart
577
print '-'*20, 'Restarting', '-'*20