def add_action(db_conn, prj_path, prj_src_path_tail, log_path): # load_info = offical_load(ats_load_name = load_name) # load_info.save() # os.system('rm -rf %s/%s' % (log_path, prj_name)) for gcda_log_dir in os.listdir(log_path): result = re.search(r"finished", gcda_log_dir) if result: print " %s has been processed. skip it" % gcda_log_dir continue name_backup = gcda_log_dir load_id, case_id, time_stamp = gcda_log_dir.split("__") load_list = offical_load.objects.filter(ats_load_name=load_id) if len(load_list) == 1: load_info = load_list[0] else: load_info = offical_load(ats_load_name=load_id) load_info.save() case_info = rts_case(ats_case_id=case_id, ats_load_name=load_info.ats_load_name, ats_load_fk=load_info) case_info.save() log("mv %s/%s %s/%s" % (log_path, gcda_log_dir, log_path, load_id)) os.rename("%s/%s" % (log_path, gcda_log_dir), "%s/%s" % (log_path, load_id)) log("cp -rfp %s/%s %s" % (log_path, load_id, prj_path)) os.system("cp -rfp %s/%s %s" % (log_path, load_id, prj_path)) prj_src_dir = "%s/%s/%s" % (prj_path, load_id, prj_src_path_tail) print "project src path %s" % prj_src_dir # flush_gcda_files_from_specific_dir(prj_src_dir, 'application', 'XuanWu') flush_gcda_files_from_specific_dir(prj_src_dir) # gcov process parse_gcov_file(load_info, case_info, prj_src_dir, db_conn) clean_foot(prj_src_dir) os.rename("%s/%s" % (log_path, load_id), "%s/%s.finished" % (log_path, name_backup))
#!/usr/local/bin/python import sys, os sys.path.append("/root/work/rts/rts_django") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rts_django.settings") #from polls.models import Poll, Choice from db.models import offical_load, rts_case, src_file, line_executed if __name__ == "__main__": print "hello, world" #for item in offical_load.objects.all(): p = offical_load(ats_load_name='load_016') p.save() case_info1 = rts_case(ats_case_id='8888001', ats_load_name=p.ats_load_name, ats_load_fk=p) case_info1.save() print "load_id load_name datetime" for load in offical_load.objects.all(): print "%-7d %-10s %-10s" % (load.id, load.ats_load_name, load.ats_timestamp)