<s> import sys , os , traceback <EOL> from AGSRestFunctions import getServicesDirectory <EOL> from AGSRestFunctions import editServicesDirectory <EOL> scriptName = os . path . basename ( sys . argv [ <NUM_LIT:0> ] ) <EOL> exitSuccessCode = <NUM_LIT:0> <EOL> exitErrCode = <NUM_LIT:1> <EOL> debug = False <EOL> def main ( ) : <EOL> totalSuccess = True <EOL> results = check_args ( ) <EOL> if not results : <EOL> sys . exit ( exitErrCode ) <EOL> server_fqdn , port , user , password , use_ssl , arcgis_com_map_text = results <EOL> if debug : <EOL> print '<STR_LIT>' , results <EOL> try : <EOL> success , s_dir_props = getServicesDirectory ( server_fqdn , port , user , password , use_ssl ) <EOL> if not success : <EOL> raise Exception ( '<STR_LIT>' + <EOL> '<STR_LIT>' + str ( s_dir_props ) ) <EOL> print '<STR_LIT>' <EOL> arcgis_com_map = '<STR_LIT>' . format ( server_fqdn ) <EOL> jsapi_arcgis = '<STR_LIT>' . format ( server_fqdn ) <EOL> jsapi_arcgis_css = '<STR_LIT>' . format ( server_fqdn ) <EOL> jsapi_arcgis_css2 = '<STR_LIT>' . format ( server_fqdn ) <EOL> if s_dir_props . get ( '<STR_LIT>' ) : <EOL> services_dir_enabled = s_dir_props . get ( '<STR_LIT>' ) <EOL> elif s_dir_props . get ( '<STR_LIT>' ) : <EOL> services_dir_enabled = s_dir_props . get ( '<STR_LIT>' ) <EOL> else : <EOL> services_dir_enabled = '<STR_LIT:true>' <EOL> success , response = editServicesDirectory ( server_fqdn , port , user , password , <EOL> s_dir_props [ '<STR_LIT>' ] , arcgis_com_map , <EOL> arcgis_com_map_text , jsapi_arcgis , <EOL> jsapi_arcgis_css , jsapi_arcgis_css2 , <EOL> s_dir_props [ '<STR_LIT>' ] , services_dir_enabled , use_ssl ) <EOL> if not success : <EOL> raise Exception ( '<STR_LIT>' + <EOL> '<STR_LIT>' + str ( response ) ) <EOL> success , s_dir_props = getServicesDirectory ( server_fqdn , port , user , password , use_ssl ) <EOL> if not success : <EOL> raise Exception ( '<STR_LIT>' + <EOL> '<STR_LIT>' + str ( s_dir_props ) ) <EOL> props_not_altered = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' ] <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' . format ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> print '<STR_LIT:->' * <NUM_LIT:100> <EOL> for key in s_dir_props : <EOL> keyName = key <EOL> if keyName in props_not_altered : <EOL> keyName = keyName + '<STR_LIT:*>' <EOL> print '<STR_LIT>' . format ( keyName , s_dir_props [ key ] ) <EOL> print '<STR_LIT>' <EOL> except : <EOL> totalSuccess = False <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> tbinfo = traceback . format_tb ( tb ) [ <NUM_LIT:0> ] <EOL> pymsg = "<STR_LIT>" + tbinfo + "<STR_LIT>" + str ( sys . exc_info ( ) [ <NUM_LIT:1> ] ) <EOL> print <EOL> print "<STR_LIT>" <EOL> print pymsg + "<STR_LIT:\n>" <EOL> finally : <EOL> exe_str = '<STR_LIT>' + scriptName + '<STR_LIT>' <EOL> if totalSuccess : <EOL> print exe_str + '<STR_LIT>' <EOL> sys . exit ( exitSuccessCode ) <EOL> else : <EOL> print '<STR_LIT>' + exe_str + '<STR_LIT>' <EOL> sys . exit ( exitErrCode ) <EOL> def check_args ( ) : <EOL> arcgis_com_map_text = '<STR_LIT>' <EOL> if len ( sys . argv ) < <NUM_LIT:6> : <EOL> print '<STR_LIT:\n>' + scriptName + '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' + arcgis_com_map_text + '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> return None <EOL> else : <EOL> server_fqdn = sys . argv [ <NUM_LIT:1> ] . lower ( ) <EOL> port = sys . argv [ <NUM_LIT:2> ] <EOL> adminuser = sys . argv [ <NUM_LIT:3> ] <EOL> password = sys . argv [ <NUM_LIT:4> ] <EOL> use_ssl = sys . argv [ <NUM_LIT:5> ] <EOL> if len ( sys . argv ) == <NUM_LIT:7> : <EOL> arcgis_com_map_text = sys . argv [ <NUM_LIT:6> ] <EOL> if port . strip ( ) == '<STR_LIT:#>' : <EOL> port = None <EOL> if use_ssl . strip ( ) . lower ( ) in [ '<STR_LIT:yes>' , '<STR_LIT>' , '<STR_LIT:y>' ] : <EOL> use_ssl = True <EOL> else : <EOL> use_ssl = False <EOL> return server_fqdn , port , adminuser , password , use_ssl , arcgis_com_map_text <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
