@task
@cmdopts([('background', 'b', 'Background mode'), ('theme-dirs=', '-td', 'The themes dir containing all themes (defaults to None)'), ('themes=', '-t', 'The themes to add sass watchers for (defaults to None)')])
@timed
def watch_assets(options):
 if tasks.environment.dry_run:
  return
 themes = get_parsed_option(options, 'themes')
 theme_dirs = get_parsed_option(options, 'theme_dirs', [])
 if ((not theme_dirs) and themes):
  raise ValueError('theme-dirs must be provided for watching theme sass.')
 else:
  theme_dirs = [path(_dir) for _dir in theme_dirs]
 sass_directories = get_watcher_dirs(theme_dirs, themes)
 observer = PollingObserver()
 CoffeeScriptWatcher().register(observer)
 SassWatcher().register(observer, sass_directories)
 XModuleSassWatcher().register(observer, ['common/lib/xmodule/'])
 XModuleAssetsWatcher().register(observer)
 print('Starting asset watcher...')
 observer.start()
 if (not getattr(options, 'background', False)):
  try:
   while True:
    observer.join(2)
  except KeyboardInterrupt:
   observer.stop()
  print('\nStopped asset watcher.')

@ task @ cmdopts ( [ ( 'background' , 'b' , 'Background mode' ) , ( 'theme-dirs=' , '-td' , 'The themes dir containing all themes (defaults to None)' ) , ( 'themes=' , '-t' , 'The themes to add sass watchers for (defaults to None)' ) ] ) @ timed def watch_assets ( options ) : if tasks . environment . dry_run : return themes = get_parsed_option ( options , 'themes' ) theme_dirs = get_parsed_option ( options , 'theme_dirs' , [ ] ) if ( ( not theme_dirs ) and themes ) : raise ValueError ( 'theme-dirs must be provided for watching theme sass.' ) else : theme_dirs = [ path ( _dir ) for _dir in theme_dirs ] sass_directories = get_watcher_dirs ( theme_dirs , themes ) observer = PollingObserver ( ) CoffeeScriptWatcher ( ) . register ( observer ) SassWatcher ( ) . register ( observer , sass_directories ) XModuleSassWatcher ( ) . register ( observer , [ 'common/lib/xmodule/' ] ) XModuleAssetsWatcher ( ) . register ( observer ) print ( 'Starting asset watcher...' ) observer . start ( ) if ( not getattr ( options , 'background' , False ) ) : try : while True : observer . join ( 2 ) except KeyboardInterrupt : observer . stop ( ) print ( '\nStopped asset watcher.' )
watch for changes to asset files .