-
Notifications
You must be signed in to change notification settings - Fork 156
/
prepare_archive.py
30 lines (24 loc) · 1.17 KB
/
prepare_archive.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
import os, time, zipfile, functools, pprint, subprocess
if ( __name__ == '__main__' ):
date_tag = time.strftime('%Y%m%d')
folder_name = 'GtkRadiant-1.6.4-%s' % date_tag
base_name = '%s.zip' % folder_name
full_path = os.path.join( r'D:\\', base_name )
def write_file( z, prefix_path, folder_name, root, fn ):
fullpath = os.path.join( root, fn )
arcname = fullpath.replace( prefix_path, folder_name )
print( '%s -> %s' % ( fullpath, arcname ) )
z.write( fullpath, arcname )
z = zipfile.ZipFile( full_path, 'w', zipfile.ZIP_DEFLATED )
prefix_path = r'D:\GtkRadiant\install'
for root, dirs, files in os.walk( prefix_path, topdown = True ):
if ( root.find( '.svn' ) >= 0 ):
continue
files = [n for n in files if not (
n.endswith( '.lib' )
or n.endswith( '.pdb' )
or n.endswith( '.exp' ) )]
list(map( functools.partial( write_file, z, prefix_path, folder_name, root ), files ))
z.close()
# could be nicer to import s3cmd
subprocess.check_call( [ r'C:\Python27\python.exe', r'C:\Python27\Scripts\s3cmd', 'put', full_path, 's3://gtkradiant' ] )