Re: [Tutor] bind line-oriented device output?

2010-03-29 Thread Fiyawerx
On Mon, Mar 29, 2010 at 11:56 AM, Tom Roche  wrote:

>
> http://mail.python.org/pipermail/tutor/2010-March/075438.html
> >> I'd like to learn to pythonically redirect the output from a
> >> line-oriented character device to a particular file or process,
> >> regardless of focus, on a generic graphical OS. But I don't want to
> >> redirect stdin entirely.
> ...
> >> It Would Be Nice, and useful for this seminar's mechanics, to be
> >> able to run some code to which one could say, see this device? and
> >> this file? Make the device's output go only to that file. For extra
> >> credit, don't let anything else write that file while this code is
> >> running.
>


> 1 does not redirect all of stdin, only the output from the scanner.
>  The user is allowed to continue to work on other tasks (e.g. with
>  output from the laptop's keyboard going to whatever frame), with
>  only the output from the scanner being bound to a particular file or
>  process.
>
>
This may be out of my league, but what about pyUSB? (
http://pyusb.sourceforge.net/docs/1.0/tutorial.html)

Possibly a program that just runs in the background, waits for input from
the usb scanner, and appends the id to a specified file when it catches it?
That way you also don't need to keep the file open the whole time, in case
someone accidentally forgets to plug it in or shuts down while the program
is still writing? I'm sure there are a lot of better ways to handle the
actual file writing, but thought it might help.

Just a noobs $.02
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bind line-oriented device output?

2010-03-29 Thread Wayne Werner
On Mon, Mar 29, 2010 at 10:56 AM, Tom Roche  wrote:

> I'll read the Product Reference Guide and hope it tells me that the
> Wasp WLS9500 "reports a control character." Unfortunately when I
> search the PDF
>
> http://tinyurl.com/waspWLS9500manual
>
> for "control character" I get no hits. Are there synonyms for that
> term in this context?
>
>
Take a look at the bottom of 8-5, it has some prefix/suffix values.
Apparently you can set it to send  and it looks like by
perusing the manual and probably a bit of trial and error you can set it up
to send one of any number of CTRL characters as the prefix. I don't know of
any windows program that uses ctrl-] as a hotkey though I'm sure there are
some.

For Python registering hotkeys, a quick google search pulled up these:
http://www.islascruz.org/html/index.php/blog/show/HotKeysonWindows.html
http://bytes.com/topic/python/answers/574341-how-create-global-hotkey (mainly
lots of links to other sites)

I wasn't able to find anything super definitive on mac, though, which is too
bad.

Anyhow, HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bind line-oriented device output?

2010-03-29 Thread Tom Roche

http://mail.python.org/pipermail/tutor/2010-March/075438.html
>> I'd like to learn to pythonically redirect the output from a
>> line-oriented character device to a particular file or process,
>> regardless of focus, on a generic graphical OS. But I don't want to
>> redirect stdin entirely.
...
>> It Would Be Nice, and useful for this seminar's mechanics, to be
>> able to run some code to which one could say, see this device? and
>> this file? Make the device's output go only to that file. For extra
>> credit, don't let anything else write that file while this code is
>> running.

http://mail.python.org/pipermail/tutor/2010-March/075443.html
> if you can assure that the target computer will be running a certain
> set of python features (i.e. Tkinter/pyGTK+/wxPython, etc)

Presuming they're available on the user's platform and not too onerous
to install, I can definitely say, "if you want , you need
to install ."

> you can fairly easily write a program that will run fullscreen and
> continually grab focus to whatever widget (in this case a text entry
> field) you want.

*Continually* grabbing focus to a UI is functionally (from the user's
point of view) equivalent to redirecting stdin, no? The user is made
unable to do anything but take attendance for the duration of the
task. In fact, for this usecase, continually grabbing focus is worse,
since the user would be unable to, e.g., read the directions for
setting up the audio. To clarify the usecase:

The barcode scanner (here, a Wasp WLS9500) is connected to an ordinary
multiprocessing laptop (which may be linux, mac, or windows) on which
the user will want to do other things while taking attendance: the
attendees don't come in all at once, and the user must accomplish
other tasks while taking attendance (notably setting up to record the
seminar audio). Hence the desired application

0 is portable.

1 does not redirect all of stdin, only the output from the scanner.
  The user is allowed to continue to work on other tasks (e.g. with
  output from the laptop's keyboard going to whatever frame), with
  only the output from the scanner being bound to a particular file or
  process.

2 does not continually grab focus. The user is allowed to continue to
  work on other tasks (e.g. with output from the laptop's keyboard
  going to whatever frame), with only scanner events being bound to a
  particular frame or widget.

But what might satisfy the usecase is

> if the device is something like the CueCat and reports a control
> character (I think it's alt+f7 for the cuecat), then at least on
> linux/windows I think it's much more trivial. You just have to
> register a global hotkey handler that will send the focus to that
> particular window.

I'll read the Product Reference Guide and hope it tells me that the
Wasp WLS9500 "reports a control character." Unfortunately when I
search the PDF

http://tinyurl.com/waspWLS9500manual

for "control character" I get no hits. Are there synonyms for that
term in this context?

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python magazine

2010-03-29 Thread Lowell Tackett

>From the virtual desk of Lowell Tackett  



--- On Sun, 3/28/10, Lowell Tackett  wrote:

> From: Lowell Tackett 
> Subject: Re: [Tutor] python magazine
> To: "Dave Angel" 
> Cc: "Benno Lang" , tutor@python.org
> Date: Sunday, March 28, 2010, 7:46 AM
> 
> From the virtual desk of Lowell Tackett  
> 
> 
> 
> --- On Sat, 3/27/10, Dave Angel 
> wrote:
> 
> > From: Dave Angel 
> > Subject: Re: [Tutor] python magazine
> > To: "Lowell Tackett" 
> > Cc: "Benno Lang" ,
> tutor@python.org
> > Date: Saturday, March 27, 2010, 6:12 AM
> > 
> > 
> > Lowell Tackett wrote:
> > > >From the virtual desk of Lowell Tackett 
> 
> > > 
> > > --- On Fri, 3/26/10, Benno Lang 
> > wrote:
> > > 
> > > From: Benno Lang 
> > > Subject: Re: [Tutor] python magazine
> > > To: "Lowell Tackett" 
> > > Cc: tutor@python.org,
> > "Bala subramanian" 
> > > Date: Friday, March 26, 2010, 8:38 PM
> > > 
> > > On 27 March 2010 00:33, Lowell Tackett 
> > wrote:
> > >   
> > >> The Python Magazine people have now got a
> Twitter
> > site--which includes a perhaps [telling] misspelling.
> > >> 
> > > Obviously that's why they're looking for a chief
> > editor - maybe it's
> > > even a deliberate ploy.
> > > 
> > > I'm not sure if this affects others, but to me
> your
> > replies appear
> > > inside the quoted section of your mail, rather
> than
> > beneath it. Would
> > > you mind writing plain text emails to avoid this
> > issue?
> > > 
> > > Thanks,
> > > benno
> > > 
> > > Like this...?
> > > 
> > > 
> > >   
> > No, there's still a problem.  You'll notice in
> this
> > message that there are ">" symbols in front of your
> lines
> > and benno's, and ">>" symbols in front of
> > Lowell's.  (Some email readers will turn the >
> into
> > vertical bar, but the effect is the same).  Your
> email
> > program should be adding those upon a reply, so that
> your
> > own message has one less > than the one to which
> you're
> > replying.  Then everyone reading can see who
> wrote
> > what, based on how many ">" or bars precede the
> > respective lines.  Quotes from older messages
> have more
> > of them.
> > 
> > Are you using "Reply-All" in your email program? 
> Or
> > are you constructing a new message with copy/paste?
> > 
> > What email are you using?  Maybe it's a
> configuration
> > setting somebody could help with.
> > 
> > DaveA
> > 
> > 
> Don't really know what I'm doing wrong (or right). 
> Just using the [email] tools that have been made available
> to me thru Yahoo mail and Firefox.  I began this text
> below your submission and "signature", and I'm using plain
> text, as suggested by a previous comment.  Don't know
> what else I could embellish this effort with.
> 
> 
>   
> 
I noticed one other thing in my response (having noticed it also in someone 
else's recent correspondence).
Apparently...my email package does not create its' own eol signals.  In 
contrast, your (Dave Angel) message holds the same eol format as it did in the 
copy that came to my mail box.  My messages however, stretch [each line] out to 
the full width of the available physical page format (to which they are 
submitted).  For what it's worth, I am typing this in the "Plain Text" option 
of my email template.

Gmane handles that predicament very gracefully, but over in "The Tutor 
Archives", my [message] lines sometime stretch [from my computer screen] 
halfway out into my kitchen.  Occasionally, I will see that occur with others' 
emailed offerings.  It's beyond me[?].

It's all the fault of Yahoo mail and Firefox...I'm just an innocent bystander 
in all of this. 


  

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] bind line-oriented device output?

2010-03-29 Thread Wayne Werner
On Sun, Mar 28, 2010 at 6:51 PM, Tom Roche  wrote:

>
> I'd like to learn to pythonically redirect the output from a
> line-oriented character device to a particular file or process,
> regardless of focus, on a generic graphical OS. But I don't want to
> redirect stdin entirely. Here's the usecase:
>
> My school has a seminar for which we record attendance by scanning the
> student ID card, or rather the barcode on its back, with a handheld
> USB scanner. This is pretty straightforward, except that the barcode
> scanner is like a keyboard writing the ASCII equivalent of the barcode
> (== the student's ID#) to stdin. FWIW, the scanner writes lines: I'm
> not sure if EOL is \r, \n, or \r\n, but I suspect the latter.
>
> Since the scanner is connected to an ordinary multiprocessing laptop on
> which one will likely be doing other things while scanning (notably
> setting up to record the presenter), it sometimes happens (especially
> until one learns to pay attention to this) that one writes to a frame
> other than the text file into which we want record attendee ID#s. This
> semester recurs every {fall, spring}, so someone faces this {pitfall,
> learning curve} at regular intervals.
>
> How to prevent writing the wrong target? One trivial solution--shlep a
> dedicated USB host for the scanner--is deprecated. An OS-specific
> solution (e.g. relying on a linux raw device) is also undesirable: I
> use ubuntu, but others will probably use mac or windows.
>
> Rather, It Would Be Nice, and useful for this seminar's mechanics, to
> be able to run some code to which one could say, see this device? and
> this file? Make the device's output go only to that file. For extra
> credit, don't let anything else write that file while this code is
> running.
>
> Can python do that? Or does one need to get closer to the metal?
>

It's certainly possible. Technically you can do /anything/, it's just a
matter of knowing how to do it. Whether or not it's worth doing is something
completely beside the point.

OTOH, if you can assure that the target computer will be running a certain
set of python features (i.e. Tkinter/pyGTK+/wxPython, etc) you can fairly
easily write a program that will run fullscreen and continually grab focus
to whatever widget (in this case a text entry field) you want.

with pyGTK you could do something like this:

gobject.timeout_add(100,  myentrywidget.grab_focus)

the function at the end may be different - perhaps you write your own
function to comply with the timeout_add requirements - but it it will
continually (every 100ms) grab the "keyboard" focus.

OTOH, if the device is something like the CueCat and reports a control
character (I think it's alt+f7 for the cuecat), then at least on
linux/windows I think it's much more trivial. You just have to register a
global hotkey handler that will send the focus to that particular window.

There are probably a few other approaches to this problem, but those are two
of the "simplest".

HTH,
Wayne
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor