<s> from src . platform . glassfish . authenticate import checkAuth <EOL> from src . platform . glassfish . interfaces import GINTERFACES <EOL> from src . module . deploy_utils import parse_war_path <EOL> from os . path import abspath <EOL> from log import LOG <EOL> import state <EOL> import utility <EOL> import json <EOL> versions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> title = GINTERFACES . GAD <EOL> def deploy ( fingerengine , fingerprint ) : <EOL> """<STR_LIT>""" <EOL> if fingerprint . version in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> state . ssl = True <EOL> war_file = fingerengine . options . deploy <EOL> war_path = abspath ( war_file ) <EOL> war_name = parse_war_path ( war_file ) <EOL> dip = fingerengine . options . ip <EOL> headers = { <EOL> "<STR_LIT>" : "<STR_LIT:application/json>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> cookie = checkAuth ( dip , fingerprint . port , title ) <EOL> if not cookie : <EOL> utility . Msg ( "<STR_LIT>" % ( dip , fingerprint . port ) , <EOL> LOG . ERROR ) <EOL> return <EOL> utility . Msg ( "<STR_LIT>" . format ( war_file ) ) <EOL> base = '<STR_LIT>' . format ( dip , fingerprint . port ) <EOL> uri = '<STR_LIT>' <EOL> data = { <EOL> '<STR_LIT:id>' : open ( war_path , '<STR_LIT:rb>' ) , <EOL> '<STR_LIT>' : '<STR_LIT:true>' <EOL> } <EOL> response = utility . requests_post ( base + uri , files = data , <EOL> auth = cookie , <EOL> headers = headers ) <EOL> if response . status_code is <NUM_LIT:200> : <EOL> if fingerprint . version in [ '<STR_LIT>' ] : <EOL> url = base + '<STR_LIT>' <EOL> response = utility . requests_get ( url , auth = cookie , headers = headers ) <EOL> if response . status_code is <NUM_LIT:200> : <EOL> data = json . loads ( response . content ) <EOL> for entry in data [ u"<STR_LIT>" ] : <EOL> if war_name in entry : <EOL> rand = entry . rsplit ( '<STR_LIT:/>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> rand = rand . split ( war_name ) [ <NUM_LIT:1> ] <EOL> fingerengine . random_int = str ( rand ) <EOL> utility . Msg ( "<STR_LIT>" . format ( war_name , rand ) , <EOL> LOG . SUCCESS ) <EOL> else : <EOL> utility . Msg ( "<STR_LIT>" . format ( war_name ) , LOG . SUCCESS ) <EOL> else : <EOL> utility . Msg ( "<STR_LIT>" . format ( war_name , <EOL> response . status_code ) , <EOL> LOG . ERROR ) </s>
