MCPcopy Create free account
hub / github.com/bobolike123/NetworkTrafficAnalysis / copyFile

Method copyFile

tools/copyRandomSample.py:52–70  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

50 return Flag
51
52 def copyFile(self):
53 list = readFilenameList(self.origin_path)
54 # print(list)
55 flag = self.checkFileisExist()
56 if flag == False: return 'moveFile Failed'
57 for malFamily in list: # 对train文件夹下的每个子文件夹,随机取出EXTRACT_RATIO比例的文件放入validation文件夹中
58 file_abs_path = self.origin_path + "\\" + malFamily
59 pathDir = readFilenameList(file_abs_path)
60 # filenumber = len(pathDir)
61 # picknumber = int(filenumber * self.EXTRACT_RATIO)
62 picknumber = dict_num[malFamily]
63 sample = random.sample(pathDir, picknumber)
64 # print(sample)
65 for name in sample:
66 # shutil.move(self.origin_path + '\\' + malFamily + '\\' + name,
67 # self.goal_path + '\\' + malFamily + '\\' + name)
68 shutil.copy(self.origin_path + '\\' + malFamily + '\\' + name,
69 self.goal_path + '\\' + malFamily + '\\' + name)
70 return 'moveFile Succeed!'
71
72if __name__ == '__main__':
73 divideDataSet(origin_path=r'K:\数据库\ISCX-IDS-2012\2_extractFlowFeature',goal_path=r'K:\数据库\ISCX-IDS-2012\3_sampleDataset').copyFile()

Callers 1

Calls 2

checkFileisExistMethod · 0.95
readFilenameListFunction · 0.70

Tested by

no test coverage detected