From c13c101ac52f37255a1f4fd911ac0fffd995e916 Mon Sep 17 00:00:00 2001 From: nzkarit Date: Fri, 29 Sep 2017 17:38:18 +1300 Subject: [PATCH 1/2] handling multiple CSV files --- ADSB_Encoder.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ADSB_Encoder.py b/ADSB_Encoder.py index b211064..cba332b 100755 --- a/ADSB_Encoder.py +++ b/ADSB_Encoder.py @@ -126,16 +126,17 @@ def manyPlanes(arguments): return samples def writeOutputFile(filename, data): - logger.info('Writing tmp.iq8s file') - SamplesFile = open('tmp.iq8s', 'wb') + tmpfile = '%s.tmp'%(filename) + logger.info('Writing %s file'%(tmpfile)) + SamplesFile = open(tmpfile, 'wb') SamplesFile.write(data) SamplesFile.close() os.system('sync') os.system('rm %s' % (filename)) logger.info('dd for file: %s' % (filename)) - os.system("dd if=tmp.iq8s of=%s bs=4k seek=63 > /dev/null 2>&1" % (filename)) + os.system("dd if=%s of=%s bs=4k seek=63 > /dev/null 2>&1" % (tmpfile, filename)) os.system('sync') - os.system('rm tmp.iq8s') + os.system('rm %s'%(tmpfile)) if __name__ == "__main__": global cfg From 470fe21ad1b5379d4d9145b98c0cc724235e1fdd Mon Sep 17 00:00:00 2001 From: nzkarit Date: Fri, 29 Sep 2017 19:36:01 +1300 Subject: [PATCH 2/2] Making work with threading --- ADSB_Encoder.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/ADSB_Encoder.py b/ADSB_Encoder.py index cba332b..030f48e 100755 --- a/ADSB_Encoder.py +++ b/ADSB_Encoder.py @@ -137,8 +137,8 @@ def writeOutputFile(filename, data): os.system("dd if=%s of=%s bs=4k seek=63 > /dev/null 2>&1" % (tmpfile, filename)) os.system('sync') os.system('rm %s'%(tmpfile)) - -if __name__ == "__main__": + +def main(): global cfg cfg = configparser.ConfigParser() cfg.read('config.cfg') @@ -158,5 +158,30 @@ if __name__ == "__main__": writeOutputFile(arguments.outputfilename, data) logger.info('Complete') +def threadingCSV(csv): + global cfg + cfg = configparser.ConfigParser() + cfg.read('config.cfg') + + arguments = argParser() + arguments.csvfile = csv[0] + arguments.outputfilename = csv[1] + global logger + logging.config.fileConfig('logging.cfg') + logger = logging.getLogger(__name__) + logger.info('Starting ADSB Encoder') + logger.debug('The arguments: %s' % (arguments)) + data = None + if arguments.csvfile == '': + data = singlePlane(arguments) + else: + data = manyPlanes(arguments) + writeOutputFile(arguments.outputfilename, data) + logger.info('Complete') + +if __name__ == "__main__": + main() + +