<s> from . import base <EOL> from protorpc import messages <EOL> from grow . pods import env <EOL> from grow . pods . storage import storage as storage_lib <EOL> import os <EOL> class Config ( messages . Message ) : <EOL> out_dir = messages . StringField ( <NUM_LIT:1> , default = '<STR_LIT>' ) <EOL> env = messages . MessageField ( env . EnvConfig , <NUM_LIT:2> ) <EOL> keep_control_dir = messages . BooleanField ( <NUM_LIT:3> , default = False ) <EOL> before_deploy = messages . StringField ( <NUM_LIT:4> , repeated = True ) <EOL> after_deploy = messages . StringField ( <NUM_LIT:5> , repeated = True ) <EOL> control_dir = messages . StringField ( <NUM_LIT:6> ) <EOL> class LocalDestination ( base . BaseDestination ) : <EOL> KIND = '<STR_LIT>' <EOL> Config = Config <EOL> storage = storage_lib . FileStorage <EOL> def __str__ ( self ) : <EOL> return os . path . abspath ( os . path . join ( self . out_dir ) ) <EOL> @ property <EOL> def out_dir ( self ) : <EOL> return os . path . expanduser ( self . config . out_dir ) <EOL> def read_file ( self , path ) : <EOL> path = os . path . join ( self . out_dir , path . lstrip ( '<STR_LIT:/>' ) ) <EOL> return self . storage . read ( path ) <EOL> def delete_file ( self , path ) : <EOL> out_path = os . path . join ( self . out_dir , path . lstrip ( '<STR_LIT:/>' ) ) <EOL> self . storage . delete ( out_path ) <EOL> def write_file ( self , path , content ) : <EOL> if isinstance ( content , unicode ) : <EOL> content = content . encode ( '<STR_LIT:utf-8>' ) <EOL> out_path = os . path . join ( self . out_dir , path . lstrip ( '<STR_LIT:/>' ) ) <EOL> self . storage . write ( out_path , content ) <EOL> def prelaunch ( self , dry_run = False ) : <EOL> for command in self . config . before_deploy : <EOL> self . command ( command ) <EOL> super ( LocalDestination , self ) . prelaunch ( dry_run ) <EOL> def postlaunch ( self , dry_run = False ) : <EOL> if self . success : <EOL> for command in self . config . after_deploy : <EOL> self . command ( command ) <EOL> super ( LocalDestination , self ) . postlaunch ( dry_run ) </s>
