Skip to content

Commit

Permalink
Fixing the "write_log" method according to the unit test #28 closes #34
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm8 committed May 17, 2022
1 parent 7367ba3 commit ea1296b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions spacelab_transmitter/spacelabtransmitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@

#Defining logfile deafult local
_DIR_CONFIG_LOGFILE_LINUX = 'spacelab_transmitter'
_DEFAULT_LOGFILE_PATH = os.path.join(os.path.expanduser('~'), _DIR_CONFIG_LOGFILE_LINUX)
_DEFAULT_LOGFILE = 'logfile.csv'
_DEFAULT_LOGFILE_PATH = os.path.join(os.path.expanduser('~'), _DIR_CONFIG_LOGFILE_LINUX)
_DEFAULT_LOGFILE = 'logfile.csv'

class SpaceLabTransmitter:

Expand Down Expand Up @@ -212,14 +212,13 @@ def on_toolbutton_about_clicked(self, toolbutton):
self.aboutdialog.hide()

def write_log(self, msg):
timestamp = datetime.now()
event = [str(datetime.now()), msg]

self.listmodel_events.append([str(timestamp), msg])
self.listmodel_events.append(event)

if not os.path.exists(_DEFAULT_LOGFILE_PATH):
os.mkdir(_DEFAULT_LOGFILE_PATH)

with open(_DEFAULT_LOGFILE_PATH + '/' + _DEFAULT_LOGFILE, 'a') as logfile:
writer = csv.writer(logfile, delimiter='\t')
writer.writerows(self.listmodel_events)

writer.writerow(event)

0 comments on commit ea1296b

Please sign in to comment.