From 00bef6186e77caa4693a9453276bfe91504c733a Mon Sep 17 00:00:00 2001 From: Ben West Date: Mon, 30 May 2016 19:51:38 -0700 Subject: [PATCH] isolate session file io into two specific methods still so-so, but at least there's a symmetry for read/write for session file. --- openaps/vendors/medtronic.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openaps/vendors/medtronic.py b/openaps/vendors/medtronic.py index 690f7f2..9d4f6a1 100644 --- a/openaps/vendors/medtronic.py +++ b/openaps/vendors/medtronic.py @@ -67,13 +67,15 @@ def before_main (self, args, app): def after_main (self, args, app): if self.save_session: - - with open(self.device.get('session', '{0}-session.json'.format(self.device.name)), 'w+') as io: - json.dump(self.update_session_info(self.session), io) + self.write_session_file(self.update_session_info(self.session), io) if self.uart: self.uart.close( ) + def write_session_file (self, session): + with open(self.device.get('session', '{0}-session.json'.format(self.device.name)), 'w+') as io: + json.dump(session, io) + def read_session_file (self): session = dict( ) with open(self.device.get('session', '{0}-session.json'.format(self.device.name)), 'a+') as io: