<s> """<STR_LIT>""" <EOL> import os <EOL> import shutil <EOL> from django . core . management . base import BaseCommand <EOL> from django . conf import settings <EOL> from tethys_apps . helpers import get_installed_tethys_apps <EOL> class Command ( BaseCommand ) : <EOL> """<STR_LIT>""" <EOL> def handle ( self , * args , ** options ) : <EOL> """<STR_LIT>""" <EOL> if not hasattr ( settings , '<STR_LIT>' ) or ( hasattr ( settings , '<STR_LIT>' ) and not settings . TETHYS_WORKSPACES_ROOT ) : <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> exit ( <NUM_LIT:1> ) <EOL> workspaces_root = settings . TETHYS_WORKSPACES_ROOT <EOL> installed_apps = get_installed_tethys_apps ( ) <EOL> print ( '<STR_LIT>' . format ( workspaces_root ) ) <EOL> for app , path in installed_apps . iteritems ( ) : <EOL> workspaces_path = os . path . join ( path , '<STR_LIT>' ) <EOL> workspaces_root_path = os . path . join ( workspaces_root , app ) <EOL> if os . path . isdir ( workspaces_path ) and not os . path . islink ( workspaces_path ) : <EOL> try : <EOL> os . remove ( workspaces_root_path ) <EOL> except OSError : <EOL> try : <EOL> shutil . rmtree ( workspaces_root_path ) <EOL> except OSError : <EOL> pass <EOL> shutil . move ( workspaces_path , workspaces_root_path ) <EOL> if os . path . isdir ( workspaces_root_path ) : <EOL> os . symlink ( workspaces_root_path , workspaces_path ) <EOL> print ( '<STR_LIT>' . format ( app ) ) </s>
