# -*- coding: utf-8 -*-
# !/usr/bin/python
import sys
import subprocess
import time
#根据实际数据的位置修改，可选择替换方式，运行导入
data_path= 'E:\\kiggle\\kiggleData\\'
#data_path = sys.argv[1]

opcode_path='op_train'
jump_path='jump_train'
jump_map_path='jump_map_train'

cmd='mkdir '+' '.join([opcode_path,jump_path,jump_map_path])
subprocess.call(cmd,shell=True)

cmd='python get_id.py '+ ' '.join([data_path+'train',data_path+'test',data_path + 'trainLabels.csv',data_path+'testLabels.csv'])
subprocess.call(cmd,shell=True)
print('DONE get_id.py')

cmd='python get_ins.py xid.p '+' '.join([data_path+'train',opcode_path])
subprocess.call(cmd,shell=True)
print('DONE get_ins.py')

cmd='python get_jump.py xid.p '+' '.join([opcode_path,jump_path])
subprocess.call(cmd,shell=True)
print('DONE get_jump.py')

cmd='python get_jump_map.py xid.p '+' '.join([data_path+'train',jump_path,jump_map_path])
subprocess.call(cmd,shell=True)
print('DONE get_jump_map.py')

cmd='python find_new_ins.py xid.p '+' '.join([opcode_path,jump_map_path])
subprocess.call(cmd,shell=True)
print('DONE find_new_ins.py')

cmd='python filtcmd.py'
subprocess.call(cmd,shell=True)
print('DONE filecmd.py')

cmd='python find_2g.py xid.p '+data_path+'train'
subprocess.call(cmd,shell=True)
print('DONE find_2g.py')

cmd='python find_3g.py xid.p '+data_path+'train'
subprocess.call(cmd,shell=True)
print('DONE find_3g.py')

cmd='python cut3g.py'
subprocess.call(cmd,shell=True)
print('DONE cut_3g.py')

cmd='python cut3g_for_4g.py'
subprocess.call(cmd,shell=True)
print('DONE cut3g_for_4g.py')

cmd='python find_4g.py xid.p '+data_path+'train'
subprocess.call(cmd,shell=True)
print('DONE find_4g.py')

cmd='python cut4g.py'
subprocess.call(cmd,shell=True)
print('DONE cut4g.py')

cmd='python sect_count_feature.py xid.p '+data_path+'train'
subprocess.call(cmd,shell=True)
print('DONE sect_count_feature_train.py')

#生成测试特征
cmd='python sect_count_feature.py Xt_id.p '+data_path+'test'
subprocess.call(cmd,shell=True)
print('DONE sect_count_feature_test.py')

cmd='python rebuild_2g3g4g.py xid.p '+data_path+'train'
subprocess.call(cmd,shell=True)
print('DONE rebuild_2g3g4g_train.py')

cmd='python rebuild_2g3g4g.py Xt_id.p '+data_path+'test'
subprocess.call(cmd,shell=True)
print('DONE rebuild_2g3g4g_test.py')

