<s> from __future__ import print_function <EOL> import os <EOL> import hashlib <EOL> import json <EOL> import shutil <EOL> import tempfile <EOL> import sys <EOL> import tarfile <EOL> try : <EOL> from urllib . request import urlretrieve <EOL> except ImportError : <EOL> from urllib import urlretrieve <EOL> import invoke <EOL> NOTEBOOK_VERSION = '<STR_LIT>' <EOL> NOTEBOOK_CHECKSUM = '<STR_LIT>' <EOL> APP_ROOT = os . path . dirname ( __file__ ) <EOL> NPM_BIN = os . path . join ( APP_ROOT , "<STR_LIT>" , "<STR_LIT>" ) <EOL> NOTEBOOK_STATIC_PATH = os . path . join ( APP_ROOT , '<STR_LIT>' % NOTEBOOK_VERSION , '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ invoke . task <EOL> def test ( ) : <EOL> invoke . run ( "<STR_LIT>" ) <EOL> @ invoke . task <EOL> def bower ( ) : <EOL> invoke . run ( <EOL> "<STR_LIT>" . format ( APP_ROOT ) + <EOL> "<STR_LIT>" . format ( NPM_BIN ) + <EOL> "<STR_LIT>" <EOL> ) <EOL> @ invoke . task <EOL> def notebook_static ( ) : <EOL> if os . path . exists ( NOTEBOOK_STATIC_PATH ) : <EOL> return <EOL> fname = '<STR_LIT>' % NOTEBOOK_VERSION <EOL> nb_tgz = os . path . join ( APP_ROOT , fname ) <EOL> nb_url = '<STR_LIT>' + fname <EOL> if not os . path . exists ( nb_tgz ) : <EOL> print ( "<STR_LIT>" % ( nb_url , nb_tgz ) ) <EOL> urlretrieve ( nb_url , nb_tgz ) <EOL> with open ( nb_tgz , '<STR_LIT:rb>' ) as f : <EOL> checksum = hashlib . sha256 ( f . read ( ) ) . hexdigest ( ) <EOL> if checksum != NOTEBOOK_CHECKSUM : <EOL> print ( "<STR_LIT>" % nb_url , file = sys . stderr ) <EOL> print ( "<STR_LIT>" % NOTEBOOK_CHECKSUM , file = sys . stderr ) <EOL> print ( "<STR_LIT>" % checksum , file = sys . stderr ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> invoke . run ( "<STR_LIT>" . format ( nb_tgz ) ) <EOL> @ invoke . task <EOL> def less ( debug = False ) : <EOL> notebook_static ( ) <EOL> if debug : <EOL> extra = "<STR_LIT>" <EOL> else : <EOL> extra = "<STR_LIT>" <EOL> tmpl = ( <EOL> "<STR_LIT>" . format ( APP_ROOT ) + <EOL> "<STR_LIT>" . format ( NPM_BIN ) + <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> args = ( extra , NOTEBOOK_STATIC_PATH ) <EOL> [ <EOL> invoke . run ( tmpl . format ( less_file , * args ) ) <EOL> for less_file in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> ] <EOL> @ invoke . task <EOL> def screenshots ( root = "<STR_LIT>" , dest = "<STR_LIT>" ) : <EOL> dest = os . path . abspath ( dest ) <EOL> script = """<STR_LIT>""" . format ( root = root , dest = dest ) <EOL> tmpdir = tempfile . mkdtemp ( ) <EOL> tmpfile = os . path . join ( tmpdir , "<STR_LIT>" ) <EOL> with open ( tmpfile , "<STR_LIT>" ) as f : <EOL> f . write ( script ) <EOL> invoke . run ( "<STR_LIT>" . format ( script = tmpfile ) ) <EOL> shutil . rmtree ( tmpdir ) </s>
