示例#1
0
    def test_watch(self):

        # removing output file to test
        if os.path.exists(self.out_file):
            os.remove(self.out_file)

        observer = SassObserver()
        observer.add_output(self.out_file, self.watch_dir)
        observer.start()
        # wait some moments to initialize observer thread
        time.sleep(0.5)
        # append something to source file
        with open(self.sass_file, "a") as f:
            f.write(
                """
body
  background-color: #FFFFFF
"""
            )

        time.sleep(1)
        self.assertTrue(os.path.exists(self.out_file))

        observer.stop()
        observer.join()
示例#2
0
文件: cli.py 项目: pylover/isass
def start_watchdog():

    # Asserts
    assert args.output, "Please provide an output file via -o option, Standard output was not supported in watch mode."
    source_msg = "Please provide one or more directory as sources, files and standard input was not supported in watch mode."
    assert len(args.sources) > 0, source_msg
    for s in args.sources:
        assert os.path.isdir(s), source_msg

    observer = SassObserver()
    observer.add_output(args.output, dirs=helpers.get_source_dirs(args.sources), lib_dirs=args.lib_dirs)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()