コード例 #1
0
ファイル: server.py プロジェクト: echan85/python-livereload
    def on_message(self, message):
        """Handshake with livereload.js

        1. client send 'hello'
        2. server reply 'hello'
        3. client send 'info'

        http://help.livereload.com/kb/ecosystem/livereload-protocol
        """
        message = ObjectDict(escape.json_decode(message))
        if message.command == "hello":
            handshake = {}
            handshake["command"] = "hello"
            protocols = message.protocols
            protocols.append("http://livereload.com/protocols/2.x-remote-control")
            handshake["protocols"] = protocols
            handshake["serverName"] = "livereload-tornado"
            self.send_message(handshake)

        if message.command == "info" and "url" in message:
            logging.info("Browser Connected: %s" % message.url)
            LiveReloadHandler.waiters.add(self)
            if not LiveReloadHandler._last_reload_time:
                if os.path.exists("Guardfile"):
                    logging.info("Reading Guardfile")
                    execfile("Guardfile")
                else:
                    logging.info("No Guardfile")
                    Task.add(os.getcwd())

                LiveReloadHandler._last_reload_time = time.time()
                logging.info("Start watching changes")
                ioloop.PeriodicCallback(self.watch_tasks, 800).start()
コード例 #2
0
ファイル: app.py プロジェクト: hqman/python-livereload
    def on_message(self, message):
        """Handshake with livereload.js

        1. client send 'hello'
        2. server reply 'hello'
        3. client send 'info'

        http://help.livereload.com/kb/ecosystem/livereload-protocol
        """
        message = ObjectDict(escape.json_decode(message))
        if message.command == 'hello':
            handshake = {}
            handshake['command'] = 'hello'
            protocols = message.protocols
            protocols.append(
                'http://livereload.com/protocols/2.x-remote-control'
            )
            handshake['protocols'] = protocols
            handshake['serverName'] = 'livereload-tornado'
            self.send_message(handshake)

        if message.command == 'info' and 'url' in message:
            send_notify('Browser Connected: %s' % message.url)
            LiveReloadHandler.waiters.add(self)
            if not LiveReloadHandler._watch_running:
                try:
                    execfile('Guardfile')
                except:
                    Task.add(os.getcwd())

                LiveReloadHandler._watch_running = True
                logging.info('Start watching changes')
                tornado.ioloop.PeriodicCallback(self.watch_tasks, 500).start()
コード例 #3
0
ファイル: server.py プロジェクト: cwood/python-livereload
    def on_message(self, message):
        """Handshake with livereload.js

        1. client send 'hello'
        2. server reply 'hello'
        3. client send 'info'

        http://help.livereload.com/kb/ecosystem/livereload-protocol
        """
        message = ObjectDict(escape.json_decode(message))
        if message.command == 'hello':
            handshake = {}
            handshake['command'] = 'hello'
            protocols = message.protocols
            protocols.append(
                'http://livereload.com/protocols/2.x-remote-control'
            )
            handshake['protocols'] = protocols
            handshake['serverName'] = 'livereload-tornado'
            self.send_message(handshake)

        if message.command == 'info' and 'url' in message:
            logging.info('Browser Connected: %s' % message.url)
            LiveReloadHandler.waiters.add(self)
            if not LiveReloadHandler._last_reload_time:
                if os.path.exists('Guardfile'):
                    logging.info('Reading Guardfile')
                    execfile('Guardfile')
                else:
                    logging.info('No Guardfile')
                    Task.add(os.getcwd())

                LiveReloadHandler._last_reload_time = time.time()
                logging.info('Start watching changes')
                ioloop.PeriodicCallback(self.watch_tasks, 800).start()
コード例 #4
0
    def watch_tasks(self):
        changes = Task.watch()
        if not changes:
            return
        if time.time() - self._last_reload_time < 3:
            # if you changed lot of files in one time
            # it will refresh too many times
            logging.info('ignore this reload action')
            return

        logging.info('Reload %s waiters', len(self.waiters))

        msg = {
            'command': 'reload',
            'path': '*',
            'liveCSS': True
        }

        self._last_reload_time = time.time()
        for waiter in LiveReloadHandler.waiters:
            try:
                waiter.write_message(msg)
            except:
                logging.error('Error sending message', exc_info=True)
                LiveReloadHandler.waiters.remove(waiter)
コード例 #5
0
ファイル: server.py プロジェクト: cwood/python-livereload
    def watch_tasks(self):
        changes = Task.watch()

        if not changes:
            return
        if time.time() - self._last_reload_time < 3:
            # if you changed lot of files in one time
            # it will refresh too many times
            logging.info('ignore this reload action')
            return

        post_funcs = Task.tasks.get('post')
        if post_funcs:
            [func() for func in post_funcs if callable(func)]

        Task.current_position = 0

        logging.info('Reload %s waiters', len(self.waiters))

        msg = {
            'command': 'reload',
            'path': Task.last_modified or '*',
            'liveCSS': True
        }


        self._last_reload_time = time.time()
        for waiter in LiveReloadHandler.waiters:
            try:
                waiter.write_message(msg)
            except:
                logging.error('Error sending message', exc_info=True)
                LiveReloadHandler.waiters.remove(waiter)
コード例 #6
0
ファイル: app.py プロジェクト: hqman/python-livereload
def main():
    if len(sys.argv) > 1:
        #: command-line tools like Makefile
        execfile('Guardfile')
        for cmd in sys.argv[1:]:
            print(cmd)
            exec('%s()' % cmd)
        return

    #: option config is not available
    #: but this enables pretty colorful logging
    tornado.options.parse_command_line()
    app = tornado.web.Application(handlers=handlers)
    app.listen(35729)
    #: task watch initialize
    Task.watch()
    print('Start service at  127.0.0.1:35729')
    tornado.ioloop.IOLoop.instance().start()
コード例 #7
0
    def watch_tasks(self):
        changes = Task.watch()
        if not changes:
            return

        logging.info("Reload %s waiters" "\nChanged %s" % (len(LiveReloadHandler.waiters), changes))
        msg = {"command": "reload", "path": "*", "liveCSS": True}
        for waiter in LiveReloadHandler.waiters:
            try:
                waiter.write_message(msg)
            except:
                logging.error("Error sending message", exc_info=True)
                LiveReloadHandler.waiters.remove(waiter)
コード例 #8
0
ファイル: app.py プロジェクト: hqman/python-livereload
    def watch_tasks(self):

        changes = Task.watch()
        if changes:
            send_notify(
                'Reload %s waiters'
                '\nChanged %s'
                % (len(LiveReloadHandler.waiters), changes)
            )
            msg = {
                'command': 'reload',
                'path': '*',
                'liveCSS': True
            }
            for waiter in LiveReloadHandler.waiters:
                try:
                    waiter.write_message(msg)
                except:
                    logging.error('Error sending message', exc_info=True)
                    LiveReloadHandler.waiters.remove(waiter)
コード例 #9
0
ファイル: server.py プロジェクト: echan85/python-livereload
    def watch_tasks(self):
        changes = Task.watch()
        if not changes:
            return
        if time.time() - self._last_reload_time < 3:
            # if you changed lot of files in one time
            # it will refresh too many times
            logging.info("ignore this reload action")
            return

        logging.info("Reload %s waiters", len(self.waiters))

        msg = {"command": "reload", "path": "*", "liveCSS": True}

        self._last_reload_time = time.time()
        for waiter in LiveReloadHandler.waiters:
            try:
                waiter.write_message(msg)
            except:
                logging.error("Error sending message", exc_info=True)
                LiveReloadHandler.waiters.remove(waiter)
コード例 #10
0
ファイル: server.py プロジェクト: miracle2k/python-livereload
 def poll_tasks(self):
     changes = Task.watch()
     if not changes:
         return
     self.watch_tasks()
コード例 #11
0
#!/usr/bin/env python
from livereload.task import Task
 
Task.add('*.html')
コード例 #12
0
 def poll_tasks(self):
     changes = Task.watch()
     if not changes:
         return
     self.watch_tasks()
コード例 #13
0
#!/usr/bin/env python
from livereload.task import Task

files = [
    '*.css',
    '*.less',
    '*.coffee',
    '*.js',
    '*.java',
    '*.scala.html',
    'conf/application.conf',
    'conf/routes',
    'project/Build.scala',
    'project/plugins.sbt',
    'project/build.properties',
]

for file in files:
    Task.add(file)
コード例 #14
0
#!/usr/bin/env python
from livereload.task import Task
from livereload.compiler import shell

# You may have a different path, e.g. _source/
Task.add('source/', shell('make html'))

コード例 #15
0
ファイル: guardfile.py プロジェクト: kenshin6x/thinbox
#!/usr/bin/env python
from livereload.task import Task

Task.add('static')
Task.add('templates')
コード例 #16
0
ファイル: reload.py プロジェクト: bopopescu/analytics-1
#!/usr/bin/env python
from livereload.task import Task

Task.add('static/css/*.css')
Task.add('*.py')
Task.add('static/css/third_party/*.css')
Task.add('static/js/third_party/*.js')
Task.add('static/js/*.js')
Task.add('templates/*.html')
Task.add('templates/webpagetest/*.html')
Task.add('templates/gae-stats/*.html')

コード例 #17
0
ファイル: reload.py プロジェクト: Khan/analytics
#!/usr/bin/env python
from livereload.task import Task

Task.add('static/css/*.css')
Task.add('*.py')
Task.add('static/css/third_party/*.css')
Task.add('static/js/third_party/*.js')
Task.add('static/js/*.js')
Task.add('templates/*.html')
Task.add('templates/gae-stats/*.html')