<s> import sys <EOL> import os <EOL> import shutil <EOL> import fnmatch <EOL> import atexit <EOL> from openmdao . devtools . utils import put_dir , repo_top , fabric_cleanup <EOL> def _push_release ( release_dir , destination , obj , py = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> files = os . listdir ( release_dir ) <EOL> f = fnmatch . filter ( files , '<STR_LIT>' ) <EOL> try : <EOL> f . remove ( '<STR_LIT>' ) <EOL> except : <EOL> pass <EOL> if len ( f ) < <NUM_LIT:1> : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> elif len ( f ) > <NUM_LIT:1> : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> script = f [ <NUM_LIT:0> ] <EOL> version = os . path . splitext ( script ) [ <NUM_LIT:0> ] . split ( '<STR_LIT:->' , <NUM_LIT:2> ) [ <NUM_LIT:2> ] <EOL> obj . run ( '<STR_LIT>' % ( destination , version ) ) <EOL> obj . run ( '<STR_LIT>' % ( destination , version ) ) <EOL> for f in os . listdir ( release_dir ) : <EOL> if ( f . endswith ( '<STR_LIT>' ) and f != '<STR_LIT>' ) or f . endswith ( '<STR_LIT>' ) : <EOL> obj . put ( os . path . join ( release_dir , f ) , '<STR_LIT>' % ( destination , f ) ) <EOL> obj . run ( '<STR_LIT>' % ( destination , f ) ) <EOL> obj . put ( os . path . join ( release_dir , '<STR_LIT>' % version ) , <EOL> '<STR_LIT>' % ( destination , version , version ) ) <EOL> obj . run ( '<STR_LIT>' % ( destination , version , version ) ) <EOL> obj . put_dir ( os . path . join ( release_dir , '<STR_LIT>' ) , <EOL> '<STR_LIT>' % ( destination , version ) ) <EOL> obj . put ( os . path . join ( repo_top ( ) , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' % ( destination , version ) ) <EOL> obj . put ( os . path . join ( repo_top ( ) , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' % destination ) <EOL> obj . put ( os . path . join ( repo_top ( ) , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' % destination ) <EOL> cdir = os . getcwd ( ) <EOL> dpath = '<STR_LIT>' % ( destination , version ) <EOL> obj . run ( '<STR_LIT>' % ( dpath , py ) ) <EOL> os . chdir ( cdir ) <EOL> dpath = '<STR_LIT>' % destination <EOL> obj . run ( '<STR_LIT>' % ( dpath , py ) ) <EOL> os . chdir ( cdir ) <EOL> obj . run ( '<STR_LIT>' % destination ) <EOL> obj . run ( '<STR_LIT>' % ( version , destination ) ) <EOL> os . chdir ( cdir ) <EOL> dpath = '<STR_LIT>' % destination <EOL> obj . run ( '<STR_LIT>' % ( dpath , py ) ) <EOL> def _setup_local_release_dir ( dpath ) : <EOL> dn = os . path . dirname <EOL> topdir = dn ( dn ( dn ( sys . executable ) ) ) <EOL> os . makedirs ( os . path . join ( dpath , '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> os . makedirs ( os . path . join ( dpath , '<STR_LIT>' ) ) <EOL> shutil . copy ( os . path . join ( topdir , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> dpath ) <EOL> class _CommObj ( object ) : <EOL> pass <EOL> def push_release ( parser , options ) : <EOL> from fabric . api import run , local , put , settings <EOL> atexit . register ( fabric_cleanup , True ) <EOL> comm_obj = _CommObj ( ) <EOL> if options . releasedir is None : <EOL> print "<STR_LIT>" <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> destdir = options . destdir <EOL> if destdir is None : <EOL> if os . path . basename ( options . releasedir ) . startswith ( '<STR_LIT>' ) : <EOL> destdir = os . path . join ( os . path . dirname ( options . releasedir ) , <EOL> "<STR_LIT>" % <EOL> os . path . basename ( options . releasedir ) . split ( '<STR_LIT:_>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> print "<STR_LIT>" <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> if os . path . isdir ( destdir ) : <EOL> print "<STR_LIT>" % destdir <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> if not os . path . isdir ( options . releasedir ) : <EOL> print "<STR_LIT>" % options . releasedir <EOL> sys . exit ( - <NUM_LIT:1> ) <EOL> if not ( '<STR_LIT:@>' in destdir or '<STR_LIT::>' in destdir ) : <EOL> if not os . path . isdir ( destdir ) : <EOL> _setup_local_release_dir ( destdir ) <EOL> comm_obj . put = shutil . copy <EOL> comm_obj . put_dir = shutil . copytree <EOL> comm_obj . run = local <EOL> _push_release ( options . releasedir , destdir , comm_obj , <EOL> py = options . py ) <EOL> else : <EOL> if options . py == '<STR_LIT>' : <EOL> options . py = '<STR_LIT>' <EOL> comm_obj . put = put <EOL> comm_obj . put_dir = put_dir <EOL> comm_obj . run = run <EOL> destparts = destdir . split ( '<STR_LIT::>' , <NUM_LIT:1> ) <EOL> if len ( destparts ) > <NUM_LIT:1> : <EOL> home = destparts [ <NUM_LIT:1> ] <EOL> else : <EOL> home = '<STR_LIT>' <EOL> with settings ( host_string = destparts [ <NUM_LIT:0> ] ) : <EOL> _push_release ( options . releasedir , home , comm_obj , <EOL> py = options . py ) </s>
