1515import re
1616import subprocess
1717import sys
18- import zipfile
1918from time_recorder import TimeRecord
2019
2120"""
2221RM_STATUS : {
2322 0 Remove Nothing
2423 1 Remove all
25- 2 Remove Lib Code
2624}
2725"""
2826RM_STATUS = 1
@@ -63,7 +61,8 @@ def __init__(self):
6361 self .packages_feature = []
6462 self .libs_feature = []
6563 self .project_path = os .path .dirname (sys .argv [0 ])
66-
64+ if self .project_path == "" :
65+ self .project_path = "."
6766 self .load_data ()
6867
6968
@@ -73,24 +72,6 @@ def rm_lib_files(lib_list):
7372 cmd = 'rm -rf %s' % lib_dir_name
7473 subprocess .call (cmd , shell = True )
7574
76- @staticmethod
77- def zip_apk (source , target ):
78- if not os .path .exists (os .path .dirname (target )):
79- os .mkdir (os .path .dirname (target ))
80- file_list = []
81- if os .path .isdir (source ):
82- for root , dirs , files in os .walk (source ):
83- for name in files :
84- file_list .append (os .path .join (root , name ))
85- else :
86- # print '%s is not a directory.' % source
87- file_list .append (source )
88- zf = zipfile .ZipFile (target , 'w' , zipfile .zlib .DEFLATED )
89- for tar in file_list :
90- arcname = tar [len (source ):]
91- zf .write (tar , arcname )
92- zf .close ()
93-
9475 def get_number (self , string ):
9576 """
9677 Get API ID From API Dictionary.
@@ -425,16 +406,6 @@ def find_features(package):
425406 if RM_STATUS > 0 :
426407 self .rm_lib_files (lib_dir_list )
427408
428- zip_file_name = self .project_path + '/../clean_app/' + os .path .basename (apk_path )[:- 3 ] + 'zip'
429- smali_path = apk_path + '/smali'
430- self .zip_apk (smali_path , zip_file_name )
431-
432409 if RM_STATUS == 1 :
433410 cmd = 'rm -rf %s' % apk_path
434411 subprocess .call (cmd , shell = True )
435- elif RM_STATUS == 2 :
436- zip_file_name = self .project_path + '/../clean_app/' + os .path .basename (apk_path )[:- 3 ] + 'zip'
437- smali_path = apk_path + '/smali'
438- self .zip_apk (smali_path , zip_file_name )
439- return zip_file_name
440- return "No Zip File Here."
0 commit comments