<s> """<STR_LIT>""" <EOL> from fabric . api import run <EOL> from fabric . api import sudo <EOL> from fabric . context_managers import cd <EOL> from fabtools . utils import run_as_root <EOL> def clone ( remote_url , path = None , use_sudo = False , user = None ) : <EOL> """<STR_LIT>""" <EOL> cmd = '<STR_LIT>' % remote_url <EOL> if path is not None : <EOL> cmd = cmd + '<STR_LIT>' % path <EOL> if use_sudo and user is None : <EOL> run_as_root ( cmd ) <EOL> elif use_sudo : <EOL> sudo ( cmd , user = user ) <EOL> else : <EOL> run ( cmd ) <EOL> def add_remote ( path , name , remote_url , use_sudo = False , user = None , fetch = True ) : <EOL> """<STR_LIT>""" <EOL> if path is None : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if fetch : <EOL> cmd = '<STR_LIT>' % ( name , remote_url ) <EOL> else : <EOL> cmd = '<STR_LIT>' % ( name , remote_url ) <EOL> with cd ( path ) : <EOL> if use_sudo and user is None : <EOL> run_as_root ( cmd ) <EOL> elif use_sudo : <EOL> sudo ( cmd , user = user ) <EOL> else : <EOL> run ( cmd ) <EOL> def fetch ( path , use_sudo = False , user = None , remote = None ) : <EOL> """<STR_LIT>""" <EOL> if path is None : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if remote is not None : <EOL> cmd = '<STR_LIT>' % remote <EOL> else : <EOL> cmd = '<STR_LIT>' <EOL> with cd ( path ) : <EOL> if use_sudo and user is None : <EOL> run_as_root ( cmd ) <EOL> elif use_sudo : <EOL> sudo ( cmd , user = user ) <EOL> else : <EOL> run ( cmd ) <EOL> def pull ( path , use_sudo = False , user = None , force = False ) : <EOL> """<STR_LIT>""" <EOL> if path is None : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> options = [ ] <EOL> if force : <EOL> options . append ( '<STR_LIT>' ) <EOL> options = '<STR_LIT:U+0020>' . join ( options ) <EOL> cmd = '<STR_LIT>' % options <EOL> with cd ( path ) : <EOL> if use_sudo and user is None : <EOL> run_as_root ( cmd ) <EOL> elif use_sudo : <EOL> sudo ( cmd , user = user ) <EOL> else : <EOL> run ( cmd ) <EOL> def checkout ( path , branch = "<STR_LIT>" , use_sudo = False , user = None , force = False ) : <EOL> """<STR_LIT>""" <EOL> if path is None : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> options = [ ] <EOL> if force : <EOL> options . append ( '<STR_LIT>' ) <EOL> options = '<STR_LIT:U+0020>' . join ( options ) <EOL> cmd = '<STR_LIT>' % ( branch , options ) <EOL> with cd ( path ) : <EOL> if use_sudo and user is None : <EOL> run_as_root ( cmd ) <EOL> elif use_sudo : <EOL> sudo ( cmd , user = user ) <EOL> else : <EOL> run ( cmd ) </s>
