This repository has been archived by the owner on Oct 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
make.py
executable file
·70 lines (55 loc) · 1.73 KB
/
make.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python
import os
import shutil
import zipfile
import zlib
import os.path
import sys
import re
# Note : Need python3 in order to run !
def _getVersion():
with open('INSTALL/config.php') as f:
for line in f:
version_search = re.search('\'nkVersion\'[\s]+=>[\s]+\'(.*)\'', line)
if version_search:
return version_search.group(1)
sys.exit('Version number no found !')
def _ignore(src, name):
if ((src == './UPLOAD/') or (src == './/UPLOAD/')):
return [['RESTDIR', 'conf.inc.php', file, 'Thumbs.db', 'ehthumbs.db', '.DS_Store', '.Spotlight-V100', '.Trashes', '.gitignore', '.git', 'make.py'], ['config_save_.(.*)\.php', '(.*)\.bak', 'thumbcache_.(.*)\.db']]
else:
return [[], []]
def _RecImport(src, dst, zip):
elements = os.listdir(src)
ignored = _ignore('.' + dst, elements)
for delete in ignored[0]:
try:
elements.remove(delete)
except ValueError:
pass
for ele in elements:
remove = False
for delete in ignored[1]:
test = re.search(delete, ele)
if test :
remove = True
break
if remove is not True:
if os.path.isfile(src + ele):
zip.write(src + ele, dst + ele)
print (dst + ele)
elif os.path.isdir(src + ele):
_RecImport(src + ele + '/', dst + ele + '/', zip)
version = _getVersion()
file = 'Nuked-Klan_v' + version + '.zip'
try:
shutil.rmtree('tmp')
except OSError:
pass
try:
os.remove(file)
except OSError:
pass
zip = zipfile.ZipFile(file, 'w', zipfile.ZIP_DEFLATED, False)
_RecImport('RESTDIR/', '/', zip)
_RecImport('./', '/UPLOAD/', zip)