CVS: python msp430-downloader.py,1.2,1.3

Chris Liechti <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21325/python

Modified Files:
	msp430-downloader.py 
Log Message:
- improve dialogs
- typos


Index: msp430-downloader.py
===================================================================
RCS file: /cvsroot/mspgcc/python/msp430-downloader.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- msp430-downloader.py	27 Sep 2004 00:40:17 -0000	1.2
+++ msp430-downloader.py	24 Oct 2004 01:54:54 -0000	1.3
@@ -3,7 +3,7 @@
 
 This one uses some dialog boxes, which makes it suitable for linking
 file extensions to this program, so that a double click in the 
-winoze exploder downloads the file.
+windoze exploder downloads the file.
 
 (C) 2004 [email protected]
 """
@@ -17,15 +17,22 @@
 name = 'msp430-downloader' #os.path.basename(os.path.splitext(sys.argv[0])[0])
 
 if len(sys.argv) < 2:
-    EasyDialogs.Message("%s: Need a filename" % name)
-    sys.exit(1)
+    #~ EasyDialogs.Message("%s: Need a filename" % name)
+    #~ sys.exit(1)
+    filename = EasyDialogs.AskFileForOpen(
+        windowTitle = "Select MSP430 binary for download",
+        typeList=['*', 'elf', 'a43']
+    )
+    if filename is None:
+        sys.exit(0)
+else:
 filename = sys.argv[1]
 lpt = '1'
 
 
 
 if EasyDialogs.AskYesNoCancel(
-    "Download '%s' with JTAG?" % filename,
+    "Download '%s' using the JTAG interface?" % filename,
 ) != 1:
     sys.exit(1)
 
@@ -45,13 +52,19 @@
     jtagobj.bar = EasyDialogs.ProgressBar('Programming %r...' % filename, 100)
     try:
         jtagobj.data = msp430.memory.Memory()   #prepare downloaded data
-        jtagobj.data.loadFile(filename)         #autodetect filetyoe
+        jtagobj.data.loadFile(filename)         #autodetect filetype
         jtagobj.bar.label('Connecting...')
         jtagobj.connect(lpt)                    #try to open port
         try:
             jtagobj.bar.label('Erasing...')
-            #~ jtagobj.actionMainErase()
+            answer = EasyDialogs.AskYesNoCancel("Choose erase mode",
+                default=1, yes="ALL", no="Main only")
+            if answer == 0: #NO
+                jtagobj.actionMainErase()
+            elif answer == 1: #YES
             jtagobj.actionMassErase()
+            else:   #CANCEL
+                sys.exit(0)
             jtagobj.bar.label('Programming...')
             jtagobj.actionProgram()
         finally:
@@ -61,8 +74,12 @@
         del jtagobj.bar
 except IOError:
     EasyDialogs.Message("%s: Can't Connect to target" % name)
-except:
-    s = StringIO()
-    traceback.print_exc(file=s)
-    print s.getvalue()
-    EasyDialogs.Message(s.getvalue())
+except (SystemExit, KeyboardInterrupt):
+    raise
+except Exception, e:
+    #~ s = StringIO()
+    #~ traceback.print_exc(file=s)
+    #~ print s.getvalue()
+    #~ EasyDialogs.Message(s.getvalue())
+    EasyDialogs.Message('An error occoured: %s' % (e))
+    
\ No newline at end of file



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.