Re: Community Involvement

2011-08-04 Thread sparky gmail

On 8/3/2011 8:14 PM, Steve Holden wrote:

[Ccs appreciated]

After some three years labor I (@holdenweb) at last find myself 
approaching the completion of the Python Certificate Series with 
O'Reilly School of Technology (@OReillySchool).


At OSCON last week the team fell to talking about the final assignment 
(although the Certificate is not a certification, students only 
progress by answering real quiz questions, not the usual 
multiple-choice task). Success also requires that they complete a 
project at the end of each (of the ~60) lesson(s).


We would ideally like the last project to to be something that 
demonstrates at least some minimal involvement with the Python 
community. Something like "get a Python answer upvoted on 
StackOverflow", for example, or getting a question answered on c.l.p. 
At the same time it shouldn't be anything that places a burden on the 
community (otherwise the hundredth student would be abused and the 
thousandth murdered).


So I wondered if anyone had any good ideas.

regards
 Steve
--
Steve Holden
st...@holdenweb.com 




Just a thought.

What about contributing code or documentation to an established project?

I dislike the idea of getting an answer up voted. First of all, for 
people trying to do it honestly you are putting
their completion into the hands of strangers, secondly, it would be very 
easy to cheat by having someone else,

or themselves with a puppet account, up vote the answer.

There are a metric grip of established projects that could use a little 
help with documentation, code examples, etc.

I think this is a better route to community participation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Selecting unique values

2011-07-26 Thread sparky gmail

On 7/25/2011 3:03 PM, Kumar Mainali wrote:

Greetings

I have a dataset with occurrence records of multiple species. I need 
to get rid of multiple listings of the same occurrence point for a 
species (as you see below in red and blue typeface). How do I create a 
dataset only with unique set of longitude and latitude for each 
species? Thanks in advance.


Species_nameLongitudeLatitude
Abies concolor-106.60135.868
Abies concolor-106.49335.9682
Abies concolor-106.48935.892
Abies concolor-106.49635.8542
Accipiter cooperi-119.68834.4339
Accipiter cooperi-119.79234.5069
Accipiter cooperi-118.79734.2581
Accipiter cooperi-77.389.68333
Accipiter cooperi-77.389.68333
Accipiter cooperi-75.9915340.65
Accipiter cooperi-75.9915340.65

- Kumar
It would seem to me that what you are wanting is a dictionary where the 
species name is the key and the value is a list of Long/Lat


So assuming your data is in a list like so (such as you might get from 
reading lines from a file) ['Abies concolor-106.60135.868', 'Abies 
concolor-106.49335.9682']


You could say

output = dict()
for record in my_long_list:
values = record.rsplit(' ', 2)
key = values[:1]
value = ' '.join(values[1:])
try:
 output[key].append(value)
 except KeyError:
 output[key] = [value]


Something like that should do.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Pythonic Approach to Annotation/Metadata?

2010-07-15 Thread Sparky
On Jul 15, 2:26 pm, John Krukoff  wrote:
> On Thu, 2010-07-15 at 12:37 -0700, Sparky wrote:
>
> 
>
> > the above is a good "pythonic" way to solve this problem? I am using
> > 2.6.
>
> Hopefully a helpful correction, but if you're running on google app
> engine, you're using python 2.5 on the google side irrespective of what
> you're running for development.
>
> --
> John Krukoff 
> Land Title Guarantee Company

Sorry about that and thanks for pointing out my mistake there.

Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Best Pythonic Approach to Annotation/Metadata?

2010-07-15 Thread Sparky
Hello Python community!

I am building a JSON-RPC web application that uses quite a few models.
I would like to return JSON encoded object information and I need a
system to indicate which properties should be returned when the object
is translated to a JSON encoded string. Unfortunately, this
application runs on top of Google's App Engine and, thus, private
attributes are not an option. Also, a preliminary search leads me to
believe that there are no real established ways to annotate variables.
Ideally I want to do something like:

def to_JSON(self):
returnDict = {}
for member in filter(someMethod, inspect.getmembers(self)):
returnDict[member[0]] = member[1]
return json.dumps(returnDict)

I recognize that two solutions would be to 1) include a prefix like
"public_" before variable names or 2) have a list/tuple of attributes
that should be transmitted, simply using the "in" operator. However,
both these options seem like a pretty ungraceful way to do it. Does
anyone else have an idea? Are there any established methods to apply
metadata / annotations to variables in Python or do you believe one of
the above is a good "pythonic" way to solve this problem? I am using
2.6.

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter Menu in Frame

2009-08-13 Thread Sparky
Hello! I am trying to figure out if it is possible to place a Tkinter
menu within a frame. This would be instead of having the menu-bar at
the top of the window.

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Two Dimensional Array + ctypes

2009-08-06 Thread Sparky
On Aug 5, 11:19 pm, "Gabriel Genellina" 
wrote:
> En Wed, 05 Aug 2009 20:12:09 -0300, Sparky  escribió:
>
>
>
>
>
> > Hello! I am trying to call this method:
>
> > long _stdcall AIBurst(long *idnum, [...]
> >                     long timeout,
> >                     float (*voltages)[4],
> >                     long *stateIOout,
> >                     long *overVoltage,
> >                     long transferMode);
>
> > I am having some problems with that  float (*voltages)[4].
> >         pointerArray = (ctypes.c_void_p * 4)
> >         voltages = pointerArray(ctypes.cast(ctypes.pointer
> > ((ctypes.c_long * 4096)()), ctypes.c_void_p), ctypes.cast
> > (ctypes.pointer((ctypes.c_long * 4096)()), ctypes.c_void_p),
> > ctypes.cast(ctypes.pointer((ctypes.c_long * 4096)()),
> > ctypes.c_void_p), ctypes.cast(ctypes.pointer((ctypes.c_long * 4096)
>
> Why c_long and not c_float?
> Anyway, this way looks much more clear to me (and doesn't require a cast):
>
> arr4096_type = ctypes.c_float * 4096
> voltages_type = arr4096_type * 4
> voltages = voltages_type()
>
> > The program runs but the values that come back in the array are not
> > right.
>
> Thay might be due to the long/float confusion.
>
> --
> Gabriel Genellina

Brilliant! Your code is much cleaner and the problem must have been
float vs long.

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Two Dimensional Array + ctypes

2009-08-05 Thread Sparky
Hello! I am trying to call this method:

long _stdcall AIBurst(long *idnum,
 long demo,
 long stateIOin,
 long updateIO,
 long ledOn,
 long numChannels,
 long *channels,
 long *gains,
 float *scanRate,
 long disableCal,
 long triggerIO,
 long triggerState,
 long numScans,
 long timeout,
 float (*voltages)[4],
 long *stateIOout,
 long *overVoltage,
 long transferMode);

I am having some problems with that  float (*voltages)[4]. Here is
what I tried:

def aiBurst(self, channels, scanRate, numScans, idNum=None, demo=0,
stateIOin=[0, 0, 0, 0], updateIO=0, ledOn=0, gains=[0, 0, 0, 0],
disableCal=0, triggerIO=0, triggerState=0, timeout=1, transferMode=0):

if idNum is None:
idNum = self.id

idNum = ctypes.c_long(idNum)

numChannels = len(channels)

stateIOArray = listToCArray(stateIOin, ctypes.c_long)
channelsArray = listToCArray(channels, ctypes.c_long)
gainsArray = listToCArray(gains, ctypes.c_long)
scanRate = ctypes.c_float(scanRate)
pointerArray = (ctypes.c_void_p * 4)
voltages = pointerArray(ctypes.cast(ctypes.pointer
((ctypes.c_long * 4096)()), ctypes.c_void_p), ctypes.cast
(ctypes.pointer((ctypes.c_long * 4096)()), ctypes.c_void_p),
ctypes.cast(ctypes.pointer((ctypes.c_long * 4096)()),
ctypes.c_void_p), ctypes.cast(ctypes.pointer((ctypes.c_long * 4096)
()), ctypes.c_void_p))
stateIOout = (ctypes.c_long * 4096)()
overVoltage = ctypes.c_long(999)

staticLib.AIBurst(ctypes.byref(idNum), demo, stateIOArray,
updateIO, ledOn, numChannels, ctypes.byref(channelsArray), ctypes.byref
(gainsArray), ctypes.byref(scanRate), disableCal, triggerIO,
triggerState, numScans, timeout, ctypes.byref(voltages), ctypes.byref
(stateIOout), ctypes.byref(overVoltage), transferMode)

The program runs but the values that come back in the array are not
right. However, I am not sure if I am passing the array or if I am
just not reading them well afterwards. What is the best way to put
this in and what is the best way to cast it and read it back?

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsError: exception: access violation writing 0x00000000

2009-08-04 Thread Sparky
On Aug 4, 9:47 am, Philip Semanchuk  wrote:
> On Aug 4, 2009, at 11:25 AM, Sparky wrote:
>
>
>
>
>
> > On Aug 3, 3:29 pm, Sparky  wrote:
> >> Hello! I am using cTypes on Windows to interface with a dll and I  
> >> keep
> >> getting an error when I execute this method:
>
> >> def eDigitalIn(self, channel, idNum = None, demo = 0, readD=0):
> >>         """
> >>         Name: U12.eAnalogIn(channel, idNum = None, demo = 0, readD=0)
> >>         Args: See section 4.4 of the User's Guide
> >>         Desc: This is a simplified version of Counter. Reads & resets
> >> the counter (CNT).
> >>         """
>
> >>         if idNum is None:
> >>             idNum = self.id
>
> >>         ljid = ctypes.c_long(idNum)
> >>         state = ctypes.c_long(999)
>
> >>         ecode = staticLib.ECount(ctypes.byref(ljid), demo, channel,
> >> readD, ctypes.byref(state))
>
> >>         if ecode != 0: raise LabJackException(ecode)
> >>         if ljid == -1: raise LabJackException(-1, "LabJack not
> >> found.")
>
> >>         return {"idnum":ljid.value, "state":state.value}
>
> >> Here is the error message:
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >>     device.eDigitalIn(0)
> >>   File "C:\Documents and Settings\All Users\Documents\Python
> >> \LabJackPython_new\u12.py", line 118, in eDigitalIn
> >>     ecode = staticLib.ECount(ctypes.byref(ljid), demo, channel,  
> >> readD,
> >> ctypes.byref(state))
> >> WindowsError: exception: access violation writing 0x
>
> >> Here is the signature of the method (which is known to work with C++
> >> programs):
>
> >> long _stdcall EDigitalIn(long *idnum,
> >>                                            long demo,
> >>                                            long channel,
> >>                                            long readD,
> >>                                            long *state);
>
> >> staticLib is declared with staticLib = ctypes.windll.LoadLibrary
> >> ("ljackuw").
>
> >> Any ideas?
>
> >> Thanks,
> >> Sam
>
> > One more thing, I seem to be getting back incorrect values for doubles
> > passed by reference. Any suggestions? I am on a 64-bit machine but I
> > should think that should not make a difference.
>
> Hi Sam,
> ctypes is pretty straightforward, and I wouldn't expect it to break on  
> something simple. I looked over your code (warning -- I am a ctypes  
> novice) and it looks OK to me. If you're getting null pointer writes  
> I'd suspect that the call signature isn't what you think it is,  
> perhaps due to a lack of an extern "C" declaration or something like  
> that. In short, I don't think this is a problem in your Python code or  
> in ctypes.
>
> But since your Python code is the easiest to change, why not do a  
> quick test of a minimal example?
>
> def eDigitalIn_test_version(self, channel, idNum = None, demo = 0,  
> readD=0):
>          ljid = ctypes.c_long(42)
>          state = ctypes.c_long(999)
>
>          ecode = staticLib.ECount(ctypes.byref(ljid), 0, 0, 0,  
> ctypes.byref(state))
>
>          print ecode
>
> Does that work any better?
>
> You could also try replacing the byref() calls with pointers created  
> by ctypes.pointer(). But I suspect that all this will do is give you  
> confidence that it isn't your Python code that's wrong.
>
> You might want to write a minimal C program that invokes ECount. That  
> would help you to prove whether or not you have a working C (not C++!)  
> interface for your function.
>
> HTH
> Philip

Hey Philip,

Thank you for your response. It turns out I was calling a function
that I was not intending on calling, so it was not a Python problem.

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: WindowsError: exception: access violation writing 0x00000000

2009-08-04 Thread Sparky
On Aug 3, 3:29 pm, Sparky  wrote:
> Hello! I am using cTypes on Windows to interface with a dll and I keep
> getting an error when I execute this method:
>
> def eDigitalIn(self, channel, idNum = None, demo = 0, readD=0):
>         """
>         Name: U12.eAnalogIn(channel, idNum = None, demo = 0, readD=0)
>         Args: See section 4.4 of the User's Guide
>         Desc: This is a simplified version of Counter. Reads & resets
> the counter (CNT).
>         """
>
>         if idNum is None:
>             idNum = self.id
>
>         ljid = ctypes.c_long(idNum)
>         state = ctypes.c_long(999)
>
>         ecode = staticLib.ECount(ctypes.byref(ljid), demo, channel,
> readD, ctypes.byref(state))
>
>         if ecode != 0: raise LabJackException(ecode)
>         if ljid == -1: raise LabJackException(-1, "LabJack not
> found.")
>
>         return {"idnum":ljid.value, "state":state.value}
>
> Here is the error message:
> Traceback (most recent call last):
>   File "", line 1, in 
>     device.eDigitalIn(0)
>   File "C:\Documents and Settings\All Users\Documents\Python
> \LabJackPython_new\u12.py", line 118, in eDigitalIn
>     ecode = staticLib.ECount(ctypes.byref(ljid), demo, channel, readD,
> ctypes.byref(state))
> WindowsError: exception: access violation writing 0x
>
> Here is the signature of the method (which is known to work with C++
> programs):
>
> long _stdcall EDigitalIn(long *idnum,
>                                            long demo,
>                                            long channel,
>                                            long readD,
>                                            long *state);
>
> staticLib is declared with staticLib = ctypes.windll.LoadLibrary
> ("ljackuw").
>
> Any ideas?
>
> Thanks,
> Sam

One more thing, I seem to be getting back incorrect values for doubles
passed by reference. Any suggestions? I am on a 64-bit machine but I
should think that should not make a difference.

Thanks again,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


WindowsError: exception: access violation writing 0x00000000

2009-08-03 Thread Sparky
Hello! I am using cTypes on Windows to interface with a dll and I keep
getting an error when I execute this method:

def eDigitalIn(self, channel, idNum = None, demo = 0, readD=0):
"""
Name: U12.eAnalogIn(channel, idNum = None, demo = 0, readD=0)
Args: See section 4.4 of the User's Guide
Desc: This is a simplified version of Counter. Reads & resets
the counter (CNT).
"""

if idNum is None:
idNum = self.id

ljid = ctypes.c_long(idNum)
state = ctypes.c_long(999)

ecode = staticLib.ECount(ctypes.byref(ljid), demo, channel,
readD, ctypes.byref(state))

if ecode != 0: raise LabJackException(ecode)
if ljid == -1: raise LabJackException(-1, "LabJack not
found.")

return {"idnum":ljid.value, "state":state.value}

Here is the error message:
Traceback (most recent call last):
  File "", line 1, in 
device.eDigitalIn(0)
  File "C:\Documents and Settings\All Users\Documents\Python
\LabJackPython_new\u12.py", line 118, in eDigitalIn
ecode = staticLib.ECount(ctypes.byref(ljid), demo, channel, readD,
ctypes.byref(state))
WindowsError: exception: access violation writing 0x

Here is the signature of the method (which is known to work with C++
programs):

long _stdcall EDigitalIn(long *idnum,
   long demo,
   long channel,
   long readD,
   long *state);

staticLib is declared with staticLib = ctypes.windll.LoadLibrary
("ljackuw").

Any ideas?

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Webcam + GStreamer

2009-07-12 Thread Sparky
On Jul 12, 7:38 pm, David  wrote:
> Sparky wrote:
> > On Jul 12, 4:30 pm, David  wrote:
> >> Sparky wrote:
> >>> On Jul 12, 3:50 pm, Sparky  wrote:
> >>>> Hello! I need to stream from a webcam in Linux and I need to be able
> >>>> to analyze the video feed frame by frame with PIL. Currently my web-
> >>>> cam (Quickcam Chat) only seems to work with GStreamer so a solution
> >>>> using pygst would be preferred.
> >>>> Thanks for your help,
> >>>> Sam
> >>> Sorry, to clarify I am just having a hard time capturing frames in a
> >>> way that I can access with PIL.
> >> Most web cams produce jpeg images so read the note at the bottom 
> >> here;http://effbot.org/imagingbook/format-jpeg.htm
> >> What exactly are you trying to do? What have you tried so far and what
> >> happened may help.
>
> >> --
> >> Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com
>
> > Dear David,
>
> > Thank you for your quick response. I have tried a few things. First of
> > all, I have tried gst-launch-0.10 v4l2src ! ffmpegcolorspace !
> > pngenc ! filesink location=foo.png. Foo.png comes out sharp enough but
> > it takes around 2 seconds to complete. I have also tried CVTypes but
> > it does not run without LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and,
> > when it does run, it only displays colored "snow". Here is that code:
>
> > import pygame
> > import Image
> > from pygame.locals import *
> > import sys
>
> > import opencv
> > #this is important for capturing/displaying images
> > from opencv import highgui
>
> > camera = highgui.cvCreateCameraCapture(-1)
> > print "cam:" + str(camera)
> > def get_image():
> >    print "here"
> >    im = highgui.cvQueryFrame(camera)
> >    #convert Ipl image to PIL image
> >    return opencv.adaptors.Ipl2PIL(im)
>
> > fps = 30.0
> > pygame.init()
> > window = pygame.display.set_mode((320,240))
> > pygame.display.set_caption("WebCam Demo")
> > screen = pygame.display.get_surface()
>
> > while True:
> >    events = pygame.event.get()
> >    im = get_image()
> >    print im.mode
> >    pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
> >    screen.blit(pg_img, (0,0))
> >    pygame.display.flip()
> >    pygame.time.delay(int(1000 * 1.0/fps))
>
> > Finally, I have gotten pygst to stream video with the example at
> >http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.htmlbut of
> > course I do not know how to get a hold of that data. Just so you know,
> > I am trying a primitive type of object tracking. I would use some of
> > the libraries already available but the two more popular
> > implementations on Linux (tbeta/ccv and reacTIVision) dont seem to
> > work with my web cam. I have more info on those non-python attempts at
> >http://ubuntuforums.org/showthread.php?p=7596908. Unfortunately no one
> > seemed to respond to that post.
>
> > Thanks again,
> > Sam
>
> See if this gets you started, I got it working here with a video4linux2 
> cam.http://code.google.com/p/python-video4linux2/
> here is what I have, I think it is the 
> same;http://dwabbott.com/python-video4linux2-read-only/
> let me know how you make out.
> -david
>
> --
> Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com

I gave it a shot and here is what I got:

s...@sam-laptop:~/python-video4linux2-read-only$ ./pyv4l2.py
Available devices:  ['/dev/video0']
/dev/video0
Capabilities:
Capture
ReadWrite
Streaming
Input 0:
Name:   zc3xx
Type:   camera
Standards: []
Pixel formats:
JPEGJPEG
Resolutions:
Segmentation fault

-

s...@sam-laptop:~/python-video4linux2-read-only$ ./streampics.py /dev/
video0 0 BGR3 640 480 testpics
Trying to create directory pics
Recording /dev/video0:0 with format JPEG at (640, 480)
Traceback (most recent call last):
  File "./streampics.py", line 94, in 
Run()
  File "./streampics.py", line 78, in Run
d.SetupStreaming(5, StreamCallback)
  File "/home/sam/python-video4linux2-read-only/pyv4l2.py", line 682,
in SetupStreaming
self.StreamOn()
  File "/home/sam/python-video4linux2-read-only/pyv4l2.py", line 636,
in StreamOn
lib.Error()
Exception: Could not start streaming:   22: Invalid argument
*** glibc detected *** python: free(): invalid next size (fast):
0x0a2aeff0 ***

Any suggestions?

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Webcam + GStreamer

2009-07-12 Thread Sparky
On Jul 12, 4:30 pm, David  wrote:
> Sparky wrote:
> > On Jul 12, 3:50 pm, Sparky  wrote:
> >> Hello! I need to stream from a webcam in Linux and I need to be able
> >> to analyze the video feed frame by frame with PIL. Currently my web-
> >> cam (Quickcam Chat) only seems to work with GStreamer so a solution
> >> using pygst would be preferred.
>
> >> Thanks for your help,
> >> Sam
>
> > Sorry, to clarify I am just having a hard time capturing frames in a
> > way that I can access with PIL.
>
> Most web cams produce jpeg images so read the note at the bottom 
> here;http://effbot.org/imagingbook/format-jpeg.htm
> What exactly are you trying to do? What have you tried so far and what
> happened may help.
>
> --
> Powered by Gentoo GNU/Linuxhttp://linuxcrazy.com

Dear David,

Thank you for your quick response. I have tried a few things. First of
all, I have tried gst-launch-0.10 v4l2src ! ffmpegcolorspace !
pngenc ! filesink location=foo.png. Foo.png comes out sharp enough but
it takes around 2 seconds to complete. I have also tried CVTypes but
it does not run without LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so and,
when it does run, it only displays colored "snow". Here is that code:

import pygame
import Image
from pygame.locals import *
import sys

import opencv
#this is important for capturing/displaying images
from opencv import highgui

camera = highgui.cvCreateCameraCapture(-1)
print "cam:" + str(camera)
def get_image():
print "here"
im = highgui.cvQueryFrame(camera)
#convert Ipl image to PIL image
return opencv.adaptors.Ipl2PIL(im)

fps = 30.0
pygame.init()
window = pygame.display.set_mode((320,240))
pygame.display.set_caption("WebCam Demo")
screen = pygame.display.get_surface()

while True:
events = pygame.event.get()
im = get_image()
print im.mode
pg_img = pygame.image.frombuffer(im.tostring(), im.size, im.mode)
screen.blit(pg_img, (0,0))
pygame.display.flip()
pygame.time.delay(int(1000 * 1.0/fps))

Finally, I have gotten pygst to stream video with the example at
http://pygstdocs.berlios.de/pygst-tutorial/webcam-viewer.html but of
course I do not know how to get a hold of that data. Just so you know,
I am trying a primitive type of object tracking. I would use some of
the libraries already available but the two more popular
implementations on Linux (tbeta/ccv and reacTIVision) dont seem to
work with my web cam. I have more info on those non-python attempts at
http://ubuntuforums.org/showthread.php?p=7596908. Unfortunately no one
seemed to respond to that post.

Thanks again,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Webcam + GStreamer

2009-07-12 Thread Sparky
On Jul 12, 3:50 pm, Sparky  wrote:
> Hello! I need to stream from a webcam in Linux and I need to be able
> to analyze the video feed frame by frame with PIL. Currently my web-
> cam (Quickcam Chat) only seems to work with GStreamer so a solution
> using pygst would be preferred.
>
> Thanks for your help,
> Sam

Sorry, to clarify I am just having a hard time capturing frames in a
way that I can access with PIL.
-- 
http://mail.python.org/mailman/listinfo/python-list


Webcam + GStreamer

2009-07-12 Thread Sparky
Hello! I need to stream from a webcam in Linux and I need to be able
to analyze the video feed frame by frame with PIL. Currently my web-
cam (Quickcam Chat) only seems to work with GStreamer so a solution
using pygst would be preferred.

Thanks for your help,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SHM and Touchpad

2009-06-17 Thread Sparky
On Jun 17, 2:09 pm, Philip Semanchuk  wrote:
> On Jun 17, 2009, at 3:56 PM, Sparky wrote:
>
> > Hello! I am writing an application that requires access to the state
> > of a synaptics touch pad on a laptop running Ubuntu Linux (for the
> > number of fingers, pressure, x location, y location, etc). A different
> > program using C++ accesses the information through SHM and I was
> > hoping to do the same with Python. I looked in PyPi and I noticed that
> > there was a module for SHM but I can not figure out where to download
> > it from (http://pypi.python.org/pypi/shm). Does anyone have any
> > suggestions?
>
> Hi Sam,
> I'm not familiar with that shm, however there was (and still is) a old  
> Python IPC module called shm. It uses Sys V semaphores, not POSIX  
> semaphores like the shm in pypi.
>
> The old shm module has been replaced by two newer ones. For Sys V 
> IPC:http://semanchuk.com/philip/sysv_ipc/
>
> For POSIX IPC:http://semanchuk.com/philip/posix_ipc/
>
> The old shm module is still around on semanchuk.com but I'm not  
> updating it anymore (the author is AWOL and I'm just the maintainer)  
> and I don't recommend using it.
>
> HTH
> Philip

Dear Philip,

Thank you for your quick response, I will take a look at the link you
provided.
-- 
http://mail.python.org/mailman/listinfo/python-list


SHM and Touchpad

2009-06-17 Thread Sparky
Hello! I am writing an application that requires access to the state
of a synaptics touch pad on a laptop running Ubuntu Linux (for the
number of fingers, pressure, x location, y location, etc). A different
program using C++ accesses the information through SHM and I was
hoping to do the same with Python. I looked in PyPi and I noticed that
there was a module for SHM but I can not figure out where to download
it from (http://pypi.python.org/pypi/shm). Does anyone have any
suggestions?

Thanks,
Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Connection tester

2009-06-10 Thread Sparky
On Jun 10, 10:01 am, Jeff McNeil  wrote:
> On Jun 10, 10:26 am, Sparky  wrote:
>
>
>
> > Hey! I am developing a small application that tests multiple websites
> > and compares their "response time". Some of these sites do not respond
> > to a ping and, for the measurement to be standardized, all sites must
> > have the same action preformed upon them. Another problem is that not
> > all of the sites have the same page size and I am not interested in
> > how long it takes to load a page but instead just how long it takes
> > for the website to respond. Finally, I am looking to keep this script
> > platform independent, if at all possible.
>
> > Here is the code:
>
> >     try:
> >         # Get the starting time
> >         origTime = time.time()
>
> >         # Create the socket connection and then close
> >         s = socket.socket(AF_INET, SOCK_STREAM)
> >         s.connect((targetIP, port))
> >         s.send("GET / HTTP/1.0\r\n\r\n")
> >         result = s.recv(1024)
> >         s.shutdown(SHUT_RDWR)
>
> >     except:
> >         result = ""
>
> >     # Check for problems and report back the time
> >     if result == "":
> >         return Result((time.time() - origTime) * 1000, True)
> >     else:
> >         return Result((time.time() - origTime) * 1000, False)
>
> > Result is just an object that holds the time it took for the method to
> > finish and if there were any errors. What I am worried about is that
> > the socket is potentially closed before the website can finish sending
> > in all the data. Does anyone have any suggestions or is the script
> > fine as it is?
>
> ICMP and application-level response times are two different animals.
> Are you interested in simply whether or not a server is up and
> responding, or do you care about the actual response time and
> performance of the web site you're checking? I did something like this
> recently and there were a few different metrics we wound up using.
> Connect time, first-byte, page download, DNS resolution, and so on.
>
> Since you don't care about any of that, just use a HEAD request. It
> will return the response headers, but as per specification it will not
> return a message body.  Take a look at "http://www.w3.org/Protocols/
> rfc2616/rfc2616-sec9.html" for a full primer on the different verbs.
>
> A somewhat simplistic alternative would be to connect to port 80 on
> the destination server and drop the connection once it has been made.
> This will tell you how long it took to establish a TCP session and
> that something is indeed listening on the destination port. That's
> slightly more information than you would get from an ICMP reply.

Thank you all for your responses. I will play with everything but the
HEAD request seems to be what I was looking for.

Sam
-- 
http://mail.python.org/mailman/listinfo/python-list


Connection tester

2009-06-10 Thread Sparky
Hey! I am developing a small application that tests multiple websites
and compares their "response time". Some of these sites do not respond
to a ping and, for the measurement to be standardized, all sites must
have the same action preformed upon them. Another problem is that not
all of the sites have the same page size and I am not interested in
how long it takes to load a page but instead just how long it takes
for the website to respond. Finally, I am looking to keep this script
platform independent, if at all possible.

Here is the code:

try:
# Get the starting time
origTime = time.time()

# Create the socket connection and then close
s = socket.socket(AF_INET, SOCK_STREAM)
s.connect((targetIP, port))
s.send("GET / HTTP/1.0\r\n\r\n")
result = s.recv(1024)
s.shutdown(SHUT_RDWR)

except:
result = ""

# Check for problems and report back the time
if result == "":
return Result((time.time() - origTime) * 1000, True)
else:
return Result((time.time() - origTime) * 1000, False)

Result is just an object that holds the time it took for the method to
finish and if there were any errors. What I am worried about is that
the socket is potentially closed before the website can finish sending
in all the data. Does anyone have any suggestions or is the script
fine as it is?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows Install Command Line

2009-02-22 Thread Sparky
On Feb 22, 11:15 am, "Martin v. Löwis"  wrote:
> Sparky wrote:
> > For internal distribution purposes, I was wondering if there was an
> > already established process/program for installing Python on Windows
> > machines without using an msi file or compiling from source. Basically
> > I need the standard distribution installed by either a batch file or
> > python script through py2exe.
>
> What's wrong with running the MSI from a batch file?
>
> msiexec /i pythonxy.msi
>
> If you want installation to be silent, add more command line options
> to msiexec.
>
> HTH,
> Martin

Ah! Wonderful that was exactly what I was looking for.

Thanks,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Windows Install Command Line

2009-02-22 Thread Sparky
For internal distribution purposes, I was wondering if there was an
already established process/program for installing Python on Windows
machines without using an msi file or compiling from source. Basically
I need the standard distribution installed by either a batch file or
python script through py2exe.

Thank you in advance,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Re: File Locking Forced? Newbie question.

2008-07-15 Thread Sparky
On Jul 15, 11:38 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> Sparky wrote:
> > Hello! I am writing some software that will have many users accessing
> > the same file resource at once for reading purposes only. I am
> > programming on (Ubuntu) Linux and my question is in Windows, can I
> > have it so that the same file can be open in read mode by more than
> > one person or could Window's file locking system get in the way?
>
> Assuming your question is: can processes A, B & C read
> from the same file at the same time, then: Yes. (You
> can try it out yourself fairly easily if you want. Just
> open a clutch of interpreter windows and do some
> open ("abc.txt", "r").read () stuff in each one).
>
> But I'm surprised you think that anything might get
> in the way of that. It would be a fairly limiting file
> system which prevented multiple simultaneous readers.
>
> TJG

Thank you. For some reason I thought there was a file locking system
on Windows (http://en.wikipedia.org/wiki/
File_locking#File_locking_in_Microsoft_Windows). But, I believe that
that only applies to those using Microsoft's file methods and only for
writing. Thanks for clearing that up.

Sam
--
http://mail.python.org/mailman/listinfo/python-list


File Locking Forced? Newbie question.

2008-07-15 Thread Sparky
Hello! I am writing some software that will have many users accessing
the same file resource at once for reading purposes only. I am
programming on (Ubuntu) Linux and my question is in Windows, can I
have it so that the same file can be open in read mode by more than
one person or could Window's file locking system get in the way?

Thanks,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie Threading Question

2008-07-13 Thread Sparky
On Jul 13, 1:30 pm, Nick Dumas <[EMAIL PROTECTED]> wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> I'm not an expert on Python threading, so don't take my word as low,
> however, I believe that there's no need for a list of systems which
> support it because the Python virtual machine handles it. Thus, any
> system which supports Python (or at least Python versions with
> threading) will support Python threading. Again, I don't know a lot
> about this, but it would make sense.
>
> Sparky wrote:
> > It seems strange, but I can't find a list of operating systems which
> > support / don't support threading in Python. Can anyone point me in
> > the right direction?
>
> > Thanks,
> > Sam
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iEYEARECAAYFAkh6V8YACgkQLMI5fndAv9hVKgCePbrN4nwbsdZXNfIcnm3cXac5
> 5kUAnR0OeNB0gjsksRD2W5gcZ8c0pby0
> =p3U+
> -END PGP SIGNATURE-

Thanks. I think that should make sense. Plus, if it is part of the
standard distribution, I would assume it is supported in most places.

Sam
--
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython Tab

2008-07-13 Thread Sparky
On Jul 13, 10:32 am, Uwe Schmitt <[EMAIL PROTECTED]>
wrote:
> On Jul 13, 6:20 pm, Sparky <[EMAIL PROTECTED]> wrote:
>
> > Is there a way to get wxPython to change the visible tab in a notebook
> > (like I have tab 1 open but the computer will automatically change to
> > tab 2)?
>
> > Thanks,
> > Sam
>
> look 
> athttp://docs.wxwidgets.org/stable/wx_wxnotebook.html#wxnotebooksetpage...
>
> greetings, uwe

Works like a charm. Thanks!

Sam
--
http://mail.python.org/mailman/listinfo/python-list


wxPython Tab

2008-07-13 Thread Sparky
Is there a way to get wxPython to change the visible tab in a notebook
(like I have tab 1 open but the computer will automatically change to
tab 2)?

Thanks,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Newbie Threading Question

2008-07-13 Thread Sparky
It seems strange, but I can't find a list of operating systems which
support / don't support threading in Python. Can anyone point me in
the right direction?

Thanks,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Re: Local User Control

2008-07-10 Thread Sparky
On Jul 10, 10:13 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> Sparky wrote:
> > On Jul 10, 9:58 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> >> Sparky wrote:
> >>> I don't know how feasible this is, but is it possible to have users
> >>> log in to access a local database file in such a way that allows the
> >>> program to know what user name and password they logged in with? This
> >>> would involve separate user names and passwords for each user.
> >> Well, this is a question which is crying out for some
> >> context. Are you talking about an existing database
> >> on an existing platform? If so, which one? Are you
> >> talking about a database youo're thinking of building?
> >> If so, the answer's probably yes but only you can
> >> know. Are you talking about something else altogether?
>
> >> TJG
>
> > Thanks for the timely response. This would be a database that I am
> > building myself. The question comes down to is there a feasible way to
> > verify a user's user name and password from inside that database.
> > Obviously the file would be encrypted, but if there is going to be
> > more than one user using it I suppose there would be a separate file
> > for a log-in. I am just asking for some guidance on how this would
> > theoretically be implemented.
>
> Maybe someone else on the list has a clearer idea than I do,
> but at this distance from an implementation, all I can say is:
> yes, I'm sure you can achieve some kind of user authentication.
> After all, lots of other products already do. Or is your proposed
> db very different?
>
> TJG

Thanks. I suppose I probably should get further down the road and come
back with a more specific question.

Thanks again,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Re: Local User Control

2008-07-10 Thread Sparky
On Jul 10, 9:58 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> Sparky wrote:
> > I don't know how feasible this is, but is it possible to have users
> > log in to access a local database file in such a way that allows the
> > program to know what user name and password they logged in with? This
> > would involve separate user names and passwords for each user.
>
> Well, this is a question which is crying out for some
> context. Are you talking about an existing database
> on an existing platform? If so, which one? Are you
> talking about a database youo're thinking of building?
> If so, the answer's probably yes but only you can
> know. Are you talking about something else altogether?
>
> TJG

Thanks for the timely response. This would be a database that I am
building myself. The question comes down to is there a feasible way to
verify a user's user name and password from inside that database.
Obviously the file would be encrypted, but if there is going to be
more than one user using it I suppose there would be a separate file
for a log-in. I am just asking for some guidance on how this would
theoretically be implemented.

Thanks again,
Sam
--
http://mail.python.org/mailman/listinfo/python-list


Local User Control

2008-07-10 Thread Sparky
I don't know how feasible this is, but is it possible to have users
log in to access a local database file in such a way that allows the
program to know what user name and password they logged in with? This
would involve separate user names and passwords for each user.

Thanks for your time and help,
Sam
--
http://mail.python.org/mailman/listinfo/python-list