def registerServer(): """ Register Server """ cfg = loadConfig('config.cfg') if os.path.exists('config.internal.cfg') == False: setInternalConfig('undefined', 'undefined', 'undefined') cfginternal = loadConfig('config.internal.cfg') url = cfg['url'] interfaceMidas = apiMidas.Communicator(url) parameters = dict() parameters['email'] = cfginternal['email'] + '@example.org' parameters['securitykey'] = cfg['securityKey'] parameters['apikey'] = cfginternal['apikey'] try: response = interfaceMidas.makeRequest( 'midas.remoteprocessing.registerserver', parameters) except pydasException.PydasException, e: parameters = dict() parameters['securitykey'] = cfg['securityKey'] parameters['os'] = cfg['os'] try: response = interfaceMidas.makeRequest( 'midas.remoteprocessing.registerserver', parameters) except pydasException.PydasException, e: print "Unable to Register. Please check the configuration." return False
def sendResults(file): """ Send Results """ cfg = loadConfig('config.cfg') cfginternal = loadConfig('config.internal.cfg') url = cfg['url'] interfaceMidas = apiMidas.Communicator(url) parameters = dict() parameters['token'] = cfginternal['token'] try: response = interfaceMidas.makeRequest( 'midas.remoteprocessing.resultsserver', parameters, file) except pydasException.PydasException, e: print "Unable to send results" print e return False
def keepAliveServer(): """ Keep Alive """ cfg = loadConfig('config.cfg') cfginternal = loadConfig('config.internal.cfg') url = cfg['url'] interfaceMidas = apiMidas.Communicator(url) parameters = dict() parameters['token'] = cfginternal['token'] parameters['os'] = cfg['os'] try: response = interfaceMidas.makeRequest( 'midas.remoteprocessing.keepaliveserver', parameters) except pydasException.PydasException, e: print "Keep aline failed" print e return False
scriptFile.close() #Create Params file try: scriptFile = open(pathProcessingFolder + '/results/parameters.txt', "w") except Exception, e: raise scriptFile.write(response['params']) scriptFile.close() inputFiles = params['input'] cfg = loadConfig('config.cfg') cfginternal = loadConfig('config.internal.cfg') url = cfg['url'] interfaceMidas = apiMidas.Communicator(url) if inputFiles: print "Download Data" for file in inputFiles: interfaceMidas.downloadItem(file, pathProcessingFolder + '/script', cfginternal['token']) print "Run script" os.chdir(pathProcessingFolder + '/script/') cmd = sys.executable + " " + pathProcessingFolder + '/script/script.py' p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE,