def proxyConfigTest(self, path2test): """ Checks proxy configuration """ tmpOutFile = self.getUniqFileName() cmd2run = self.squid_path + " -k parse -f " + path2test runner = ph4CmdRunner(cmd2run, tmpOutFile, tmpOutFile, stdsAreFileNames=True, blocking=True) runner.work() # check stdoutput tmpOutFileH = None stdout = None try: tmpOutFileH = open(tmpOutFile, 'r') stdout = tmpOutFileH.read() stdout = stdout.strip() tmpOutFileH.close() try: if (os.path.exists(tmpOutFile)): os.remove(tmpOutFile) except Exception, e: print ("Error: cannot delete tmpOutFile[%s]: " %(tmpOutFile)), e if 'FATAL:' in stdout: print "!Error! \"FATAL:\" keyword appeared after squid configuration test!" return 1
'''Test that damn proxies configuration''' cfgTestRes = self.proxyConfigTest(tmpSquidConfigFile) if cfgTestRes > 0: print "Error during generated config file testing" continue '''Owerwrite old config file with new config file''' try: os.rename(tmpSquidConfigFile, self.squid_config_file) except Exception,e: print "Error during moving [%s] -> [%s]; " % (tmpSquidConfigFile, self.squid_config_file), e continue '''Reload new changes''' runner = ph4CmdRunner(self.squid_reload_command, blocking=True) runner.work() print "DONE", "="*80, "\n" #if not problem2send == '': # body = 'Problem with rdiff-backup! Problems: \n%s\n Desc:\n%s Stoud: %s\n' % (problem2send, desc, stdout) # self.sendMail(self.backupDesc['erroremail'], "Problem with backup [%s - %s]" % (self.backupDesc['user'], rec['src']), body) #else: # print "Process ended successfully!" #print "" def run(self): """Main runner method""" startTime = time.time() startDatetime = datetime.datetime.now()