self.playlist_saved=0
self.playlist_name=''
self.notes_saved=1
+ self.notes_filename=None
#create outlet
self.outlet=lout.Outlet()
except ImportError:
pass
+ #load default list, if possible
+ self.do_loadlist(self.config['defaultlist'])
#HELPER FUNCTIONS
#Everything sending an event should be here
'''
return self.plotmanip[self.config['plotmanips'].index(name)]
+ def _clickize(self, xvector, yvector, index):
+ '''
+ returns a ClickedPoint() object from an index and vectors of x, y coordinates
+ '''
+ point=ClickedPoint()
+ point.index=index
+ point.absolute_coords=xvector[index],yvector[index]
+ point.find_graph_coords(xvector,yvector)
+ return point
+
#HERE COMMANDS BEGIN
def help_set(self):
def do_loadlist(self, args):
#checking for args: if nothing is given as input, we warn and exit.
while len(args)==0:
- args=linp.alphainput('File to load?','',0,[])
+ args=linp.safeinput('File to load?')
arglist=args.split()
play_to_load=arglist[0]
def do_genlist(self,args):
#args list is: input path, output name
if len(args)==0:
- args=linp.alphainput('Input files?','',1,[])
+ args=linp.safeinput('Input files?')
arglist=args.split()
list_path=arglist[0]
Syntax: savelist [filename]
'''
while len(args)==0:
- args=linp.alphainput('Output files?','',1,[])
+ args=linp.safeinput('Output file?',['savedlist.txt'])
output_filename=args
'''
if filename=='':
- filename=linp.alphainput('Jump to?','',0,[])
+ filename=linp.safeinput('Jump to?')
filepath=os.path.abspath(filename)
print filepath
c+=1
except IndexError:
#We've found the end of the list.
- answer=linp.alphainput('Curve not found in playlist. Add it to list?','y',0,[])
+ answer=linp.safeinput('Curve not found in playlist. Add it to list?',['y'])
if answer.lower()[0]=='y':
try:
self.do_addtolist(filepath)
dest=0
if args=='':
- name=linp.alphainput('Filename?',self.current.path+'.png',0,[])
+ name=linp.safeinput('Filename?',[self.current.path+'.png'])
else:
args=args.split()
name=args[0]
whichplot=0
args=args.split()
if len(args)==0:
- filename=linp.alphainput('Filename?',self.current.path+'.txt',0,[])
+ filename=linp.safeinput('Filename?',[self.current.path+'.txt'])
else:
filename=linp.checkalphainput(args[0],self.current.path+'.txt',[])
try:
#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:
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('Notebook 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
def do_notelog(self,args):
if len(args)==0:
- args=linp.alphainput('Notelog filename?','notelog.txt',0,[])
+ args=linp.safeinput('Notelog filename?',['notelog.txt'])
note_lines='Notes taken at '+time.asctime()+'\n'
for item in self.current_list:
def do_copylog(self,args):
if len(args)==0:
- args=linp.alphainput('Destination directory?','',0,[]) #TODO default
+ args=linp.safeinput('Destination directory?') #TODO default
mydir=os.path.abspath(args)
if not os.path.isdir(mydir):
if len(item.notes)>0:
try:
shutil.copy(item.path, mydir)
- except OSError:
- print 'OSError. Cannot copy file. Perhaps you gave me a wrong directory?'
+ except (OSError, IOError):
+ print 'Cannot copy file. '+item.path+' Perhaps you gave me a wrong directory?'
#OUTLET management
-
-
+#-----------------
def do_outlet_show(self,args):
'''OUTLET_SHOW
---------
else:
self.outlet.delete(args)
-
-
-
-
#OS INTERACTION COMMANDS
#-----------------
def help_dir(self):
def do_current(self,args):
print self.current.path
+ def do_info(self,args):
+ '''
+ INFO
+ ----
+ Returns informations about the current curve.
+ '''
+ print 'Path: ',self.current.path
+ print 'Experiment: ',self.current.curve.experiment
+ print 'Filetype: ',self.current.curve.filetype
+ for plot in self.current.curve.default_plots():
+ for set in plot.vectors:
+ lengths=[len(item) for item in set]
+ print 'Data set size: ',lengths
+
def do_version(self,args):
'''
VERSION
we_exit='N'
if (not self.playlist_saved) or (not self.notes_saved):
- we_exit=linp.alphainput('You did not save your playlist and/or notes. Exit?','n',0,[])
+ we_exit=linp.safeinput('You did not save your playlist and/or notes. Exit?',['n'])
else:
- we_exit=linp.alphainput('Exit?','y',0,[])
+ we_exit=linp.safeinput('Exit?',['y'])
if we_exit[0].upper()=='Y':
wx.CallAfter(self.frame.Close)