Codebase list python-livereload / 3722101
Update upstream source from tag 'upstream/2.5.1' Update to upstream version '2.5.1' with Debian dir 3938ab6b0707d793925852c772102cef08256e40 Antonio Terceiro 6 years ago
15 changed file(s) with 137 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
1616
1717 pip-log.txt
1818
19 .idea
1920 .coverage
2021 .tox
2122 .env/
11 =========
22
33 The full list of changes between each Python LiveReload release.
4
5 Version 2.5.1
6 -------------
7
8 Release on Jan 7, 2017
9
10 Happy New Year.
11
12 1. Fix Content-Type detection
13 2. Ensure current version of pyinotify is installed before using
14
15 Version 2.5.0
16 -------------
17
18 Released on Nov 16, 2016
19
20 1. wait parameter can be float via Todd Wolfson
21 2. Option to disable liveCSS via Yunchi Luo
22 3. Django management command via Marc-Stefan Cassola
23
24 Version 2.4.1
25 -------------
26
27 Released on Jan 19, 2016
28
29 1. Allow other hostname with JS script location.hostname
30 2. Expose delay parameter in command line tool
31 3. Server.watch accept ignore parameter
432
533 Version 2.4.0
634 -------------
125153 + Static Server support index
126154 + Dynamic watch directory changes
127155
128 .. _ver0.6:
129
130156 Version 0.6
131157 ------------
132158 Release on Jun 18th, 2012
133159
134160 + Add static server, 127.0.0.1:35729
135
136 .. _ver0.5:
137161
138162 Version 0.5
139163 -----------
141165
142166 + support for python3
143167
144 .. _ver0.4:
145
146168 Version 0.4
147169 -----------
148170 Release on May 8th, 2012
149171
150172 + bugfix for notify (sorry)
151
152 .. _ver0.3:
153173
154174 Version 0.3
155175 -----------
0 Copyright (c) 2012-2013, Hsiaoming Yang <me@lepture.com>
0 Copyright (c) 2012-2015, Hsiaoming Yang <me@lepture.com>
11
22 Redistribution and use in source and binary forms, with or without
33 modification, are permitted provided that the following conditions
22
33 This is a brand new LiveReload in version 2.0.0.
44
5 .. image:: https://pypip.in/d/livereload/badge.png
5 .. image:: https://img.shields.io/pypi/dm/livereload.svg
66 :target: https://pypi.python.org/pypi/livereload
77 :alt: Downloads
8 .. image:: https://pypip.in/v/livereload/badge.png
8 .. image:: https://img.shields.io/pypi/v/livereload.svg
99 :target: https://pypi.python.org/pypi/livereload
1010 :alt: Version
1111
3131 By default, it will listen to port 35729, the common port for `LiveReload browser extensions`_. ::
3232
3333 $ livereload --help
34 usage: livereload [-h] [-p PORT] [directory]
34 usage: livereload [-h] [-p PORT] [-w WAIT] [directory]
3535
3636 Start a `livereload` server
3737
4141 optional arguments:
4242 -h, --help show this help message and exit
4343 -p PORT, --port PORT Port to run `livereload` server on
44 -w WAIT, --wait WAIT Time delay before reloading
4445
4546 .. _`livereload browser extensions`: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-
4647
155156 Django
156157 ~~~~~~
157158
158 Here is a little hint on Django. Change your ``manage.py`` file to:
159
160 .. code:: python
161
162 #!/usr/bin/env python
163 import os
164 import sys
165
166 if __name__ == "__main__":
167 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hello.settings")
168
169 from django.core.management import execute_from_command_line
170
171 if 'livereload' in sys.argv:
172 from django.core.wsgi import get_wsgi_application
173 from livereload import Server
174 application = get_wsgi_application()
175 server = Server(application)
176
177 # Add your watch
178 # server.watch('path/to/file', 'your command')
179 server.serve()
180 else:
181 execute_from_command_line(sys.argv)
182
183 When you execute ``./manage.py livereload``, it will start a livereload server.
184
159 For Django there is a management command included.
160
161 To use simply
162
163 - add ``'livereload'`` to your ``INSTALLED_APPS`` and
164 - then run ``./manage.py livereload``.
165
166 For available options like host and ports please refer to ``./manage.py livereload -h``.
167
168 To automagically serve static files like the native ``runserver`` command you have to use `dj-static <https://github.com/kennethreitz/dj-static>`_. (follow the simple instructions there).
185169
186170 Flask
187171 ~~~~~
192176
193177 # app is a Flask object
194178 app = create_app()
179
180 # remember to use DEBUG mode for templates auto reload
181 # https://github.com/lepture/python-livereload/issues/144
182 app.debug = True
195183
196184 server = Server(app.wsgi_app)
197185 # server.watch
3838 clean:
3939 -rm -rf $(BUILDDIR)/*
4040
41 html:
41 html: _themes/.git
4242 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
4343 @echo
4444 @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
148148 $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
149149 @echo "Testing of doctests in the sources finished, look at the " \
150150 "results in $(BUILDDIR)/doctest/output.txt."
151
152
153 _themes/.git:
154 git submodule update --init
9999 # documentation.
100100 html_theme_options = {
101101 'index_logo': None,
102 'github_fork': 'lepture/python-livereload',
102103 }
103104
104105 # Add any paths that contain custom themes here, relative to this directory.
33
44 A python version of livereload.
55
6 :copyright: (c) 2013 by Hsiaoming Yang
6 :copyright: (c) 2013 - 2017 by Hsiaoming Yang
7 :license: BSD, see LICENSE for more details.
78 """
89
9 __version__ = '2.4.0'
10 __version__ = '2.5.1'
1011 __author__ = 'Hsiaoming Yang <me@lepture.com>'
1112 __homepage__ = 'https://github.com/lepture/python-livereload'
1213
2121 default='.',
2222 nargs='?'
2323 )
24 parser.add_argument(
25 '-w', '--wait',
26 help='Time delay in seconds before reloading',
27 type=float,
28 default=0.0
29 )
2430
2531
2632 def main(argv=None):
2834
2935 # Create a new application
3036 server = Server()
31 server.watcher.watch(args.directory)
37 server.watcher.watch(args.directory, delay=args.wait)
3238 server.serve(host=args.host, port=args.port, root=args.directory)
55 HTTP and WebSocket handlers for livereload.
66
77 :copyright: (c) 2013 - 2015 by Hsiaoming Yang
8 :license: BSD, see LICENSE for more details.
89 """
910
1011 import os
2324 class LiveReloadHandler(WebSocketHandler):
2425 waiters = set()
2526 watcher = None
27 live_css = None
2628 _last_reload_time = None
2729
2830 def allow_draft76(self):
9698 msg = {
9799 'command': 'reload',
98100 'path': path,
99 'liveCSS': True,
101 'liveCSS': cls.live_css,
100102 'liveImg': True,
101103 }
102104
0 import os
1 import re
2 from django.core.management.base import BaseCommand, CommandError
3 from django.core.management.commands.runserver import naiveip_re
4 from django.core.servers.basehttp import get_internal_wsgi_application
5 from livereload import Server
6
7
8 class Command(BaseCommand):
9 help = 'Runs the development server with livereload enabled.'
10
11 def add_arguments(self, parser):
12 parser.add_argument('addrport',
13 nargs='?',
14 default='127.0.0.1:8000',
15 help='host and optional port the django server should listen on (default: 127.0.0.1:8000)')
16 parser.add_argument('-l', '--liveport',
17 type=int,
18 default=35729,
19 help='port the livereload server should listen on (default: 35729)')
20
21 def handle(self, *args, **options):
22 m = re.match(naiveip_re, options['addrport'])
23 if m is None:
24 raise CommandError('"%s" is not a valid port number '
25 'or address:port pair.' % options['addrport'])
26 addr, _ipv4, _ipv6, _fqdn, port = m.groups()
27 if not port.isdigit():
28 raise CommandError("%r is not a valid port number." % port)
29
30 if addr:
31 if _ipv6:
32 raise CommandError('IPv6 addresses are currently not supported.')
33
34
35 application = get_internal_wsgi_application()
36 server = Server(application)
37
38 for file in os.listdir('.'):
39 if file[0] != '.' and file[:2] != '__' and os.path.isdir(file):
40 server.watch(file)
41
42 server.serve(host=addr, port=port, liveport=options['liveport'])
44
55 WSGI app server for livereload.
66
7 :copyright: (c) 2013 by Hsiaoming Yang
7 :copyright: (c) 2013 - 2015 by Hsiaoming Yang
8 :license: BSD, see LICENSE for more details.
89 """
910
1011 import os
129130
130131 if status_code != 304:
131132 if "content-type" not in header_set:
132 headers.append(("Content-Type", "text/html; charset=UTF-8"))
133 headers.append(("Content-Type", "application/octet-stream; charset=UTF-8"))
133134 if "content-length" not in header_set:
134135 headers.append(("Content-Length", str(len(body))))
135136
141142 )
142143 header_obj = httputil.HTTPHeaders()
143144 for key, value in headers:
144 if key == 'Content-Length':
145 if key.lower() == 'content-length':
145146 value = str(len(body))
146147 header_obj.add(key, value)
147148 request.connection.write_headers(start_line, header_obj, chunk=body)
172173 watcher = watcher_cls()
173174 self.watcher = watcher
174175
175 def watch(self, filepath, func=None, delay=None):
176 def watch(self, filepath, func=None, delay=None, ignore=None):
176177 """Add the given filepath for watcher list.
177178
178179 Once you have intialized a server, watch file changes before
192193 :param delay: Delay sending the reload message. Use 'forever' to
193194 not send it. This is useful to compile sass files to
194195 css, but reload on changed css files then only.
196 :param ignore: A function return True to ignore a certain pattern of
197 filepath.
195198 """
196199 if isinstance(func, string_types):
197200 func = shell(func)
198201
199 self.watcher.watch(filepath, func, delay)
200
201 def application(self, port, host, liveport=None, debug=None):
202 self.watcher.watch(filepath, func, delay, ignore=ignore)
203
204 def application(self, port, host, liveport=None, debug=None, live_css=True):
202205 LiveReloadHandler.watcher = self.watcher
206 LiveReloadHandler.live_css = live_css
203207 if liveport is None:
204208 liveport = port
205209 if debug is None and self.app:
211215 (r'/livereload.js', LiveReloadJSHandler)
212216 ]
213217
218 # The livereload.js snippet.
219 # Uses JavaScript to dynamically inject the client's hostname.
220 # This allows for serving on 0.0.0.0.
214221 live_script = escape.utf8((
215 '<script src="http://{host}:{port}/livereload.js"></script>'
216 ).format(host=host, port=liveport))
222 '<script type="text/javascript">'
223 'document.write("<script src=''http://"'
224 ' + window.location.hostname + ":{port}/livereload.js''>'
225 ' </"+"script>");'
226 '</script>'
227 ).format(port=liveport))
217228
218229 web_handlers = self.get_web_handlers(live_script)
219230
250261 ]
251262
252263 def serve(self, port=5500, liveport=None, host=None, root=None, debug=None,
253 open_url=False, restart_delay=2, open_url_delay=None):
264 open_url=False, restart_delay=2, open_url_delay=None, live_css=True):
254265 """Start serve the server with the given port.
255266
256267 :param port: serve on this port, default is 5500
261272 via Tornado (and causes polling). Defaults to True when
262273 ``self.app`` is set, otherwise False.
263274 :param open_url_delay: open webbrowser after the delay seconds
275 :param live_css: whether to use live css or force reload on css. Defaults to True
264276 """
265277 host = host or '127.0.0.1'
266278 if root is not None:
269281 self._setup_logging()
270282 logger.info('Serving on http://%s:%s' % (host, port))
271283
272 self.application(port, host, liveport=liveport, debug=debug)
284 self.application(port, host, liveport=liveport, debug=debug, live_css=live_css)
273285
274286 # Async open web browser after 5 sec timeout
275287 if open_url or open_url_delay:
55 A file watch management for LiveReload Server.
66
77 :copyright: (c) 2013 - 2015 by Hsiaoming Yang
8 :license: BSD, see LICENSE for more details.
89 """
910
1011 import os
7071 func = item['func']
7172 func and func()
7273 delay = item['delay']
73 if delay and isinstance(delay, int):
74 if delay and isinstance(delay, float):
7475 delays.add(delay)
7576
7677 if delays:
164165
165166
166167 def get_watcher_class():
167 if pyinotify is None:
168 if pyinotify is None or not hasattr(pyinotify, 'TornadoAsyncNotifier'):
168169 return Watcher
169170 return INotifyWatcher
2222 author='Hsiaoming Yang',
2323 author_email='me@lepture.com',
2424 url='https://github.com/lepture/python-livereload',
25 packages=['livereload'],
25 packages=['livereload', 'livereload.management.commands'],
2626 description='Python LiveReload is an awesome tool for web developers',
2727 long_description=fread('README.rst'),
2828 entry_points={