From 591415847bd6ec40e23488514c5d7f253a3951a6 Mon Sep 17 00:00:00 2001 From: devicerandom Date: Thu, 19 Jun 2008 17:07:21 +0000 Subject: [PATCH] (hooke_cli.py) Updated note command to incrementally save notes -a lot of headaches when Hooke crashes should be relieved --- hooke.conf | 1 + hooke_cli.py | 61 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/hooke.conf b/hooke.conf index 56e042f..0b4c2ec 100755 --- a/hooke.conf +++ b/hooke.conf @@ -32,6 +32,7 @@ This section defines which plugins have to be loaded by Hooke. This section defines which drivers have to be loaded by Hooke. --> + diff --git a/hooke_cli.py b/hooke_cli.py index d50afcf..4cc5510 100755 --- a/hooke_cli.py +++ b/hooke_cli.py @@ -102,6 +102,7 @@ class HookeCli(cmd.Cmd): self.playlist_saved=0 self.playlist_name='' self.notes_saved=1 + self.notes_filename=None #create outlet self.outlet=lout.Outlet() @@ -670,16 +671,20 @@ Syntax: txt [filename] {plot to export} #LOGGING, REPORTING, NOTETAKING - def help_note(self): - print ''' -NOTE -Writes or displays a note about the current curve. -If [anything] is empty, it displays the note, otherwise it adds a note. -The note is then saved in the playlist if you issue a savelist command ---------------- -Syntax: note [anything] -''' - def do_note(self,args): + + + def do_note_old(self,args): + ''' + NOTE_OLD + **deprecated**: Use note instead. Will be removed in 0.9 + + Writes or displays a note about the current curve. + If [anything] is empty, it displays the note, otherwise it adds a note. + The note is then saved in the playlist if you issue a savelist command + --------------- + Syntax: note_old [anything] + + ''' if args=='': print self.current_list[self.pointer].notes else: @@ -694,6 +699,42 @@ Syntax: note [anything] self.current_list[self.pointer].notes=args self.notes_saved=0 + + def do_note(self,args): + ''' + NOTE + + Writes or displays a note about the current curve. + If [anything] is empty, it displays the note, otherwise it adds a note. + The note is then saved in the playlist if you issue a savelist command. + --------------- + Syntax: note_old [anything] + + ''' + if args=='': + print self.current_list[self.pointer].notes + else: + if self.notes_filename == None: + self.notes_filename=raw_input('Filename? ') + title_line='Notes taken at '+time.asctime()+'\n' + f=open(self.notes_filename,'w') + f.write(title_line) + f.close() + + #bypass UnicodeDecodeError troubles + try: + args=args.decode('ascii') + except: + args=args.decode('ascii','ignore') + if len(args)==0: + args='?' + self.current_list[self.pointer].notes=args + + f=open(self.notes_filename,'a+') + note_string=(self.current.path+' | '+self.current.notes+'\n') + f.write(note_string) + f.close() + def help_notelog(self): print ''' NOTELOG -- 2.26.2