#NEWLINE# def __call__( self , loop = None ) : #NEWLINE# #INDENT# 'Watch assets for changes.\n\n        ``loop``\n            A callback, taking no arguments, to be called once every loop\n            iteration. Can be useful to integrate the command with other code.\n            If not specified, the loop wil call ``time.sleep()``.\n        ' #NEWLINE# mtimes = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# try : #NEWLINE# #INDENT# for bundle in self . environment : #NEWLINE# #INDENT# print ( ( 'Bringing up to date: %s' % bundle . output ) ) #NEWLINE# bundle . build ( force = False ) #NEWLINE# #UNINDENT# self . log . info ( ( 'Watching %d bundles for changes...' % len ( self . environment ) ) ) #NEWLINE# while True : #NEWLINE# #INDENT# changed_bundles = self . check_for_changes ( mtimes ) #NEWLINE# built = [ ] #NEWLINE# for bundle in changed_bundles : #NEWLINE# #INDENT# print ( ( 'Building bundle: %s ...' % bundle . output ) , end = ' ' ) #NEWLINE# sys . stdout . flush ( ) #NEWLINE# try : #NEWLINE# #INDENT# bundle . build ( force = True ) #NEWLINE# built . append ( bundle ) #NEWLINE# #UNINDENT# except BuildError as e : #NEWLINE# #INDENT# print ( '' ) #NEWLINE# print ( ( 'Failed: %s' % e ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# print ( 'done' ) #NEWLINE# #UNINDENT# #UNINDENT# if len ( built ) : #NEWLINE# #INDENT# self . event_handlers [ 'post_build' ] ( ) #NEWLINE# #UNINDENT# do_end = ( loop ( ) if loop else time . sleep ( 0.1 ) ) #NEWLINE# if do_end : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except KeyboardInterrupt : #NEWLINE# #INDENT# pass