Mercurial > piecrust2
annotate piecrust/chefutil.py @ 113:de257cc40ce1
Re-enable proper caching of rendered segments in server.
The server keeps records on files that are processed while the server is
running. Disk caching is simply disabled for files that are known to use
other pages -- because unlike the baker, there's no cheap way to know
which files are up to date or not, and rendering is faster enough anyway.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 19 Oct 2014 00:30:44 -0700 |
parents | 8703be118430 |
children | 133845647083 |
rev | line source |
---|---|
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import time |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 from colorama import Fore |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
5 def format_timed(start_time, message, colored=True): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 end_time = time.clock() |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 time_str = '%8.1f ms' % ((end_time - start_time) * 1000.0) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 if colored: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 return '[%s%s%s] %s' % (Fore.GREEN, time_str, Fore.RESET, message) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 return '[%s] %s' % (time_str, message) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
11 |
39
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
12 |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
13 def log_friendly_exception(logger, ex): |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
14 indent = '' |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
15 while ex: |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
16 logger.error('%s%s' % (indent, str(ex))) |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
17 indent += ' ' |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
18 ex = ex.__cause__ |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
19 |
99
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
20 |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
21 def print_help_item(s, title, description, margin=4, align=25): |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
22 s.write(margin * ' ') |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
23 s.write(title) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
24 spacer = (align - margin - len(title) - 1) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
25 if spacer <= 0: |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
26 s.write("\n") |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
27 s.write(' ' * align) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
28 else: |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
29 s.write(' ' * spacer) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
30 s.write(description) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
31 s.write("\n") |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
32 |