[Tutor] help

2005-02-08 Thread james middendorff
I want to use mysqldb to add people into a database,
but when I ask for the certain fields like Name,
PhoneNumber and such, I cannot get it to put them in
as a string? I am not sure what I am doing wrong but
here is my code thanks to anyone who helps:
import MySQLdb

username = raw_input("what is your username? ")
password = raw_input("what is the password? ")
database = raw_input("what database do you want to
enter? ")
conn = MySQLdb.connect(host='127.0.0.1',
user=username, passwd=password, db=database)

c = conn.cursor()

Name = raw_input("what is the name you want to add? ")
PhoneNumber = input("what is the phone number for the
person you are adding? ")
Address = raw_input("what is the address for the
person you are adding? ")
EmailAddress = raw_input("what is the email address of
the person you are adding? ")
BirthDate = raw_input("what is the birthdate of the
person you are adding? year-month-day")


c.execute ("""
INSERT INTO people ()
VALUES
   ('%s','%s','%s','%s','%s');
   """)% (Name, PhoneNumber, Address,
EmailAddress, BirthDate)
   
print "%d rows were inserted" % c.rowcount

=
"I would kill everyone in this room
for a drop of sweet beer."
 Homer Simpson



__ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help

2005-04-17 Thread james middendorff
Hello, 
I was wondering if there was a tutorial and or module
that would help me create a program to use a parallel
port to turn on/off a device in linux? I have searched
but cannot find a tutorial on a good way to do this.
The whole project would be to use a parallel port to
control solid state relays, allowing me to drive a rc
car from my pc... Thanks for any help

James 

"I would kill everyone in this room
for a drop of sweet beer."
 Homer Simpson



__ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] help with my python app

2005-05-16 Thread james middendorff
Hello, I would like to be able to use the arrow keys
to control a remote control car, which I can do but
only one key at a time. I would like to press the up
key, then while it is moving forward, press the left
or right key to turn while it is moving forward? I am
sure there are probably better ways to write the code,
I am still learning all of this. Also if this
indention is off I am including the file
thanks

#!/usr/bin/python
import parallel
import pygame
from pygame.locals import *

p=parallel.Parallel()
p.setData(0)







def main():
# Initialise screen
pygame.init()
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("James' custom RC
Car Application")

# Fill background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))

# Display some text
font = pygame.font.Font(None, 36)
text = font.render("Which Way? ", 1, (10, 10,
10))
textpos = text.get_rect()
textpos.centerx =
background.get_rect().centerx
background.blit(text, textpos)

# Blit everything to the screen
screen.blit(background, (0, 0))
pygame.display.flip()

# Event loop
while 1:
for event in pygame.event.get():
if event.type == QUIT:
return
elif event.type == KEYDOWN:
if event.key == K_UP:
background.fill((250, 250, 250))
font = pygame.font.Font(None, 36)
text = font.render("Forward", 1, (10, 
10,
10))
textpos = text.get_rect()
textpos.centerx =
background.get_rect().centerx
background.blit(text, textpos)
screen.blit(background, (0, 0))
pygame.display.flip()
screen.blit(background, (0, 0))
pygame.display.flip()
p.setData(1)


if event.key == K_DOWN:
background.fill((250, 250, 250))
font =
pygame.font.Font(None, 36)
text =
font.render("Reverse", 1, (10, 10, 10))
textpos =
text.get_rect()
   
textpos.centerx = background.get_rect().centerx
   
background.blit(text, textpos)
   
screen.blit(background, (0, 0))
   
pygame.display.flip()
   
screen.blit(background, (0, 0))
   
pygame.display.flip()
p.setData(2)


if event.key == K_LEFT:
background.fill((250, 250, 250))
font =
pygame.font.Font(None, 36)
text =
font.render("LEFT", 1, (10, 10, 10))
textpos =
text.get_rect()
textpos.centerx =
background.get_rect().centerx
background.blit(text,
textpos)

screen.blit(background, (0, 0))
pygame.display.flip()

screen.blit(background, (0, 0))
pygame.display.flip()
p.setData(8)


if event.key == K_RIGHT:
background.fill((250, 250, 250))
font =
pygame.font.Font(None, 36)
text =
font.render("RIGHT", 1, (10, 10, 10))
textpos =
text.get_rect()
   
textpos.centerx = background.get_rect().centerx
   
background.blit(text, textpos)
   
screen.blit(background, (0, 0))
   
pygame.display.flip()
   
screen.blit(background, (0, 0))
   
pygame.display.flip()

[Tutor] help

2006-01-16 Thread james middendorff
I am trying to do some AGI scripting with python and
asterisk, I read the book, Asterisk the Future of
Telephony, which has an example of AGI + python. I
have found that none of the example seems to work. My
question is I have figured out how to play a recorded
message sys.stdout.write('EXEC PLAYBACK name "*#"')
then you do sys.stdout.flush() and you will get your
message played. In the book it shows if you want to
capture something the user inputs you do result =
sys.stdin.readline().strip() but when I add that to my
line I cannot get my message to be played? Am I
totally off on this. All I want it to make a message
play, then capture their input, and put it to use in
the rest of my python script?
Thanks for any help. I hope someone else is playing
with asterisk and python
James

"I would kill everyone in this room
for a drop of sweet beer."
 Homer Simpson

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor