def handle(self, *command_args, **command_options): if command_options["debug"]: logging.getLogger("django_handlebars").setLevel(logging.DEBUG) console = NullConsole() if command_options["quiet"] else Console() try: console.set_out(self.stdout) console.set_err(self.stderr) console.raw = command_options["raw"] blockers = cant_compile() if blockers: console.err( self.warn_unavail( "<color:red>You can not compile handlebars templates:<color:reset>", blockers)) return from django_handlebars.management.compiler import Compiler compiler = Compiler(console=console) if command_options["clean"]: compiler.cleanup() if command_options["watch"]: blockers = cant_observe() if blockers: console.err( self.warn_unavail( "<color:red>You can not watch file changes:<color:reset>", blockers)) return from django_handlebars.management.observer import Observer compiler.add_path(appsettings.TPL_DIR) observer = Observer(appsettings.TPL_DIR, compiler) def close(signum, stack): console.out("\nShutting down observer...") observer.stop() signal.signal(signal.SIGINT, close) observer.start() signal.pause() else: compiler.add_path(appsettings.TPL_DIR) compiler.terminate() except ReadableError as err: console.err("<color:red>Ooops!<color:reset> %s" % err.message) return
def handle(self, *command_args, **command_options): if command_options["debug"]: logging.getLogger("django_handlebars").setLevel(logging.DEBUG) console = NullConsole() if command_options["quiet"] else Console() try: console.set_out(self.stdout) console.set_err(self.stderr) console.raw = command_options["raw"] blockers = cant_compile() if blockers: console.err( self.warn_unavail("<color:red>You can not compile handlebars templates:<color:reset>", blockers) ) return from django_handlebars.management.compiler import Compiler compiler = Compiler(console=console) if command_options["clean"]: compiler.cleanup() if command_options["watch"]: blockers = cant_observe() if blockers: console.err(self.warn_unavail("<color:red>You can not watch file changes:<color:reset>", blockers)) return from django_handlebars.management.observer import Observer compiler.add_path(appsettings.TPL_DIR) observer = Observer(appsettings.TPL_DIR, compiler) def close(signum, stack): console.out("\nShutting down observer...") observer.stop() signal.signal(signal.SIGINT, close) observer.start() signal.pause() else: compiler.add_path(appsettings.TPL_DIR) compiler.terminate() except ReadableError as err: console.err("<color:red>Ooops!<color:reset> %s" % err.message) return
import time import tempfile import shutil from imp import reload from django.template import Template, Context from unittest import skipIf from django.test import TestCase from django.test.utils import override_settings as _override_settings import appsettings from django_handlebars.utils import ReadableError, cant_compile, cant_observe CANT_COMPILE = "; ".join(cant_compile()) CANT_OBSERVE = "; ".join(cant_observe()) class override_settings(_override_settings): def enable(self): super(override_settings, self).enable() reload(appsettings) def disable(self): super(override_settings, self).disable() reload(appsettings) class TagsTest(TestCase):
import os import time import tempfile import shutil import urllib2 from django.template import Template, Context from unittest import skipIf from django.test import TestCase from django.test.utils import override_settings as _override_settings import appsettings from django_handlebars.utils import ReadableError, cant_compile, cant_observe CANT_COMPILE = "; ".join(cant_compile()) CANT_OBSERVE = "; ".join(cant_observe()) class override_settings(_override_settings): def enable(self): super(override_settings, self).enable() reload(appsettings) def disable(self): super(override_settings, self).disable() reload(appsettings) class TagsTest(TestCase): src_dir = tempfile.mkdtemp(prefix="tags-test-sources-")