def test_runIndexCreatePrograms(self): self.logger.info("Index Create Programs Test") for d in self.directory_list: result = plugins.directoryValidAndImport( os.path.join(TEST_DIRECTORY_PATH, d["directory_name"])) if result["code"] == 0: result = plugins.directoryAnalysisProgram( os.path.join(TEST_DIRECTORY_PATH, d["directory_name"])) if result["code"] == 0: result = plugins.makeAlgorithmConfigFiles() if result["code"] == 0: result = plugins.runIndexCreateProgram() # log_info = "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"]) # self.logger.info(log_info) ''' print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"]) ''' if result["code"] == 0: config_query_set = AlgorithmConfigInfo.objects.all( ) total = len(config_query_set) finished = len( config_query_set.filter(config_flag=1)) while finished < total: self.logger.info("index creating...") time.sleep(10) finished = AlgorithmConfigInfo.objects.filter( config_flag=1) else: log_info = "{} - {} - {}".format( result["code"], d["directory_return_code"], result["message"]) self.logger.info(log_info) self.assertEqual(result["code"], d["directory_return_code"])
def addDirectorytoDatabase(request): dirs_string = request.POST['directories'] dir_list = dirs_string.split(';') dir_list = [d for d in dir_list if os.path.exists(d.strip())] importDirInfoToDatabase(dir_list) file_list = [] for dir in dir_list: tmp = dir.strip() file_list += getFileFromDirectory(tmp) importFileInfoToDatabase(file_list) config_file_list = makeAlgorithmConfigFiles() runIndexCreateProgram() return HttpResponseRedirect('/dashboard/') #return HttpResponse(file_list) #return render_to_response('dashboard.html',{}) '''
def test_makeAlgorithmConfigFiles(self): self.logger.info("Algorithm Config Files make Test") for d in self.directory_list: result = plugins.directoryValidAndImport( os.path.join(TEST_DIRECTORY_PATH, d["directory_name"])) if result["code"] == 0: result = plugins.directoryAnalysisProgram( os.path.join(TEST_DIRECTORY_PATH, d["directory_name"])) if result["code"] == 0: result = plugins.makeAlgorithmConfigFiles() log_info = "{} - {} - {}".format( result["code"], d["directory_return_code"], result["message"]) self.logger.info(log_info) ''' print "{} - {} - {}".format(result["code"], d["directory_return_code"], result["message"]) ''' self.assertEqual(result["code"], d["directory_return_code"])
def directoryAddition(request): directory_string = request.POST.get('directory', '') result = plugins.directoryValidAndImport(directory_string) if result["code"] == 0: result = plugins.directoryAnalysisProgram(directory_string) if result["code"] == 0: result = plugins.makeAlgorithmConfigFiles() if result["code"] == 0: result = plugins.runIndexCreateProgram() if result["code"] == 0: return HttpResponseRedirect('/dashboard/') #return HttpResponse(json.dumps(result), content_type="application/json") else: #return HttpResponse(json.dumps(result), content_type="application/json") return HttpResponseRedirect('/dashboard/') else: #return HttpResponse(json.dumps(result), content_type="application/json") return HttpResponseRedirect('/dashboard/') else: #return HttpResponse(json.dumps(result), content_type="application/json") return HttpResponseRedirect('/dashboard/') else: #return HttpResponse(json.dumps(result), content_type="application/json") return HttpResponseRedirect('/dashboard/')
# -*- coding: utf-8 -*- ''' Created on 2016-12-12 @author: Polly ''' import plugins def test(): for i in range(10): print "%s times has been done!"%i def runDirectoryAnalysisProgram(): directory_list = plugins.getDirectoryList() file_list = plugins.getFileListFromDirectoryList() plugins.importFileInfoToDatabase(file_list) plugins.makeAlgorithmConfigFiles() plugins.runIndexCreateProgram()