changeset 1016:c4cfbbeed72e

chef: Fix crash for commands run outside of a website.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 29 Nov 2017 20:38:15 -0800
parents fa489c5e829e
children 3c669bb9498e
files piecrust/main.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/main.py	Wed Nov 29 20:37:57 2017 -0800
+++ b/piecrust/main.py	Wed Nov 29 20:38:15 2017 -0800
@@ -316,8 +316,9 @@
         return 0
 
     # Add some timing information.
-    app.env.stats.registerTimer('ChefStartup')
-    app.env.stats.stepTimerSince('ChefStartup', _chef_start_time)
+    if app.env:
+        app.env.stats.registerTimer('ChefStartup')
+        app.env.stats.stepTimerSince('ChefStartup', _chef_start_time)
 
     # Run the command!
     ctx = CommandContext(appfactory, app, parser, result)