Skip to content

Commit

Permalink
using grablib rather than vanillia urllib
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Jan 7, 2017
1 parent f2be4d3 commit bdb3e64
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 28 deletions.
1 change: 1 addition & 0 deletions .grablib.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a451e4d39b8d7ef62d380d07742b782f https://raw.githubusercontent.com/livereload/livereload-js/v2.2.1/dist/livereload.js livereload.js
3 changes: 3 additions & 0 deletions grablib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
download_root: 'aiohttp_devtools/runserver'
download:
'GITHUB/livereload/livereload-js/v2.2.1/dist/livereload.js': '/'
32 changes: 4 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,17 @@
from importlib.machinery import SourceFileLoader
from pathlib import Path
from setuptools import setup
from grablib import Grab

THIS_DIR = Path(__file__).resolve().parent
long_description = THIS_DIR.joinpath('README.rst').read_text()

# avoid loading the package before requirements are installed:
version = SourceFileLoader('version', 'aiohttp_devtools/version.py').load_module()


def check_livereload_js():
import hashlib
live_reload_221_hash = 'a451e4d39b8d7ef62d380d07742b782f'
live_reload_221_url = 'https://raw.githubusercontent.com/livereload/livereload-js/v2.2.1/dist/livereload.js'

path = THIS_DIR.joinpath('aiohttp_devtools/runserver/livereload.js')

def check_path():
with path.open('rb') as fr:
file_hash = hashlib.md5(fr.read()).hexdigest()
return file_hash == live_reload_221_hash

if path.is_file():
if check_path():
return

import urllib.request

print('downloading livereload:\nurl: {}\npath: {}'.format(live_reload_221_url, path))
with urllib.request.urlopen(live_reload_221_url) as r:
with path.open('wb') as fw:
fw.write(r.read())

if not check_path():
raise RuntimeError('checksums do not match for {} after download'.format(path))

check_livereload_js()
# make sure livereload.js exists.
grab = Grab(THIS_DIR / 'grablib.yml')
grab.download()

package = THIS_DIR.joinpath('aiohttp_devtools/start')

Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage==4.3.1
docutils==0.13.1
flake8==3.2.1
grablib==0.3
ghp-import==0.5.4
pycodestyle==2.2.0
pyflakes==1.4.0
Expand Down

0 comments on commit bdb3e64

Please sign in to comment.