<s> import sys , os , traceback , datetime , ast , copy , json <EOL> sys . path . append ( os . path . join ( os . path . dirname ( os . path . dirname ( sys . argv [ <NUM_LIT:0> ] ) ) , '<STR_LIT>' ) ) <EOL> from AGSRestFunctions import getServiceList <EOL> scriptName = os . path . basename ( sys . argv [ <NUM_LIT:0> ] ) <EOL> exitErrCode = <NUM_LIT:1> <EOL> debug = False <EOL> sectionBreak = '<STR_LIT:=>' * <NUM_LIT> <EOL> sectionBreak1 = '<STR_LIT:->' * <NUM_LIT> <EOL> def check_args ( ) : <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> return None <EOL> else : <EOL> server = sys . argv [ <NUM_LIT:1> ] <EOL> port = sys . argv [ <NUM_LIT:2> ] <EOL> adminuser = sys . argv [ <NUM_LIT:3> ] <EOL> password = sys . argv [ <NUM_LIT:4> ] <EOL> useSSL = sys . argv [ <NUM_LIT:5> ] <EOL> if port . strip ( ) == '<STR_LIT:#>' : <EOL> port = None <EOL> if useSSL . strip ( ) . lower ( ) in [ '<STR_LIT:yes>' , '<STR_LIT>' , '<STR_LIT:y>' ] : <EOL> useSSL = True <EOL> else : <EOL> useSSL = False <EOL> return server , port , adminuser , password , useSSL <EOL> def main ( ) : <EOL> totalSuccess = True <EOL> results = check_args ( ) <EOL> if not results : <EOL> sys . exit ( exitErrCode ) <EOL> server , port , adminuser , password , useSSL = results <EOL> if debug : <EOL> print server , port , adminuser , password , useSSL <EOL> try : <EOL> if useSSL : <EOL> protocol = '<STR_LIT>' <EOL> else : <EOL> protocol = '<STR_LIT:http>' <EOL> allServices = getServiceList ( server , port , adminuser , password ) <EOL> excludeServices = [ ] <EOL> services = [ service for service in allServices if service not in excludeServices ] <EOL> services = [ service . replace ( '<STR_LIT>' , '<STR_LIT:/>' ) for service in allServices ] <EOL> if len ( services ) == <NUM_LIT:0> : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> numServices = len ( services ) <EOL> i = <NUM_LIT:0> <EOL> for service in services : <EOL> i += <NUM_LIT:1> <EOL> print service <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> if totalSuccess : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
