mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
fix: [import_dir] remove dir whitespaces #475
This commit is contained in:
parent
1f8c858c77
commit
72fe8a2461
1 changed files with 8 additions and 5 deletions
|
@ -9,7 +9,7 @@ import gzip
|
|||
import argparse
|
||||
import os
|
||||
import time, datetime
|
||||
import mimetypes
|
||||
import magic
|
||||
|
||||
'''
|
||||
'
|
||||
|
@ -75,11 +75,10 @@ if __name__ == "__main__":
|
|||
messagedata = f.read()
|
||||
|
||||
#verify that the data is gzipEncoded. if not compress it
|
||||
if 'text' in str(mimetypes.guess_type(complete_path)[0]):
|
||||
if 'text/plain' in str(magic.from_buffer(messagedata, mime=True)):
|
||||
messagedata = gzip.compress(messagedata)
|
||||
complete_path += '.gz'
|
||||
|
||||
|
||||
if complete_path[-4:] != '.gz':
|
||||
|
||||
#if paste do not have a 'date hierarchy', create it
|
||||
|
@ -94,10 +93,14 @@ if __name__ == "__main__":
|
|||
wanted_path = wanted_path.split('/')
|
||||
wanted_path = '/'.join(wanted_path[-(4+args.hierarchy):])
|
||||
|
||||
path_to_send = 'import_dir/' + args.name + '>>' + wanted_path
|
||||
# remove whitespace
|
||||
wanted_path = wanted_path.replace(' ', '')
|
||||
feeder_name = args.name.replace(' ', '')
|
||||
|
||||
path_to_send = 'import_dir/' + feeder_name + '>>' + wanted_path
|
||||
s = b' '.join( [ args.channel.encode(), path_to_send.encode(), base64.b64encode(messagedata) ] )
|
||||
socket.send(s)
|
||||
print('import_dir/' + args.name+'>>'+wanted_path)
|
||||
print('import_dir/' + feeder_name+'>>'+wanted_path)
|
||||
time.sleep(args.seconds)
|
||||
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue