Re: [Tutor] Looking for ConfigObj Documentation

2009-02-23 Thread ALAN GAULD
 Under Start there's a ? icon that says Help and Support.  Minimal info. 

Yes, although by exploring the links and using the Microsoft Knowledgebase 
panel on the left you do get more than I remembered. I just think the DOS 
HELP command is easier to use.

However I did find a good overview on Technet:

http://technet.microsoft.com/en-us/library/bb490954.aspx

Which has a lot of other stuff on cmd.exe too.

 It seems to me that the Command Prompt window is important enough 
 in
the use of Python to warrant a full page somewhere to its
applicability. 

I might try to do that sometime. But its not really Python specific, if you 
are doing any serious programming or admin work on a PC you really 
should be familiar with the cmd window, its often the fastest and easiest 
way to do stuff. And learning the little tricks and settings that make it 
more productive is definitely worthwhile.

Alan G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-22 Thread Alan Gauld


Wayne Watson sierra_mtnv...@sbcglobal.net wrote

tried XP's Help on command prompts. Not much there. Is there another 
source?


When you say XPs help do you mean the GUI help tool?
There isn't much in there.

For DOS things use the DOS help tool.

Type HELP CMD at the DOS prompt.

Alan G. 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-22 Thread Wayne Watson
Title: Signature.html




Under Start there's a ? icon that says Help and Support. Minimal info.
It seems to me that the Command Prompt window is important enough in
the use of Python to warrant a full page somewhere to its
applicability. Well, if not, then I'll make do with what I've seen
here. 

Alan Gauld wrote:

"Wayne Watson" sierra_mtnv...@sbcglobal.net wrote
  
  
  tried XP's Help on command prompts. Not much
there. Is there another source?

  
  
When you say XPs help do you mean the GUI help tool?
  
There isn't much in there.
  
  
For DOS things use the DOS help tool.
  
  
Type HELP CMD at the DOS prompt.
  
  
Alan G. 
  
___
  
Tutor maillist - Tutor@python.org
  
http://mail.python.org/mailman/listinfo/tutor
  
  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-22 Thread ALAN GAULD
 Under Start there's a ? icon that says Help and Support.  Minimal info. 

Yes, although by exploring the links and using the Microsoft Knowledgebase 
panel on the left you do get more than I remembered. I just think the DOS 
HELP command is easier to use.

However I did find a good overview on Technet:

http://technet.microsoft.com/en-us/library/bb490954.aspx

Which has a lot of other stuff on cmd.exe too.

 It seems to me that the Command Prompt window is important enough 
 in
the use of Python to warrant a full page somewhere to its
applicability. 

I might try to do that sometime. But its not really Python specific, if you 
are doing any serious programming or admin work on a PC you really 
should be familiar with the cmd window, its often the fastest and easiest 
way to do stuff. And learning the little tricks and settings that make it 
more productive is definitely worthwhile.

Alan G.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Alan Gauld


Wayne Watson sierra_mtnv...@sbcglobal.net wrote

My assumption was is was fully a DOS window.  


No its a DOS window on steroids!
Thee are a ton of improvements to the DOS shell in XP 
most of which are turned off by default.


Take half an hour to go through the help screens for CMD 
and turn on the various registry settings it mentions to 
access its full power. (Type HELP CMD at the prompt)


Trying to work my way to folder was a bit daunting, 


Cut n paste of the path works, but you can also use tab 
to complete the file name which speeds things up considerably.
(And recall that with QuickEdit turned on you can easily cut n paste 
from the CMD window itself)


Now the problem became one of typing in the name of the 
program each time it was to be executed. 


Even on DOS F3 repeated the last command but 
on XP (and indeed since Win95) you can use up/down arrow 
to step back through the command history. And you can 
set it to remember the history betweeen sessions (although 
I don't personally do that...) I think you can also search 
back through the history but I don't use that very often 
and I'm maybe confusing it with cygwin/bash!

This works inside the python prompt in a CMD window too.

Other tricks include environment variable expansion good 
for HOME, PATH, etc


Definitely worth spending some time reading the HELP on 
the enhanced CMD features.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Tim Golden

Alan Gauld wrote:
Cut n paste of the path works, but you can also use tab to complete the 
file name which speeds things up considerably.


And you can drag a file in from explorer to a Console window
to get the full path pasted in automatically.

Even on DOS F3 repeated the last command but on XP (and indeed since 
Win95) you can use up/down arrow to step back through the command 
history. And you can set it to remember the history betweeen sessions 
(although I don't personally do that...) I think you can also search 
back through the history but I don't use that very often and I'm maybe 
confusing it with cygwin/bash!


No, you're right: if you press a few characters and then
F8 a matching line will be populated (can't remember if
it's the most recent or the oldest). If you press F7, a
selection list of all the lines entered pops up and you
can select from there.

And all the old tricks from the original DOS shells work:
F3 as you mentioned (altho' up/down arrows are easier for
this); F2 will copy up to a particular characters. Quite
limited but still they have their possibilities.


TJG
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Wayne Watson




As it turns out QuickEdit is turned on in my XP, but certainly not by
me.

The unfolding of what the cmd prompt actually does reminds me of a
couple of incidents. When I wrote a book on an interpretive Basic
language in the early 90s, the very first paragraph began with how to
exit from the interpreter. At the time, it seemed popular with such
interpreters to obfuscate the exit command by using names like SYSTEM!
Yikes! 

When I was introduced the C by the Kernighan and Ritchie book, I almost
jumped for joy with their famous "Hello World" program. This was a book
to be read. When I casually, and I mean casually, started looking at
python a few years ago, I started with what I might call a (well-known)
bloated book on the subject, it took until chapter 3 for the author to
say anything about running programs. The first programming job I had
found me staring at a government issued
200 page manual printed in capitals on a then popular language. What a
huge bore. It's a wonder that I continued, or anyone, for that matter.
I guess the right start matters, or in the words of the hero in
Schindler's List (movie), "It's all about presentation." After this
cmd console "discovery", I'd say this is quite possibly something I'd
put in the first chapter of any book on Python. 

Nice to know about F8 (and F7), tab or other attempts didn't do it for
me. I'll take Alan's suggestion on spending some time on the reading
XP Help.

Tim Golden wrote:
Alan
Gauld wrote:
  
  Cut n paste of the path works, but you can
also use tab to complete the file name which speeds things up
considerably.

  
  
And you can drag a file in from explorer to a Console window
  
to get the full path pasted in automatically.
  
  
  Even on DOS F3 repeated the last command but
on XP (and indeed since Win95) you can use up/down arrow to step back
through the command history. And you can set it to remember the history
betweeen sessions (although I don't personally do that...) I think you
can also search back through the history but I don't use that very
often and I'm maybe confusing it with cygwin/bash!

  
  
No, you're right: if you press a few characters and then
  
F8 a matching line will be populated (can't remember if
  
it's the most recent or the oldest). If you press F7, a
  
selection list of all the lines entered pops up and you
  
can select from there.
  
  
And all the old tricks from the original DOS shells work:
  
F3 as you mentioned (altho' up/down arrows are easier for
  
this); F2 will copy up to a particular characters. Quite
  
limited but still they have their possibilities.
  
  
  
TJG
  
___
  
Tutor maillist - Tutor@python.org
  
http://mail.python.org/mailman/listinfo/tutor
  
  


-- 

Signature.html
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Wayne Watson
Title: Signature.html




I tried XP's Help on command prompts. Not much there. Is there another
source?
-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Marc Tompkins
On Sat, Feb 21, 2009 at 6:42 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  I tried XP's Help on command prompts. Not much there. Is there another
 source?


There are lots, and Google knows most of them - here's a good one to start
with: http://www.ss64.com/nt/

-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Wayne Watson
Title: Signature.html




Yes, to a potential bad idea. I'm not quite sure why I put that in
there. Possibly what I really wanted is the location of the file. There
are some other entries where I want to know the location of the file.
For example, the mask file. I likely want to load that file when the
program opens. Similarly with the Events folder. In fact, I probably
want the folder's name chosen by the user, and the location. Folders
and files are not completely thought out. The hard core data, time,
gray choice, lat/long, etc., are currently the most important. 

Distracted? It happens to me all the time?:-) I tell people my life
could be summed up by two words, interrupted projects. 

I could very likely build the file myself from looking at the
descriptions of boolean, etc., but you mentioned something about
possibly a validation function(?) that sounded like maybe I didn't yet
know all the wrinkles in the file.  

Marc Tompkins wrote:

  On Sat, Feb 21, 2009 at 6:46 PM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
Marc, did I miss your update
on the file?

  
  No, just got distracted. I'll get that to you shortly.
  
  
  
One thing I meant to ask you - why is the file name the first line of
the file? It's up to you, but I think it's generally a bad idea -
that's a holdover from my database days; one of the first rules I
learned was "Don't store derived data (and if you must, then don't rely
on it!)" What benefit does it give you, and what consequences would
result if the first line of the file did NOT match the actual file
name? (You know, I edit the file and Save As "Initial1.sen", or
"Initial.sen.hld", or whatever, but I forget to change the first line -
or conversely, I change the first line but forget to rename the file...
What happens? In other words, what are you doing with it?
-- 
  www.fsrtechnologies.com


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Wayne Watson
Title: Signature.html




I've found others like that, but I was looking for something more
descriptive. Things like typing fill-in, or cut/paste, use of F8, etc.
I'd guess there are more. 

Marc Tompkins wrote:
On Sat, Feb 21, 2009 at 6:42 PM, Wayne Watson sierra_mtnv...@sbcglobal.net
wrote:
  
  
I tried XP's Help on command
prompts. Not much there. Is there another
source?
  
  
There are lots, and Google knows most of them - here's a good one to
start with: http://www.ss64.com/nt/
  
  
  
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Marc Tompkins
On Sat, Feb 21, 2009 at 8:26 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  I've found others like that, but I was looking for something more
 descriptive. Things like typing fill-in, or cut/paste, use of F8, etc.  I'd
 guess there are more.

Click through a little further: http://www.ss64.com/nt/cmd.html
Should tell you more than you could possibly want to know about the XP
command prompt and its options.

-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-21 Thread Marc Tompkins
On Fri, Feb 20, 2009 at 2:19 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  Good. Thanks. It works fine for me now.  I deleted the file. I just ran
 the program again straight from the py file, and it put my the black window
 with my raw_input prompt.  It seems odd that it wouldn't have left text
 debris when it crashed.

 I've attached a copy of an Initial file. It's still under development, but
 pretty close for the immediate purposes. The _file_ names will likely end
 up as a string showing the complete path to the file.  start/stop_time will
 be times in
  the format shown, hh:mm:ss. The first line is just a header, and currently
 gets tossed when the file is read.  _name are strings. No others have seen
 the program, so development continues.

 Sentinel NC Configuration File Sentinel User 3 - 1/3/2009 (Meteor Software)
 config_file_name=Initial.sen
 mask_file_name=*none*
 gray_scale=True
 post_event_stack=False
 post_event_format=Tiff 2
 show_real_time=False
 hourly_rate=12
 slowdown=1
 start_time=20:00:12
 stop_time=06:03:00
 lat=40.0
 long=120.0
 utc_offset=8
 elevation=1000.0
 site_name=Unknown
 clock_drift=0.0
 zenith_x_pixel=319
 zenith_y_pixel=239
 north_angle_rotation=0.0
 events=Events
 post_events=Post_Events
 meteors=Meteor_Tags
 composites=wtw:same as events?
 flat_mask_val=30
 mask_file_name=*none*
 mask_file_offset=30
 flat_mask_active=False


OK - first problem is, as the error message indicated, line 1:

 Sentinel NC Configuration File Sentinel User 3 - 1/3/2009 (Meteor Software)

It's not a comment, it's not a real configuration item, so ConfigObj barfs.
Put a # in front of that, and we run just fine until:

 configobj.DuplicateError: Duplicate keyword name at line 26.

which is also correct - line 26 is a duplicate of line 3.  Put a # in
front of _that_, and we run just fine with the following result:


config_file_name = Initial.sen
mask_file_name = *none*
gray_scale = True
post_event_stack = False
post_event_format = Tiff 2
show_real_time = False
hourly_rate = 12
slowdown = 1
start_time = 20:00:12
stop_time = 06:03:00
lat = 40.0
long = 120.0
utc_offset = 8
elevation = 1000.0
site_name = Unknown
clock_drift = 0.0
zenith_x_pixel = 319
zenith_y_pixel = 239
north_angle_rotation = 0.0
events = Events
post_events = Post_Events
meteors = Meteor_Tags
composites = wtw:same as events?
flat_mask_val = 30
#mask_file_name=*none*
mask_file_offset = 30
flat_mask_active = False


(Once again, those are my own triple quotes) Notice that the first line has
been suppressed - if you want a comment to survive into the actual file,
you'll need to add it in the configspec; however, line 26 _did_ survive...
there's some mystery there, but I'm not going to kill myself over it.
I haven't modified the actual program or the configspec.  This illustrates
that the configspec dictates the bare minimum that the config file can
contain, not the maximum - any valid lines (of the format name = value)
that are in the config file but not in the spec will survive (and be
available to your program).


-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Wayne Watson
Title: Signature.html




Marc, I'm reaching back here, since something seems to have gone awry.
I'm looking at the code for Global_Config1.py. When I execute it from
IDLE, I get again:
...
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1637, in _parse
 ParseError, infile, cur_index)
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1748, in _handle_error
 raise error
ParseError: Invalid line at line "1". --- same old, same old

However, we know IDLE can goof up. So I thought I'd execute the code by
double clicking on the file. A black window appears briefly, then
disappears. I have raw_input and other tricks to see if I could slow it
down. Finally, I went to the MS Command prompt window, and executed
the py file from there. I get exactly the same message (s) as above. I
don't recall if you tried the program on your system. Comments?


Marc Tompkins wrote:

  On Wed, Feb 18, 2009 at 7:42 PM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
I took your "starter" code,
and formatted it to be what I hope is an
acceptable program, Gobal_Config.py. See attached. I'm using Python
2.5.2. I put the two modules in the same folder with it, and executed
it in IDLE. I got this:
 ...
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1637, in _parse
 ParseError, infile, cur_index)
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1748, in _handle_error
 raise error
ParseError: Invalid line at line "1".

As far as I can tell, line 1 of config.obj looks OK. It's a comment.
Something is amiss.

  
  
I hate to say it, but IDLE is really holding you back. It's convenient
because it installs automagically with Python, but it does funky,
confusing things - as in this case, where it's somehow stepped on the
real error and assigned blame in the wrong place; you've already
experienced its internal conflicts with Tkinter... I use wxPython for
my GUI goodness, and swear by SPE (Stani's Python Editor). I don't
want to re-ignite the IDE wars, but I definitely think you need to do
yourself a favor and move away from IDLE.
  
Anyway, I didn't mean for that to be a standalone program, but to be
picked apart into chunks and dropped into an existing program (or,
actually, just to be used as an example - maybe of what _not_ to do,
but an example...) 
First error: 
 if argv is None:
   argv = sys.argv == you haven't imported "sys"
  
Second error:
 app = MyApp(0) == you haven't defined a class called
"MyApp", so you can't do this...
  
So I cut it down to just this bit:
test = Global.cfgFile.validate(Global.vtor, copy=True)
Global.cfgFile.write()
  
(unindented all the way to the left, so that it executes as the main
body of the program) and it works just fine... except:
Third error (well, issue not error):
Take all my comments out! They weren't meant to be included in final
code. ConfigObj allows inline comments in your config file, and in the
configspec - so my comments show up in there too. Here's what
Initial.sen ends up looking like:
  
  mask_file_name = None
gray_scale = True
post_event_stack = False
post_event_format = Tiff 2
show_real_time = False
hourly_rate = 0
slowdown = 1 # I don't know what
# this value is/does, so this is probably wrong
start_time = 00:00:00 # or you could make the default None?
stop_time = 00:00:00
 # as a default latitude, if any...
  
I've cut everything down; I'm attaching it as Global_Config1.py (just
to avoid confusion with the earlier version). If you do actually want
to use it as the basis of anything, you'll want to place the call to
.validate() somewhere near the beginning of the action - remember, the
call to .write() just afterward is completely optional; I had it in
there for testing and have kept it in there for the same reason.
 

  
Does PYTHONPATH apply in Win
XP? I haven't played at the level of paths
for a long time in any OS. We can worry about an install "package"
later for the modules. It might be best for the users of this program. 

  
  
Ya know, I have no idea anymore. I thought I knew - but I just did a
SET from a command prompt, and I don't have a PYTHONPATH variable. I
seem to reacall something from a year or two ago... (looking now) Oh
yes - there's a directory under your Python directory (Python25 in my
case) called "Lib", and a folder under that called "site-packages"; any
text files with the extension ".pth" will be scaned for the names of
folders to add to the search path. As much as I love Python, I wish
they'd get all this together...
  
  
  
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) 

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Paul McGuire
Has anyone already mentioned the article in Python Magazine, May, 2008?

-- Paul

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Marc Tompkins
On Fri, Feb 20, 2009 at 9:45 AM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  Marc, I'm reaching back here, since something seems to have gone awry. I'm
 looking at the code for Global_Config1.py. When I execute it from IDLE, I
 get again:

 ...
   File
 C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py,
 line 1637, in _parse
 ParseError, infile, cur_index)
   File
 C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py,
 line 1748, in _handle_error
 raise error
 ParseError: Invalid line at line 1.   --- same old, same old

 However, we know IDLE can goof up. So I thought I'd execute the code by
 double clicking on the file. A black window appears briefly, then
 disappears. I have raw_input and other tricks to see if I could slow it
 down.  Finally, I went to the MS Command prompt window, and executed the py
 file from there. I get exactly the same message (s) as above. I don't recall
 if you tried the program on your system. Comments?


First: the line 1 it's talking about is the first line of the config file,
not of configobj.py.
Second: as written, there's no GUI here, so we _expect_ it to briefly show a
black window, then close - but when it's done, there should be a file called
Initial.sen in the current directory, which will look like this (this is
the output on my machine):


mask_file_name = None
gray_scale = True
post_event_stack = False
post_event_format = Tiff 2
show_real_time = False
hourly_rate = 0
slowdown = 1
start_time = 00:00:00
stop_time = 00:00:00


(I've added the triple quotes for visual clarity - they don't appear in the
actual file.)

I suspect that what's happening is that you already have a file called
Initial.sen, and its contents don't match the configspec.  So the ParseError
is an expected result - we either need to tweak the configspec to match your
previous file, or add exception handling, or (simplest) if you don't have
any real installed base, just start from scratch.

Do me two favors:
 - send your existing Initial.sen so I can look at modifying the configspec
or adding exception handling
 - delete or rename it, then try the program again.

-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Marc Tompkins
On Fri, Feb 20, 2009 at 10:45 AM, Paul McGuire pt...@austin.rr.com wrote:

 Has anyone already mentioned the article in Python Magazine, May, 2008?


No, I for one haven't seen it.  Is it available online, or only for
subscribers?


-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Wayne Watson
Title: Signature.html




Good. Thanks. It works fine for me now. I deleted the file. I just ran
the program again straight from the py file, and it put my the black
window with my raw_input prompt. It seems odd that it wouldn't have
left text debris when it crashed.

I've attached a copy of an Initial file. It's still under development,
but pretty close for the immediate purposes. The "_file_" names will
likely end up as a string showing the complete path to the file.
start/stop_time will be times in
the format shown, hh:mm:ss. The first line is just a header, and
currently gets tossed when the file is read. "_name" are strings. No
others have seen the program, so development continues. 



Marc Tompkins wrote:

  On Fri, Feb 20, 2009 at 9:45 AM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
Marc, I'm reaching back here,
since something seems to have gone awry.
I'm looking at the code for Global_Config1.py. When I execute it from
IDLE, I get again:

  ...
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1637, in _parse
 ParseError, infile, cur_index)
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1748, in _handle_error
 raise error
  
ParseError: Invalid line at line "1". --- same old, same old

However, we know IDLE can goof up. So I thought I'd execute the code by
double clicking on the file. A black window appears briefly, then
disappears. I have raw_input and other tricks to see if I could slow it
down. Finally, I went to the MS Command prompt window, and executed
the py file from there. I get exactly the same message (s) as above. I
don't recall if you tried the program on your system. Comments?

  
  
  
  
First: the line "1" it's talking about is the first line of the config
file, not of configobj.py.
Second: as written, there's no GUI here, so we _expect_ it to briefly
show a black window, then close - but when it's done, there should be a
file called "Initial.sen" in the current directory, which will look
like this (this is the output on my machine):
"""
  
mask_file_name = None
gray_scale = True
post_event_stack = False
post_event_format = Tiff 2
show_real_time = False
hourly_rate = 0
slowdown = 1
start_time = 00:00:00
stop_time = 00:00:00
 
"""
(I've added the triple quotes for visual clarity - they don't appear in
the actual file.)
  
I suspect that what's happening is that you already have a file called
Initial.sen, and its contents don't match the configspec. So the
ParseError is an expected result - we either need to tweak the
configspec to match your previous file, or add exception handling, or
(simplest) if you don't have any real installed base, just start from
scratch. 
  
Do me two favors: 
- send your existing Initial.sen so I can look at modifying the
configspec or adding exception handling
- delete or rename it, then try the program again.
  
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



Sentinel NC Configuration File Sentinel User 3 - 1/3/2009 (Meteor Software)
config_file_name=Initial.sen
mask_file_name=*none*
gray_scale=True
post_event_stack=False
post_event_format=Tiff 2
show_real_time=False
hourly_rate=12
slowdown=1
start_time=20:00:12
stop_time=06:03:00
lat=40.0
long=120.0
utc_offset=8
elevation=1000.0
site_name=Unknown
clock_drift=0.0
zenith_x_pixel=319
zenith_y_pixel=239
north_angle_rotation=0.0
events=Events
post_events=Post_Events
meteors=Meteor_Tags
composites=wtw:same as events?
flat_mask_val=30
mask_file_name=*none*
mask_file_offset=30
flat_mask_active=False
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Alan Gauld


Wayne Watson sierra_mtnv...@sbcglobal.net wrote

 I just ran the program again straight from the py file, 
and it put my the black window with my raw_input prompt.  


Thats why, when debugging, its often better to open the 
command window first and run the program from the 
OS prompt. That way you don't lose any text messages 
that may be written to the screen.


Alan G

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Wayne Watson
Title: Signature.html




Not because of this particular problem, but, out of curiosity, I tried
today to give the MS command line facility a shot. I think that's what
we are discussing here. I immediately ran into something of a problem.
My assumption was is was fully a DOS window. Trying to work my way to
folder was a bit daunting, since I have not used this in a very long
time, but this wasn't the problem. 

As it turns out, there was an easier way. Drag and drop the
path+program link into the window after placing a CD in the command
line. Very non-DOS*. :-) One could then backspace to remove the program
name, so the result was a CD to the program folder, where several
programs reside. Now the problem became one of typing in the name of
the program each time it was to be executed. With a pretty long path
name and the need to type in the file name on each use, it seemed a bit
tedious. Maybe there's another way?

* But yet, no copy and paste from the folder Address area

P.S. For some very odd reason, now when I press Reply, I get both the
poster's address and Tutor. It seems to come and go. Right now it
doesn't work, as I try it one other messages I see on screen. Very odd.

Alan Gauld wrote:

"Wayne Watson" sierra_mtnv...@sbcglobal.net wrote
  
  
  I just ran the program again straight from
the py file, and it put my the black window with my raw_input prompt. 
  
Thats why, when debugging, its often better to open the command window
first and run the program from the OS prompt. That way you don't lose
any text messages that may be written to the screen.
  
  
Alan G
  
  
___
  
Tutor maillist - Tutor@python.org
  
http://mail.python.org/mailman/listinfo/tutor
  
  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-20 Thread Marc Tompkins
On Fri, Feb 20, 2009 at 5:05 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  Not because of this particular problem, but, out of curiosity, I tried
 today to give the MS command line facility a shot. I think that's what we
 are discussing here. I immediately ran into something of a problem. My
 assumption was is was fully a DOS window.  Trying to work my way to folder
 was a bit daunting, since I have not used this in a very long time, but this
 wasn't the problem.

 As it turns out, there was an easier way. Drag and drop the path+program
 link into the window after placing a CD in the command line. Very non-DOS*.
 :-) One could then backspace to remove the program name, so the result was a
 CD to the program folder, where several programs reside. Now the problem
 became one of typing in the name of the program each time it was to be
 executed. With a pretty long path name and the need to type in the file name
 on each use, it seemed a bit tedious.  Maybe there's another way?

 * But yet, no copy and paste from the folder Address area


Two tips: Command Prompt Here and tab completion.

1) If you haven't already, check out the Windows XP PowerToys:
http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx
Most of them are useless (to me, anyway) but the two that are indispensible
- I install them on every (XP) machine I work on - are TweakUI and Command
Prompt Here.  It adds a Comand Prompt Here item to the menu when you
right-click on a folder.  I remember seeing a few articles explaining how to
do this yourself - but why bother?

2)  Tab completion is turned on by default in Windows XP - just type the
first few letters of the filename, and Windows will fill in the rest.  If
there are several files that start with what you typed, you might need to
add a few letters to get the right one, but it still saves lots and lots of
typing.  It even intelligently handles long filenames with spaces in them,
putting them in quotes when required.  If it's turned off on your machine,
you can turn it back on through TweakUI (see #1 above) under Command
Prompt.

So for example, you would right-click on your project folder, select Command
Prompt Here, type python  followed by G and a tab, then Enter.  (Or
maybe GL then Tab, or whatever - you get the drift.)

If you want a command prompt in your desktop folder, just right-click on a
folder on your desktop, select CPH, then type cd..  Much simpler than
Start/Run/cmd followed by cd \Documents and Settings\username\Desktop.

Copy and paste DOES work, but not with keyboard shortcuts (presumably, those
are intercepted by the command prompt itself) - right-click in the command
window and select Paste.
-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Wayne Watson
Title: Signature.html




Hi, actually I had two aims with the pseudo code, 1. print it, and 2.
check to see if it would pull in the two modules. I pulled it into
Word, and quickly formatted it to get the line wrap out, and put it in
some sort of readable format. After that, I thought why not just take
it as it was, and scoop it into IDLE. My plan was to right a test
program to get a better understanding of how to use ConfigObj rather
than just try it through the program I plan to use it in. 

I've tried to keep to IDLE for no reason other than the author
recommended it. Well, OK, I had gotten comfortable with the editor.
I'll try wxPython.

I took a quick look look at where Python was installed and found it was
directly under C:, and not under Program Files. That's a surprise. Now
I recall where I found something about classes and paths. It's on the
File menu of IDLE, Class Browser and Path Browser. 

I thought, in the last post, I asked about items like: show_real_time =
boolean(default=False) and hourly_rate = integer(min=0, default=0);
but, apparently, I accidentally knocked it out. Anyway, here's the
question. Where is the syntax for items like boolean, integer, and
others described? The doc I have barely refers to them. 

Off to find wx...

Marc Tompkins wrote:

  On Wed, Feb 18, 2009 at 7:42 PM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
I took your "starter" code,
and formatted it to be what I hope is an
acceptable program, Gobal_Config.py. See attached. I'm using Python
2.5.2. I put the two modules in the same folder with it, and executed
it in IDLE. I got this:
 ...
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1637, in _parse
 ParseError, infile, cur_index)
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1748, in _handle_error
 raise error
ParseError: Invalid line at line "1".

As far as I can tell, line 1 of config.obj looks OK. It's a comment.
Something is amiss.

  
  
I hate to say it, but IDLE is really holding you back. It's convenient
because it installs automagically with Python, but it does funky,
confusing things - as in this case, where it's somehow stepped on the
real error and assigned blame in the wrong place; you've already
experienced its internal conflicts with Tkinter... I use wxPython for
my GUI goodness, and swear by SPE (Stani's Python Editor). I don't
want to re-ignite the IDE wars, but I definitely think you need to do
yourself a favor and move away from IDLE.
  
Anyway, I didn't mean for that to be a standalone program, but to be
picked apart into chunks and dropped into an existing program (or,
actually, just to be used as an example - maybe of what _not_ to do,
but an example...) 
First error: 
 if argv is None:
   argv = sys.argv == you haven't imported "sys"
  
Second error:
 app = MyApp(0) == you haven't defined a class called
"MyApp", so you can't do this...
  
So I cut it down to just this bit:
test = Global.cfgFile.validate(Global.vtor, copy=True)
Global.cfgFile.write()
  
(unindented all the way to the left, so that it executes as the main
body of the program) and it works just fine... except:
Third error (well, issue not error):
Take all my comments out! They weren't meant to be included in final
code. ConfigObj allows inline comments in your config file, and in the
configspec - so my comments show up in there too. Here's what
Initial.sen ends up looking like:
  
  mask_file_name = None
gray_scale = True
post_event_stack = False
post_event_format = Tiff 2
show_real_time = False
hourly_rate = 0
slowdown = 1 # I don't know what
# this value is/does, so this is probably wrong
start_time = 00:00:00 # or you could make the default None?
stop_time = 00:00:00
 # as a default latitude, if any...
  
I've cut everything down; I'm attaching it as Global_Config1.py (just
to avoid confusion with the earlier version). If you do actually want
to use it as the basis of anything, you'll want to place the call to
.validate() somewhere near the beginning of the action - remember, the
call to .write() just afterward is completely optional; I had it in
there for testing and have kept it in there for the same reason.
 

  
Does PYTHONPATH apply in Win
XP? I haven't played at the level of paths
for a long time in any OS. We can worry about an install "package"
later for the modules. It might be best for the users of this program. 

  
  
Ya know, I have no idea anymore. I thought I knew - but I just did a
SET from a command prompt, and I don't have a PYTHONPATH variable. I
seem to reacall something from a year or two ago... (looking now) Oh
yes - there's a directory under your Python directory (Python25 in my
case) called "Lib", and a folder under that called "site-packages"; any
text files with the extension ".pth" will be scaned for the names of
folders to add to the search path. As much as I love Python, I wish
they'd get all this 

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Wayne Watson




I now have wxPython, IDLE and Vim installed. IDLE didn't disappear
during the wx install. It looks as though wxPython re-compiled library
files. I'll be exploring vim now. 

Wayne Watson wrote:

  
Hi, actually I had two aims with the pseudo code, 1. print it, and 2.
check to see if it would pull in the two modules. I pulled it into
Word, and quickly formatted it to get the line wrap out, and put it in
some sort of readable format. After that, I thought why not just take
it as it was, and scoop it into IDLE. My plan was to right a test
program to get a better understanding of how to use ConfigObj rather
than just try it through the program I plan to use it in. 
  
I've tried to keep to IDLE for no reason other than the author
recommended it. Well, OK, I had gotten comfortable with the editor.
I'll try wxPython.
  
I took a quick look look at where Python was installed and found it was
directly under C:, and not under Program Files. That's a surprise. Now
I recall where I found something about classes and paths. It's on the
File menu of IDLE, Class Browser and Path Browser. 
  
I thought, in the last post, I asked about items like: show_real_time =
boolean(default=False) and hourly_rate = integer(min=0, default=0);
but, apparently, I accidentally knocked it out. Anyway, here's the
question. Where is the syntax for items like boolean, integer, and
others described? The doc I have barely refers to them. 
  
Off to find wx...


-- 

Signature.html
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/




___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Marc Tompkins
On Thu, Feb 19, 2009 at 4:51 AM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  Hi, actually I had two aims with the pseudo code, 1. print it, and 2.
 check to see if it would pull in the two modules. I pulled it into Word, and
 quickly formatted it to get the line wrap out, and put it in some sort of
 readable format. After that, I thought why not just take it as it was, and
 scoop it into IDLE.  My plan was to right a test program to get a better
 understanding of how to use ConfigObj rather than just try it through the
 program I plan to use it in.

 I've tried to keep to IDLE for no reason other than the author recommended
 it. Well, OK, I had gotten comfortable with the editor.  I'll try wxPython.


I wasn't very clear (and I shouldn't have mentioned wx at all, for
clarity!)  wxPython is not an alternative to IDLE, it's an alternative to
Tkinter.  SPE happens to have been written using wx (as IDLE uses Tkinter).
As I say, I should have left wx out of that... my point was that IDLE was
messing with the error somewhow and leading you to think it was a problem
with ConfigObj, when in fact it was probably the missing import sys.
Since IDLE does that sort of thing A LOT, and also has known issues with
Tkinter (which you've experienced firsthand), I thought I'd slip in a gentle
suggestion to change tools.



 I took a quick look look at where Python was installed and found it was
 directly under C:, and not under Program Files. That's a surprise. Now I
 recall where I found something about classes and paths. It's on the File
 menu of IDLE, Class Browser and Path Browser.

 I thought, in the last post, I asked about items like: show_real_time =
 boolean(default=False) and hourly_rate = integer(min=0, default=0); but,
 apparently, I accidentally knocked it out.  Anyway, here's the question.
 Where is the syntax for items like boolean,  integer, and others described?
 The doc I have barely refers to them.


I posted it a few messages back - here's the link again:
http://www.voidspace.org.uk/python/validate.html
In particular you want this section:
http://www.voidspace.org.uk/python/validate.html#the-standard-functions


-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Marc Tompkins
On Thu, Feb 19, 2009 at 9:58 AM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  I now have wxPython, IDLE and Vim installed. IDLE didn't disappear during
 the wx install.  It looks as though wxPython re-compiled library files. I'll
 be exploring vim now.


wxPython doesn't replace or remove anything - I still have IDLE on my
machine, I just don't use it.  The wxPython installer wasn't re-compiling
Python - it was using Python to compile its own scripts for use on your
machine.

Once again, to be clear: wxPython is an alternative to Tkinter, not to IDLE
- it's a different toolkit for creating GUI applications.
The upsides:
 - it's a good deal more sophisticated and powerful (I feel) than Tkinter,
and the apps you produce using it will look a lot more native (on Windows,
they'll look like Windows apps; on OS X they'll have the Apple look and
feel, etc.) and therefore more professional/less hobbyist-like.
 - the syntax of working with wxPython widgets feels more Pythonic (to me).
It's a matter of personal taste, but I tried Tkinter for a few days and
hated it; I tried wxPython and got hooked.
The downsides:
 - it's not part of Python proper, so it's an extra dependency (although
there's a great install-package creator called Gui2Exe that will bundle your
program along with Python and all other dependencies into a Windows-style
installer, so you can distribute just one file to your potential users.)
 - it's not part of Python proper, so most tutorials/Python books barely
mention its existence.  There's (1) excellent book, wxPython in Action, a
couple of very active mailing lists, an excellent and gigantic demo program
with sample code for almost every widget, and Google.  Other than that,
you're on your own.
-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Wayne Watson
Title: Signature.html




Ok, I now understand the role of wx. I'm going to un-install wx. I want
to keep this program as close to the original as I can, which means I
will use Tkinter from here on out. GUIs of different sorts seem to be
a burgeoning industry. 

I'm willing to give vim a shot. I believe in an earlier thread
unrelated to this, Alan suggested it. I'm perhaps incorrectly assuming
vim will take care of the Tkinter problem. If these editors aren't
really the source of some the error reporting problem, then I'm going
to have to come up with new thinking or some tactic that will get to
the real errors. If there is an influence of the editors, then I would
think it has something to do with the interface to Python, so it comes
down to which editor has the best or most stable interface with
Python. When Alan suggested it, there was something about the apparent
awkwardness of executing the code, which made me pass on it. I'm going
back to find out what that was. 

Yep, I missed this in your other post:
"In particular you want this section: http://www.voidspace.org.uk/python/validate.html#the-standard-functions"

Marc Tompkins wrote:

  On Thu, Feb 19, 2009 at 9:58 AM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
I now have wxPython, IDLE and
Vim installed. IDLE didn't disappear
during the wx install. It looks as though wxPython re-compiled library
files. I'll be exploring vim now. 


  
  
  
wxPython doesn't replace or remove anything - I still have IDLE on my
machine, I just don't use it. The wxPython installer wasn't
re-compiling Python - it was using Python to compile its own scripts
for use on your machine.
  
Once again, to be clear: wxPython is an alternative to Tkinter, not to
IDLE - it's a different toolkit for creating GUI applications. 
The upsides:
- it's a good deal more sophisticated and powerful (I feel) than
Tkinter, and the apps you produce using it will look a lot more
"native" (on Windows, they'll look like Windows apps; on OS X they'll
have the Apple look and feel, etc.) and therefore more
professional/less hobbyist-like. 
- the syntax of working with wxPython widgets feels more Pythonic (to
me). It's a matter of personal taste, but I tried Tkinter for a few
days and hated it; I tried wxPython and got hooked.
The downsides: 
- it's not part of Python proper, so it's an extra dependency
(although there's a great install-package creator called Gui2Exe that
will bundle your program along with Python and all other dependencies
into a Windows-style installer, so you can distribute just one file to
your potential users.)
- it's not part of Python proper, so most tutorials/Python books
barely mention its existence. There's (1) excellent book, "wxPython in
Action", a couple of very active mailing lists, an excellent and
gigantic demo program with sample code for almost every widget, and
Google. Other than that, you're on your own.
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Marc Tompkins
On Thu, Feb 19, 2009 at 10:59 AM, Wayne Watson sierra_mtnv...@sbcglobal.net
 wrote:


 I'm willing to give vim a shot. I believe in an earlier thread unrelated to
 this, Alan suggested it. I'm perhaps incorrectly assuming vim will take care
 of the Tkinter problem. If these editors aren't really the source of some
 the error reporting problem, then I'm going to have to come up with new
 thinking or some tactic that will get to the real errors. If there is an
 influence of the editors, then I would think it has something to do with the
 interface to Python, so it comes down to which editor has the best or most
 stable interface with Python.  When Alan suggested it, there was something
 about the apparent awkwardness of executing the code, which made me pass on
 it. I'm going back to find out what that was.


The problem is not with IDLE as an editor, but with IDLE as a shell.
You can edit your code in any editor, and as long as it doesn't slip funky
hidden characters into your file (not an issue with any normal text editor
AFAIK, but you definitely don't want to use Word!) it will make NO
difference to your code.  The problem with IDLE is that it tries to be an
IDE (Integrated Development Environment - in other words, you can edit the
code, execute it, debug it, get rudimentary language help all in one
program) and it does a p#$$-poor job of it.  Alan's advice is to avoid the
IDE approach and get used to editing your program in one window and running
it in another - after all, that's how your users will see it.  And it's good
advice and a valid approach.  Myself, I like using an IDE - the one thing I
used to like about using Visual Studio was the integration.  So I use SPE,
which is an IDE and (IMHO) a good one.  It does not matter in the slightest
which tool you use, as long as that tool does not get in your way.

(Actually, I may be misrepresenting Alan and Vim a bit - I don't use it
myself.  You can run external programs from inside of vim, so Alan's desktop
may look more like a traditional IDE than I'm imagining.)
-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-19 Thread Wayne Watson




Actually, I had gotten comfortable with using IDLE a few weeks ago, and
just put a short cut to the program within easy reach. I'd edit then
execute with the icon. One day, I happened to hit F5 and it executed
the program properly. Somehow I drifted back to the old way,
unsuspectingly. Not good. Maybe there's a way to disable F5!!! Maybe
it's just too close to F3! 

Marc Tompkins wrote:

  On Thu, Feb 19, 2009 at 10:59 AM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
  
I'm willing to give vim a
shot. I believe in an earlier thread
unrelated to this, Alan suggested it. I'm perhaps incorrectly assuming
vim will take care of the Tkinter problem. If these editors aren't
really the source of some the error reporting problem, then I'm going
to have to come up with new thinking or some tactic that will get to
the real errors. If there is an influence of the editors, then I would
think it has something to do with the interface to Python, so it comes
down to which editor has the best or most stable interface with
Python. When Alan suggested it, there was something about the apparent
awkwardness of executing the code, which made me pass on it. I'm going
back to find out what that was. 

  
  
The problem is not with IDLE as an editor, but with IDLE as a shell.
You can edit your code in any editor, and as long as it doesn't slip
funky hidden characters into your file (not an issue with any normal
text editor AFAIK, but you definitely don't want to use Word!) it will
make NO difference to your code. The problem with IDLE is that it
tries to be an IDE (Integrated Development Environment - in other
words, you can edit the code, execute it, debug it, get rudimentary
language help all in one program) and it does a p#$$-poor job of it.
Alan's advice is to avoid the IDE approach and get used to editing your
program in one window and running it in another - after all, that's how
your users will see it. And it's good advice and a valid approach.
Myself, I like using an IDE - the one thing I used to like about using
Visual Studio was the integration. So I use SPE, which is an IDE and
(IMHO) a good one. It does not matter in the slightest which tool you
use, as long as that tool does not get in your way.
  
  
  
(Actually, I may be misrepresenting Alan and Vim a bit - I don't use it
myself. You can run external programs from inside of vim, so Alan's
desktop may look more like a traditional IDE than I'm imagining.)
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
  


-- 

Signature.html
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Marc Tompkins
On Wed, Feb 18, 2009 at 7:30 AM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  See Subject. I've run across a 58 page document
 http://www.voidspace.org.uk/python/configobj.htmlhttp://www.voidspace.org.uk/python/configobj.html,
 but am uncertain of its applicability to my present needs (see my thread on
 Changing the Attribute). Usually, I end up with some 3-4 page document, so
 this raises an eyebrow. Am I on the right trail? In the meantime, I think
 I'll turn it into a more manageable pdf file before putting it to paper.


It's a very powerful module - does lots of things you don't need yet, and
maybe never will - and I agree that it could benefit from a
hit-the-ground-running guide...

Here's a quick-and-dirty; you can flesh out the details from the
documentation you downloaded.  (By the way, you'll also want to use the
validate module - another 14 pages or so...)
==
* Download configobj.py and validate.py; put them somewhere in your
Python path (or in the same folder as your project, if you want)
* Add two lines to the top of your program:
from configobj import ConfigObj
from validate import Validator
* To make working with your spec easier,
import StringIO  # allows you to work with strings as if they were
files
# You could just create a spec file, and open it normally, but this
keeps everything in one place.
* Somewhere in your program, create your spec and load it.  There are a
lot of ways you can do this - for me, the simple thing is to put it in a
class.  I create a class called Global - it's a crutch, I know...
class Global(object):
cfgFileName = os.getcwd() + os.sep + 'Initial.sen' # current
directory + \ + filename - but you could put it anywhere and call it
anything
# create your spec as a multi-line string between triple quotes
tmpStr = 
mask_file_name = string(default=None)
gray_scale = boolean(default=True)
post_event_stack = boolean(default=False)
post_event_format = string(default=Tiff 2)
show_real_time = boolean(default=False)
hourly_rate = integer(min=0, default=0)
slowdown= integer(min=0, max=10, default=1) # I don't know what
this value is/does, so this is probably wrong
start_time = string(default=00:00:00) # or you could make the
default None?
stop_time = string(default=00:00:00)
lat = float(min=0.0, max=90.0) # I have no idea what you'd want
as a default latitude, if any...


cfgSpec = StringIO.StringIO(tmpStr) # turns the above string
into a file-like object, which ConfigObj is expecting
cfgFile = ConfigObj(cfgFileName,
configspec=cfgSpec, raise_errors=True,
write_empty_values=True,
create_empty=True, indent_type='',
list_values=True) # creates the actual ConfigObj object
vtor = Validator() # creates a validator to match your config
data against your spec
* Invoke the above code when your program starts - I do it just before
my mainloop, like so:
def main(argv=None):
if argv is None:
argv = sys.argv
test = Global.cfgFile.validate(Global.vtor, copy=True) # tries
to load cfgFile; if it doesn't exist, creates it; fills in defaults for any
missing values
Global.cfgFile.write() # saves the validated file (you don't
need to do this here at the start, but I usually do)
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
main()
* Your ConfigObj is ready to use!  Simply access the contents like a
regular dictionary.  To save back to the file, call the write() method.
Global.cfgFile['mask_file_name'] = 'bogus.txt'
Global.cfgFile.write()

maskFile = Global.cfgFile['mask_file_name']
* Or use the values directly without copying to intermediate variables:
with open(Global.cfgFile['mask_file_name'], 'w+b') as maskFile:
maskFile.write('some bogus text')
==
I'm attaching that as a text file too - I suspect that my indentation won't
survive the trip...

My Global class is an ugly hack.  I'm sure you'll come up with something
more aesthetically pleasing...
ConfigObj has lots of very cool features - sections, repeated sections,
custom input validators - that's what the 50+ pages of documentation are
about.  When you need that stuff, it's available.
-- 
www.fsrtechnologies.com

* Download configobj.py and validate.py; put them somewhere in your Python 
path (or in the same folder as your project, if you want)
* Add two lines to the top of your program: 
from configobj import ConfigObj
from validate import Validator
* To make working with your spec easier, 
import StringIO  # allows you 

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Wayne Watson
Title: Signature.html




OK, I got the ObjectConfig and Validate downloads, and copied your
Global class successfully. Don't I need to get the two files into
Python as a module? How does that work?

Marc Tompkins wrote:

  On Wed, Feb 18, 2009 at 7:30 AM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
See Subject. I've run across
a 58 page document
http://www.voidspace.org.uk/python/configobj.html,
but am
uncertain of its applicability to my present needs (see my thread on
"Changing the Attribute"). Usually, I end up with some 3-4 page
document, so this raises an eyebrow. Am I on the right trail? In the
meantime, I think I'll turn it into a more manageable pdf file before
putting it to paper. 
  
  
It's a very powerful module - does lots of things you don't need yet,
and maybe never will - and I agree that it could benefit from a
hit-the-ground-running guide...
  
Here's a quick-and-dirty; you can flesh out the details from the
documentation you downloaded. (By the way, you'll also want to use the
validate module - another 14 pages or so...)
==
 * Download configobj.py and validate.py; put them somewhere in your
Python path (or in the same folder as your project, if you want)
 * Add two lines to the top of your program: 
 from configobj import ConfigObj
 from validate import Validator
 * To make working with your spec easier, 
 import StringIO # allows you to work with strings as if they
were files
 # You could just create a spec file, and open it normally, but
this keeps everything in one place.
 * Somewhere in your program, create your spec and load it. There
are a lot of ways you can do this - for me, the simple thing is to put
it in a class. I create a class called Global - it's a crutch, I
know...
 class Global(object): 
 cfgFileName = os.getcwd() + os.sep + 'Initial.sen' #
current directory + "\" + filename - but you could put it anywhere and
call it anything
 # create your spec as a multi-line string between triple
quotes
 tmpStr = """
 mask_file_name = string(default=None)
 gray_scale = boolean(default=True)
 post_event_stack = boolean(default=False)
 post_event_format = string(default="Tiff 2")
 show_real_time = boolean(default=False)
 hourly_rate = integer(min=0, default=0)
 slowdown= integer(min=0, max=10, default=1) # I don't know
what this value is/does, so this is probably wrong
 start_time = string(default="00:00:00") # or you could make
the default None?
 stop_time = string(default="00:00:00")
 lat = float(min=0.0, max=90.0) # I have no idea what you'd
want as a default latitude, if any...
  
 """
 cfgSpec = StringIO.StringIO(tmpStr) # turns the above
string into a file-like object, which ConfigObj is expecting
 cfgFile = ConfigObj(cfgFileName, 
 configspec=cfgSpec, raise_errors=True,
write_empty_values=True, 
 create_empty=True, indent_type=' ',
list_values=True) # creates the actual ConfigObj object
 vtor = Validator() # creates a validator to match your
config data against your spec
 * Invoke the above code when your program starts - I do it just
before my mainloop, like so:
 def main(argv=None):
 if argv is None:
 argv = sys.argv
 test = Global.cfgFile.validate(Global.vtor, copy=True) #
tries to load cfgFile; if it doesn't exist, creates it; fills in
defaults for any missing values
 Global.cfgFile.write() # saves the validated file (you
don't need to do this here at the start, but I usually do)
 app = MyApp(0) 
 app.MainLoop()
 if __name__ == '__main__':
 main()
 * Your ConfigObj is ready to use! Simply access the contents like
a regular dictionary. To save back to the file, call the write()
method.
 Global.cfgFile['mask_file_name'] = 'bogus.txt'
 Global.cfgFile.write()
 
 maskFile = Global.cfgFile['mask_file_name']
 * Or use the values directly without copying to intermediate
variables:
 with open(Global.cfgFile['mask_file_name'], 'w+b') as maskFile:
 maskFile.write('some bogus text')
==
I'm attaching that as a text file too - I suspect that my indentation
won't survive the trip...
  
My Global class is an ugly hack. I'm sure you'll come up with
something more aesthetically pleasing...
  
  
ConfigObj has lots of very cool features - sections, repeated sections,
custom input validators - that's what the 50+ pages of documentation
are about. When you need that stuff, it's available.
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/




___
Tutor maillist  -  Tutor@python.org

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Marc Tompkins
On Wed, Feb 18, 2009 at 1:01 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  OK, I got the ObjectConfig and Validate downloads, and copied your Global
 class successfully. Don't I need to get the two files into Python as a
 module? How does that work?


Simplest: put them in the same folder as your own program.  More standard:
put them in one of the folders in your Python path - same general idea as
the DOS search path, it's a list of directories where Python will look for
modules you ask it to import.

From the docs: (http://docs.python.org/tutorial/modules.html)
The Module Search
Path¶http://docs.python.org/tutorial/modules.html#the-module-search-path

When a module named spam is imported, the interpreter searches for a file
named spam.py in the current directory, and then in the list of directories
specified by the environment variable
*PYTHONPATH*http://docs.python.org/using/cmdline.html#envvar-PYTHONPATH.
This has the same syntax as the shell variable *PATH*, that is, a list of
directory names. When
*PYTHONPATH*http://docs.python.org/using/cmdline.html#envvar-PYTHONPATHis
not set, or when the file is not found there, the search continues in
an
installation-dependent default path; on Unix, this is usually
.:/usr/local/lib/python.

Actually, modules are searched in the list of directories given by the
variable sys.path which is initialized from the directory containing the
input script (or the current directory),
*PYTHONPATH*http://docs.python.org/using/cmdline.html#envvar-PYTHONPATHand
the installation- dependent default. This allows Python programs that
know what they're doing to modify or replace the module search path. Note
that because the directory containing the script being run is on the search
path, it is important that the script not have the same name as a standard
module, or Python will attempt to load the script as a module when that
module is imported. This will generally be an error. See section *Standard
Modules* http://docs.python.org/tutorial/modules.html#tut-standardmodulesfor
more information.




 Marc Tompkins wrote:

 On Wed, Feb 18, 2009 at 7:30 AM, Wayne Watson 
 sierra_mtnv...@sbcglobal.net wrote:

 See Subject. I've run across a 58 page document
 http://www.voidspace.org.uk/python/configobj.htmlhttp://www.voidspace.org.uk/python/configobj.html,
 but am uncertain of its applicability to my present needs (see my thread on
 Changing the Attribute). Usually, I end up with some 3-4 page document, so
 this raises an eyebrow. Am I on the right trail? In the meantime, I think
 I'll turn it into a more manageable pdf file before putting it to paper.


 It's a very powerful module - does lots of things you don't need yet, and
 maybe never will - and I agree that it could benefit from a
 hit-the-ground-running guide...

 Here's a quick-and-dirty; you can flesh out the details from the
 documentation you downloaded.  (By the way, you'll also want to use the
 validate module - another 14 pages or so...)
 ==
 * Download configobj.py and validate.py; put them somewhere in your
 Python path (or in the same folder as your project, if you want)
 * Add two lines to the top of your program:
 from configobj import ConfigObj
 from validate import Validator
 * To make working with your spec easier,
 import StringIO  # allows you to work with strings as if they were
 files
 # You could just create a spec file, and open it normally, but this
 keeps everything in one place.
 * Somewhere in your program, create your spec and load it.  There are a
 lot of ways you can do this - for me, the simple thing is to put it in a
 class.  I create a class called Global - it's a crutch, I know...
 class Global(object):
 cfgFileName = os.getcwd() + os.sep + 'Initial.sen' # current
 directory + \ + filename - but you could put it anywhere and call it
 anything
 # create your spec as a multi-line string between triple quotes
 tmpStr = 
 mask_file_name = string(default=None)
 gray_scale = boolean(default=True)
 post_event_stack = boolean(default=False)
 post_event_format = string(default=Tiff 2)
 show_real_time = boolean(default=False)
 hourly_rate = integer(min=0, default=0)
 slowdown= integer(min=0, max=10, default=1) # I don't know what
 this value is/does, so this is probably wrong
 start_time = string(default=00:00:00) # or you could make the
 default None?
 stop_time = string(default=00:00:00)
 lat = float(min=0.0, max=90.0) # I have no idea what you'd want
 as a default latitude, if any...

 
 cfgSpec = StringIO.StringIO(tmpStr) # turns the above string
 into a file-like object, which ConfigObj is expecting
 cfgFile = ConfigObj(cfgFileName,
 configspec=cfgSpec, raise_errors=True,
 

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Wayne Watson
Title: Signature.html




Thanks. I recall installing several libraries though, where somehow
they were packaged to automatically install when opened. 

In the http://www.voidspace.org.uk/python/configobj.html
description, I do not see much of an explanations of examples of items
like, integer(min=0, default=0). It looks like they may be called
configspecs. I see this in section 5.3.2.2.
key1 = integer(0, 30, default=15)
key2 = integer(default=15)
key3 = boolean(default=True)
key4 = option('Hello', 'Goodbye', 'Not Today', default='Not Today')

but not much else. Validators? Are there others like integer, booleand
and option? Items like start_time would then be called keywords?

Marc Tompkins wrote:

  On Wed, Feb 18, 2009 at 1:01 PM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
OK, I got the ObjectConfig
and Validate downloads, and copied your
Global class successfully. Don't I need to get the two files into
Python as a module? How does that work?

  
  
Simplest: put them in the same folder as your own program. More
standard: put them in one of the folders in your Python path - same
general idea as the DOS search path, it's a list of directories where
Python will look for modules you ask it to import.
  
From the docs: (http://docs.python.org/tutorial/modules.html)
  The Module Search Path
  When a module named spam is
imported, the interpreter searches for a file
named spam.py
in the current directory, and then in the list of
directories specified by the environment variable PYTHONPATH. This
has the same syntax as the shell variable PATH, that is, a
list of
directory names. When PYTHONPATH is not set, or when the file is
not
found there, the search continues in an installation-dependent default
path; on
Unix, this is usually .:/usr/local/lib/python.
  Actually, modules are searched in the list of directories given by
the variable sys.path
which is initialized from the directory containing the input script
(or the current directory), PYTHONPATH and the installation- dependent
default. This allows Python programs that know what they're doing to
modify or
replace the module search path. Note that because the directory
containing the
script being run is on the search path, it is important that the script
not have
the same name as a standard module, or Python will attempt to load the
script as
a module when that module is imported. This will generally be an error.
See
section Standard
Modules for more information.
  

  

Marc Tompkins wrote:

  
  
  On Wed, Feb 18, 2009 at 7:30 AM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
See Subject. I've run
across
a 58 page document http://www.voidspace.org.uk/python/configobj.html,
but am
uncertain of its applicability to my present needs (see my thread on
"Changing the Attribute"). Usually, I end up with some 3-4 page
document, so this raises an eyebrow. Am I on the right trail? In the
meantime, I think I'll turn it into a more manageable pdf file before
putting it to paper. 
  
  
It's a very powerful module - does lots of things you don't need yet,
and maybe never will - and I agree that it could benefit from a
hit-the-ground-running guide...
  
Here's a quick-and-dirty; you can flesh out the details from the
documentation you downloaded. (By the way, you'll also want to use the
validate module - another 14 pages or so...)
==
 * Download configobj.py and validate.py; put them somewhere in your
Python path (or in the same folder as your project, if you want)
 * Add two lines to the top of your program: 
 from configobj import ConfigObj
 from validate import Validator
 * To make working with your spec easier, 
 import StringIO # allows you to work with strings as if they
were files
 # You could just create a spec file, and open it normally, but
this keeps everything in one place.
 * Somewhere in your program, create your spec and load it. There
are a lot of ways you can do this - for me, the simple thing is to put
it in a class. I create a class called Global - it's a crutch, I
know...
 class Global(object): 
 cfgFileName = os.getcwd() + os.sep + 'Initial.sen' #
current directory + "\" + filename - but you could put it anywhere and
call it anything
 # create your spec as a multi-line string between triple
quotes
 tmpStr = """
 mask_file_name = string(default=None)
 gray_scale = boolean(default=True)
 post_event_stack = boolean(default=False)
 post_event_format = string(default="Tiff 2")
 show_real_time = boolean(default=False)
 hourly_rate = integer(min=0, default=0)
 slowdown= integer(min=0, max=10, default=1) # I don't know
what this value is/does, so this is probably wrong
 start_time = string(default="00:00:00") # or you could make
the default None?
 stop_time = string(default="00:00:00")
 lat = float(min=0.0, max=90.0) # I have no idea what you'd
want as a default latitude, if any...
  
 """
 cfgSpec = StringIO.StringIO(tmpStr) # turns the 

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Marc Tompkins
On Wed, Feb 18, 2009 at 2:57 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  Thanks. I recall installing several libraries though, where somehow they
 were packaged to automatically install when opened.

 In the 
 http://www.voidspace.org.uk/python/configobj.htmlhttp://www.voidspace.org.uk/python/configobj.htmldescription,
  I do not see much of an explanations of examples of items like,
 integer(min=0, default=0). It looks like they may be called configspecs. I
 see this in section 5.3.2.2.

 key1 = integer(0, 30, default=15)
 key2 = integer(default=15)
 key3 = boolean(default=True)
 key4 = option('Hello', 'Goodbye', 'Not Today', default='Not Today')

 but not much else. Validators? Are there others like integer, booleand and
 option?  Items like start_time would then be called keywords?

The configspec (configuration specification) is that thing I put inside of
triple quotes.  It's basically a template of what your config file will look
like once it has actual data in it.

In 5.3.2, the sentence The validate method uses the
validatehttp://www.voidspace.org.uk/python/validate.htmlmodule to do
the validation links to the validate.py documentation - but
you won't see that if you're reading it on paper...

Remember I said there's a bunch of stuff there you might not need just now?
A good deal of it has to do with extending ConfigObj for your own twisted,
nefarious purposes (bwahahahahaha!) - you can write your own validators for
just about any kind of values you can imagine.  However, just to get
started, the built-ins are probably good (from the validate.py doc,
http://www.voidspace.org.uk/python/validate.html#the-standard-functions):




The standard functions come built-in to every Validator instance. They work
with the following basic data types :

   - integer
   - float
   - boolean
   - string
   - ip_addr

plus lists of these datatypes.

Adding additional checks is done through coding simple functions.

The full set of standard checks are :
  'integer':

matches integer values (including negative). Takes optional 'min' and 'max'
arguments :

integer()
integer(3, 9)# any value from 3 to 9
integer(min=0) # any positive value
integer(max=9)

 'float':

matches float values Has the same parameters as the integer check.
 'boolean':matches boolean values: True or False.

Acceptable string values for True are :

true, on, yes, 1

 Acceptable string values for False are :

false, off, no, 0

Any other value raises an error.
 'string':

matches any string. Takes optional keyword args 'min' and 'max' to specify
min and max length of string.
 'ip_addr':

matches an Internet Protocol address, v.4, represented by a dotted-quad
string, i.e. '1.2.3.4'.
 'list':

matches any list. Takes optional keyword args 'min', and 'max' to specify
min and max sizes of the list. The list checks always return a list.
 'tuple':

matches any list. This check returns a tuple rather than a list.
 'int_list':

Matches a list of integers. Takes the same arguments as list.
 'float_list':

Matches a list of floats. Takes the same arguments as list.
 'bool_list':

Matches a list of boolean values. Takes the same arguments as list.
 'string_list':

Matches a list of strings. Takes the same arguments as list.
 'ip_addr_list':

Matches a list of IP addresses. Takes the same arguments as list.
 'mixed_list':

Matches a list with different types in specific positions. List size must
match the number of arguments.

Each position can be one of :

int, str, boolean, float, ip_addr

So to specify a list with two strings followed by two integers, you write
the check as :

mixed_list(str, str, int, int)

 'pass':

matches everything: it never fails and the value is unchanged. It is also
the default if no check is specified.
 'option':

matches any from a list of options. You specify this test with :

option('option 1', 'option 2', 'option 3')

  ===


-- 
www.fsrtechnologies.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Wayne Watson
Title: Signature.html




I took your "starter" code, and formatted it to be what I hope is an
acceptable program, Gobal_Config.py. See attached. I'm using Python
2.5.2. I put the two modules in the same folder with it, and executed
it in IDLE. I got this:
 ...
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1637, in _parse
 ParseError, infile, cur_index)
 File
"C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py",
line 1748, in _handle_error
 raise error
ParseError: Invalid line at line "1".

As far as I can tell, line 1 of config.obj looks OK. It's a comment.
Something is amiss.

Does PYTHONPATH apply in Win XP? I haven't played at the level of paths
for a long time in any OS. We can worry about an install "package"
later for the modules. It might be best for the users of this program. 

When I was using Python 2.4, I could find an entry on Start for it, and
get an item on it under Python 2.4 called something like Library Paths.
I don't see that at all on Python 2.5. Bad memory, I just checked on my
laptop, which has 2.4; however, I recall being able to probe Python
library paths. This may be irrelevant.

The ConfigObj 4 Introduction and Ref doc doesn't seem to associate it
with any version of Python. Its version is 4.5.3. Puzzled ...

Marc Tompkins wrote:

  On Wed, Feb 18, 2009 at 1:01 PM, Wayne
Watson sierra_mtnv...@sbcglobal.net
wrote:
  
OK, I got the ObjectConfig
and Validate downloads, and copied your
Global class successfully. Don't I need to get the two files into
Python as a module? How does that work?

  
  
Simplest: put them in the same folder as your own program. More
standard: put them in one of the folders in your Python path - same
general idea as the DOS search path, it's a list of directories where
Python will look for modules you ask it to import.
  
>From the docs: (http://docs.python.org/tutorial/modules.html)
  The Module Search Path
  When a module named spam is
imported, the interpreter searches for a file
named spam.py
in the current directory, and then in the list of
directories specified by the environment variable PYTHONPATH. This
has the same syntax as the shell variable PATH, that is, a
list of
directory names. When PYTHONPATH is not set, or when the file is
not
found there, the search continues in an installation-dependent default
path; on
Unix, this is usually .:/usr/local/lib/python.
  Actually, modules are searched in the list of directories given by
the variable
  sys.path
which is initialized from the directory containing the input script
(or the current directory), PYTHONPATH and the installation- dependent
default. This allows Python programs that know what they're doing to
modify or
replace the module search path. Note that because the directory
containing the
script being run is on the search path, it is important that the script
not have
the same name as a standard module, or Python will attempt to load the
script as
a module when that module is imported. This will generally be an error.
See
section Standard
Modules for more information.
  
  
  


  
  
  www.fsrtechnologies.com
  
  
  
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



-- 
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



  
  
  
  
  
-- 
  www.fsrtechnologies.com
  

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
  


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


"Nature, to be commanded, must be obeyed."
   -- Sir Francis Bacon 




Web Page: www.speckledwithstars.net/



import os, os.path
from configobj import ConfigObj
from validate import Validator
import StringIO

class Global(object): 
cfgFileName = os.getcwd() + os.sep + 'Initial.sen' # current directory + 
\ + filename --
#   but you could put it anywhere and call it anything
# create your spec as a multi-line string between triple quotes
tmpStr = 
mask_file_name = string(default=None)
gray_scale = boolean(default=True)
post_event_stack = boolean(default=False)
post_event_format = string(default=Tiff 2)
show_real_time = boolean(default=False)
hourly_rate = integer(min=0, default=0)
slowdown= integer(min=0, max=10, default=1) # I don't know what
#   this value is/does, so this is 

Re: [Tutor] Looking for ConfigObj Documentation

2009-02-18 Thread Marc Tompkins
On Wed, Feb 18, 2009 at 7:42 PM, Wayne Watson
sierra_mtnv...@sbcglobal.netwrote:

  I took your starter code, and formatted it to be what I hope is an
 acceptable program, Gobal_Config.py. See attached.  I'm using Python 2.5.2.
 I put the two modules in the same folder with it, and executed it in IDLE. I
 got this:
   ...
   File
 C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py,
 line 1637, in _parse
 ParseError, infile, cur_index)
   File
 C:\Sandia_Meteors\New_Sentinel_Development\Sentuser_Utilities_Related\sentuser\configobj.py,
 line 1748, in _handle_error
 raise error
 ParseError: Invalid line at line 1.

 As far as I can tell, line 1 of config.obj looks OK. It's a comment.
 Something is amiss.


I hate to say it, but IDLE is really holding you back.  It's convenient
because it installs automagically with Python, but it does funky, confusing
things - as in this case, where it's somehow stepped on the real error and
assigned blame in the wrong place; you've already experienced its internal
conflicts with Tkinter...  I use wxPython for my GUI goodness, and swear by
SPE (Stani's Python Editor).  I don't want to re-ignite the IDE wars, but I
definitely think you need to do yourself a favor and move away from IDLE.

Anyway, I didn't mean for that to be a standalone program, but to be picked
apart into chunks and dropped into an existing program (or, actually, just
to be used as an example - maybe of what _not_ to do, but an example...)
First error:
if argv is None:
   argv = sys.argv  == you haven't imported sys

Second error:
app = MyApp(0)  == you haven't defined a class called MyApp, so you
can't do this...

So I cut it down to just this bit:
test = Global.cfgFile.validate(Global.vtor, copy=True)
Global.cfgFile.write()

(unindented all the way to the left, so that it executes as the main body of
the program) and it works just fine... except:
Third error (well, issue not error):
Take all my comments out!  They weren't meant to be included in final code.
ConfigObj allows inline comments in your config file, and in the configspec
- so my comments show up in there too.  Here's what Initial.sen ends up
looking like:

mask_file_name = None
gray_scale = True
post_event_stack = False
post_event_format = Tiff 2
show_real_time = False
hourly_rate = 0
slowdown = 1# I don't know what
#   this value is/does, so this is probably wrong
start_time = 00:00:00# or you could make the default None?
stop_time = 00:00:00
#   as a default latitude, if any...

I've cut everything down; I'm attaching it as Global_Config1.py (just to
avoid confusion with the earlier version).  If you do actually want to use
it as the basis of anything, you'll want to place the call to .validate()
somewhere near the beginning of the action - remember, the call to .write()
just afterward is completely optional; I had it in there for testing and
have kept it in there for the same reason.



 Does PYTHONPATH apply in Win XP? I haven't played at the level of paths for
 a long time in any OS. We can worry about an install package later for the
 modules. It might be best for the users of this program.


Ya know, I have no idea anymore.  I thought I knew - but I just did a SET
from a command prompt, and I don't have a PYTHONPATH variable.  I seem to
reacall something from a year or two ago... (looking now)  Oh yes - there's
a directory under your Python directory (Python25 in my case) called Lib,
and a folder under that called site-packages; any text files with the
extension .pth will be scaned for the names of folders to add to the
search path.  As much as I love Python, I wish they'd get all this
together...

-- 
www.fsrtechnologies.com
import os, os.path
from configobj import ConfigObj
from validate import Validator
import StringIO

class Global(object): 
cfgFileName = os.getcwd() + os.sep + 'Initial.sen'
tmpStr = 
mask_file_name = string(default=None)
gray_scale = boolean(default=True)
post_event_stack = boolean(default=False)
post_event_format = string(default=Tiff 2)
show_real_time = boolean(default=False)
hourly_rate = integer(min=0, default=0)
slowdown= integer(min=0, max=10, default=1) 
start_time = string(default=00:00:00)
stop_time = string(default=00:00:00)
lat = float(min=0.0, max=90.0)

cfgSpec = StringIO.StringIO(tmpStr) 
cfgFile = ConfigObj(cfgFileName,
configspec=cfgSpec, raise_errors=True, write_empty_values=True,
create_empty=True, indent_type='', list_values=True) 
vtor = Validator() 

test = Global.cfgFile.validate(Global.vtor, copy=True)
Global.cfgFile.write()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor