<s> """<STR_LIT>""" <EOL> import os <EOL> import shutil <EOL> import subprocess <EOL> from getpass import getuser <EOL> SRC_DIR = '<STR_LIT>' <EOL> BUILD_DIR = '<STR_LIT>' <EOL> DIST_DIR = '<STR_LIT>' <EOL> def remove_dirs ( ) : <EOL> print '<STR_LIT>' <EOL> print """<STR_LIT>""" <EOL> if os . path . exists ( BUILD_DIR ) : <EOL> cmd = '<STR_LIT>' % ( getuser ( ) , BUILD_DIR ) <EOL> shellcmd ( cmd ) <EOL> shutil . rmtree ( BUILD_DIR ) <EOL> if os . path . exists ( DIST_DIR ) : <EOL> cmd = '<STR_LIT>' % ( getuser ( ) , DIST_DIR ) <EOL> shellcmd ( cmd ) <EOL> shutil . rmtree ( DIST_DIR ) <EOL> def build_dist ( ) : <EOL> print '<STR_LIT>' <EOL> cmd = '<STR_LIT>' <EOL> shellcmd ( cmd ) <EOL> def build_dmg ( ) : <EOL> print '<STR_LIT>' <EOL> pkg = os . listdir ( DIST_DIR ) [ <NUM_LIT:0> ] <EOL> fn , ext = os . path . splitext ( pkg ) <EOL> dmg = fn + '<STR_LIT>' <EOL> srcfolder = os . path . join ( DIST_DIR , pkg ) <EOL> dstfolder = os . path . join ( DIST_DIR , dmg ) <EOL> cmd = '<STR_LIT>' % ( srcfolder , dstfolder ) <EOL> shellcmd ( cmd ) <EOL> def shellcmd ( cmd , verbose = True ) : <EOL> """<STR_LIT>""" <EOL> if verbose : <EOL> print cmd <EOL> try : <EOL> subprocess . check_call ( cmd , shell = True ) <EOL> except subprocess . CalledProcessError , err : <EOL> msg = """<STR_LIT>""" % str ( err ) <EOL> raise Exception ( msg ) <EOL> def build ( ) : <EOL> cwd = os . getcwd ( ) <EOL> os . chdir ( SRC_DIR ) <EOL> remove_dirs ( ) <EOL> build_dist ( ) <EOL> build_dmg ( ) <EOL> os . chdir ( cwd ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> build ( ) </s>
