(self)
| 83 | return name |
| 84 | |
| 85 | def copyFile(self): |
| 86 | list = readFilenameList(self.origin_path) |
| 87 | # print(list) |
| 88 | flag = self.checkFileisExist() |
| 89 | if flag == False: return 'copyFile Failed' |
| 90 | index = 0 |
| 91 | for sub_folder, num2pick in dict_num.items(): |
| 92 | print(sub_folder, num2pick) |
| 93 | class_path = os.path.join(self.origin_path, sub_folder) |
| 94 | sample_list = random.sample(os.listdir(class_path), num2pick) |
| 95 | sample_train = sample_list[:int(num2pick * 0.8)] |
| 96 | sample_validation = sample_list[int(num2pick * 0.8):] |
| 97 | |
| 98 | goal_sub_path = self.get_floder_name(index) |
| 99 | for name in sample_train: |
| 100 | shutil.copy(self.origin_path + '\\' + sub_folder + '\\' + name, |
| 101 | self.goal_path + '\\train' + '\\' + goal_sub_path + '\\' + f'{goal_sub_path}_{hash(name)}.pcap') |
| 102 | for name in sample_validation: |
| 103 | shutil.copy(self.origin_path + '\\' + sub_folder + '\\' + name, |
| 104 | self.goal_path + '\\validation' + '\\' + goal_sub_path + '\\' + f'{goal_sub_path}_{hash(name)}.pcap') |
| 105 | index += 1 |
| 106 | return 'moveFile Succeed!' |
| 107 | |
| 108 | # file_abs_path = self.origin_path + "\\" + class_list |
| 109 | # pcap_list = readFilenameList(file_abs_path) |
| 110 | # picknumber = dict_num[malFamily] |
| 111 | # sample = random.sample(pathDir, picknumber) |
| 112 | # # print(sample) |
| 113 | # for name in sample: |
| 114 | # # shutil.move(self.origin_path + '\\' + malFamily + '\\' + name, |
| 115 | # # self.goal_path + '\\' + malFamily + '\\' + name) |
| 116 | # shutil.copy(self.origin_path + '\\' + malFamily + '\\' + name, |
| 117 | # self.goal_path + '\\' + malFamily + '\\' + name) |
| 118 | # return 'moveFile Succeed!' |
| 119 | |
| 120 | |
| 121 | if __name__ == '__main__': |
no test coverage detected