Skip to content

Commit

Permalink
isolate session file io into two specific methods
Browse files Browse the repository at this point in the history
still so-so, but at least there's a symmetry for read/write for session file.
  • Loading branch information
bewest committed May 31, 2016
1 parent b463c6f commit 00bef61
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions openaps/vendors/medtronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 00bef61

Please sign in to comment.