1234567891011121314151617 |
- def upload(filename):
- parsed_name = filename.split('/')
- dir = parsed_name[0]
- file = parsed_name[1].split('-')
- gz_filename = file[0] + '-archive'
- for el in file[1:]:
- gz_filename = gz_filename + '-' + el
- gz_filename = gz_filename + '.bz2'
- full_file_path = log_dir + dir + '/' + gz_filename
- print('Compressing: ' + log_dir + filename)
- with open(log_dir + filename, 'rb') as f_in, bz2.BZ2File(log_dir + dir + '/' + gz_filename, 'w') as f_out:
- shutil.copyfileobj(f_in, f_out)
- print('Removing: ' + log_dir + filename)
- os.remove(log_dir + filename)
- if encrypt(dir + '/' + gz_filename):
- upload_to_s3([dir + '/' + gz_filename + '.aes', ], bucket)
- os.remove(log_dir + dir + '/' + gz_filename + '.aes')
|