<s> from src . platform . jboss . interfaces import JINTERFACES <EOL> from src . platform . jboss . authenticate import checkAuth <EOL> from src . module . deploy_utils import parse_war_path <EOL> from os . path import abspath <EOL> from log import LOG <EOL> import utility <EOL> versions = [ "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' ] <EOL> title = JINTERFACES . MM <EOL> def deploy ( fingerengine , fingerprint ) : <EOL> """<STR_LIT>""" <EOL> war_file = abspath ( fingerengine . options . deploy ) <EOL> war_name = parse_war_path ( war_file ) <EOL> war_raw = parse_war_path ( war_file , True ) <EOL> utility . Msg ( "<STR_LIT>" . format ( war_file ) ) <EOL> base = "<STR_LIT>" . format ( fingerengine . options . ip , <EOL> fingerprint . port ) <EOL> add_content = "<STR_LIT>" <EOL> association = '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' <EOL> deploy = '<STR_LIT>' <EOL> headers = { "<STR_LIT:Content-Type>" : "<STR_LIT:application/json>" } <EOL> try : <EOL> fwar = { war_file : open ( war_file , "<STR_LIT:r>" ) . read ( ) } <EOL> except : <EOL> utility . Msg ( "<STR_LIT>" % war_file , LOG . ERROR ) <EOL> return <EOL> response = utility . requests_post ( base + add_content , files = fwar ) <EOL> if response . status_code == <NUM_LIT> : <EOL> response = redo_auth ( fingerengine , fingerprint , base + add_content , <EOL> files = fwar ) <EOL> if response . status_code != <NUM_LIT:200> : <EOL> utility . Msg ( "<STR_LIT>" % response . status_code , LOG . ERROR ) <EOL> return <EOL> if response . json ( ) [ '<STR_LIT>' ] != '<STR_LIT:success>' : <EOL> utility . Msg ( "<STR_LIT>" , LOG . ERROR ) <EOL> utility . Msg ( response . json ( ) , LOG . DEBUG ) <EOL> return <EOL> BYTES_VALUE = response . json ( ) [ '<STR_LIT:result>' ] [ '<STR_LIT>' ] <EOL> response = utility . requests_post ( base , <EOL> data = association . format ( war_name , BYTES_VALUE , war_raw ) , <EOL> headers = headers ) <EOL> if response . status_code == <NUM_LIT> : <EOL> response = redo_auth ( fingerengine , fingerprint , base , <EOL> data = association . format ( war_name , BYTES_VALUE , war_raw ) , <EOL> headers = headers ) <EOL> if response . status_code != <NUM_LIT:200> : <EOL> utility . Msg ( "<STR_LIT>" % response . status_code , LOG . ERROR ) <EOL> utility . Msg ( response . content , LOG . DEBUG ) <EOL> return <EOL> deploy = deploy . format ( war_name ) <EOL> response = utility . requests_post ( base , data = deploy , headers = headers ) <EOL> if response . status_code == <NUM_LIT> : <EOL> response = redo_auth ( fingerengine , fingerprint , base , data = deploy , <EOL> headers = headers ) <EOL> if response . status_code != <NUM_LIT:200> : <EOL> utility . Msg ( "<STR_LIT>" % response . status_code , LOG . ERROR ) <EOL> utility . Msg ( response . content , LOG . DEBUG ) <EOL> return <EOL> utility . Msg ( "<STR_LIT>" % ( war_file , fingerengine . options . ip ) , <EOL> LOG . SUCCESS ) <EOL> def redo_auth ( fingerengine , fingerprint , url , ** args ) : <EOL> """<STR_LIT>""" <EOL> response = None <EOL> utility . Msg ( "<STR_LIT>" % <EOL> ( fingerengine . options . ip , fingerprint . port ) , LOG . DEBUG ) <EOL> cookies = checkAuth ( fingerengine . options . ip , fingerprint . port , <EOL> fingerprint . title , fingerprint . version ) <EOL> if cookies : <EOL> response = utility . requests_post ( url , auth = cookies [ <NUM_LIT:1> ] , ** args ) <EOL> else : <EOL> utility . Msg ( "<STR_LIT>" % <EOL> ( fingerengine . options . ip , fingerprint . port ) , LOG . ERROR ) <EOL> return response </s>
