Commits

zzzeek  committed 1f46518

- use local config
- mako exceptions
- detect newly added files

  • Participants
  • Parent commits acba884

Comments (0)

Files changed (1)

File blogodev/blogodev.py

 import os
 import sys
 import stat
+import traceback
 import shutil
 import tempfile
 import time
 import argparse
 from mako.template import Template
 from mako.lookup import TemplateLookup
+from mako import exceptions as mako_exceptions
 
 from blogofile.cache import bf
 from blogofile import config, site_init, util, server, cache, filter, controller
-from blogofile.main import config_init
 
 logging.basicConfig()
 logger = logging.getLogger("blogofile")
             _check_output(state)
         except KeyboardInterrupt:
             bfserver.shutdown()
+        except:
+            print traceback.print_exc()
 
+def config_init(args):
+    try:
+        config.init("_config.py")
+    except config.ConfigNotFoundException: #pragma: no cover
+        sys.exit("No configuration found in source dir: {0}".format(args.src_dir))
 
 def _file_mtime(f):
     if not os.path.exists(f):
         return st[stat.ST_MTIME]
 
 def _check_output(state):
+    starting = not(state)
     for src, dest in _walk_files(output_dir, True):
         src_mtime = _file_mtime(src)
-        if src not in state:
+        if starting:
             state[src] = src_mtime
         elif src_mtime > state[src]:
             logger.info("File %s changed since start", src)
             break
 
 def _rebuild():
+    print("File changes detected, rebuilding...")
     writer = Writer()
     logger.debug("Running user's pre_build() function...")
     config.pre_build()