473,396 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Poll script in Python

Lad
Is there a poll script available in Python?
Jul 18 '05 #1
9 4156
On 16 Oct 2004 03:59:05 -0700, Lad <ex****@hope.cz> wrote:
Is there a poll script available in Python?


Can you be more specific? Are you talking about socket polling? Or a
web poll? Etc?

-Josh
Jul 18 '05 #2
Is there a poll script available in Python?


What do you mean by "poll"?

Do you mean "poll a file for changes", "poll a file handle for
readability/writability", "poll a socket", ..., "a web poll for taking
surveys",...?

- Josiah

Jul 18 '05 #3
Lad
Josh Close <na****@gmail.com> wrote in message news:<ma**************************************@pyt hon.org>...
On 16 Oct 2004 03:59:05 -0700, Lad <ex****@hope.cz> wrote:
Is there a poll script available in Python?


Can you be more specific? Are you talking about socket polling? Or a
web poll? Etc?

About web poll
Lad
Jul 18 '05 #4
> About web poll

Like: http://www.quizilla.com/
Or: http://slashdot.org/pollBooth.pl?qid=1192&aid=-1

You must be precise.

- Josiah

Jul 18 '05 #5
ex****@hope.cz (Lad) wrote in message news:<81************************@posting.google.co m>...
Josh Close <na****@gmail.com> wrote in message news:<ma**************************************@pyt hon.org>...
On 16 Oct 2004 03:59:05 -0700, Lad <ex****@hope.cz> wrote:
Is there a poll script available in Python?


Can you be more specific? Are you talking about socket polling? Or a
web poll? Etc?

About web poll
Lad


When in doubt, make your own :) !!!
Jul 18 '05 #6
ex****@hope.cz (Lad) wrote in message news:<81*************************@posting.google.c om>...
Is there a poll script available in Python?


I'm very interested in increasing the range of 'standard' CGI scripts
available in python. If you (or anyone else ?) wants help in writing a
simple one that could be used as a plugin to other webpages then
contact me and we'll work on it.

Regards,

Fuzzyman

http://www.voidspace.org.uk/atlantib...thonutils.html
Jul 18 '05 #7
ex****@hope.cz (Lad) wrote in message news:<81*************************@posting.google.c om>...
Is there a poll script available in Python?

Sure!
Jul 18 '05 #8
ma**********@gmail.com (Matthew K Jensen) wrote
When in doubt, make your own :) !!!

That seems wasteful, although I admit that finding something that
exactly suits you can be hard. I looked around for survey software a
while ago and didn't find any that worked for me, so I wrote some,
called Theodolite. If you are interested in the blurb at
http://joshua.smcvt.edu/theo, I'd be glad for beta tester feedback
(This is not a permanent address: I haven't yet had the chance to
upload the material to a Sourceforge-like site. If you mail me, I'll
tell you how to get it.)

Jim
Jul 18 '05 #9
fu******@gmail.com (Michael Foord) wrote in message news:<6f**************************@posting.google. com>...
ex****@hope.cz (Lad) wrote in message news:<81*************************@posting.google.c om>...
Is there a poll script available in Python?


I'm very interested in increasing the range of 'standard' CGI scripts
available in python. If you (or anyone else ?) wants help in writing a
simple one that could be used as a plugin to other webpages then
contact me and we'll work on it.


Here's some code (with organization-specific stuff replaced by
asterisks) that I wrote for polls that use ranked ballots:

# vote.cgi

#!/usr/bin/python

import os

def printError(message):
print ' <p>%s</p>\n </body>\n</html>' % message

def ordinal(n):
if n == 1:
return str(n) + 'st'
if n == 2:
return str(n) + 'nd'
if n == 3:
return str(n) + 'rd'
if n < 20:
return str(n) + 'th'
return ordinal(n % 10)

def printBallot():
candidates = file('CANDIDATES').read().splitlines()
n = len(candidates)
print ' <form method="post" action="castvote.cgi" />'
print ' <table>'
print ' <tr>'
print ' <th>Candidate</th>'
for i in xrange(1, n + 1):
print ' <th>%s choice</th>' % ordinal(i)
print ' </tr>'
for (candidateNumber, candidateName) in enumerate(candidates):
print ' <tr>'
print ' <td class="candidate">%s</td>' %
candidateName
for i in xrange(1, n + 1):
print ' <td>'
print ' <input type="radio" name="rank-%d" '
\
'value="%d"' % (candidateNumber,
i),
if i == n:
print 'checked',
print '/>'
print ' </td>'
print ' </tr>'
print ' </table>'
print ' <p class="votesubmission">'
print ' <input type="submit" value="Submit Ballot" />'
print ' </p>'
print ' </form>'
print ' </body>'
print '</html>'

print '''Content-Type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=us-ascii" />
<link rel="stylesheet" type="text/css" href="../****/style.css"
/>
<title>Vote!</title>
</head>
<body>'''
address = os.environ['REMOTE_ADDR']
if address.startswith(****):
try:
ballots = file('BALLOTS').read()
except IOError:
ballots = ''
if (address + '\n') in ballots:
printError('This isn\'t Chicago. You\'re only allowed to vote
once.')
else:
printBallot()
else:
printError('You can only vote from within ****')

# castvote.cgi

#!/usr/bin/python

import cgi
import os

address = os.environ['REMOTE_ADDR']
form = cgi.FieldStorage()
ballot = []
i = 0
while True:
try:
ballot.append(int(form['rank-%d' % i].value))
except KeyError:
break
i += 1

f = file('BALLOTS', 'a')
f.write('%r # %s\n' % (ballot, address))
f.close()

print '''Content-Type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=us-ascii" />
<link rel="stylesheet" type="text/css" href="../****/style.css"
/>
<title>Vote Submitted</title>
</head>
<body>
<p>Thank you for voting in ****'s ****. Results will be
announced at
****.</p>
<p>Click <a href="../****">here</a> to return to the
website.</p>
</body>
</html>'''
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Michael | last post by:
Hi, I am looking for a poll script with a special feature. Normally poll scripts display for every answer option ONE bar according to how many votes the answer got. I am looking for a script...
44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
17
by: Doug Holton | last post by:
George W Bush, as certified by Florida's election commission. Which decorator syntax do you like the most? See http://wiki.wxpython.org/index.cgi/PythonDecoratorsPoll A. @classmethod def...
4
by: Mario | last post by:
Hello everybody, Does anybody know how i make a script to make a poll? I mean a small poll when you can choose yes or no? -- -------"""------- ---()--- °?----(_)-----?° | Greetz Mario|
1
by: Magnus Lycka | last post by:
I'm trying to read standard out in a process started with popen2 in a non-blocking way. (Other good ways of doing this than the one I tried are appreciated.) I've tried to dumb down my code to...
2
by: beliavsky | last post by:
Linux Journal annually polls its readers on questions such as their favorite programming language. In the 2005 poll, Python is 2nd, its highest ranking ever. Below are the results by year. I wish...
5
by: pbd22 | last post by:
Hi. I am trying to poll a long-running process via a hidden IFrame. I am noticing that the online errata gives advice for handling a server response: window.parent.handleServerResponse(); ...
2
by: inhahe | last post by:
select.poll isn't supported on Windows, because Windows doesn't have such a feature, or at least it didn't until Vista. Vista implements the same thing but called WSAPoll, an article is here...
1
by: Jean-Paul Calderone | last post by:
On Tue, 6 May 2008 08:36:28 -0400, inhahe <inhahe@gmail.comwrote: If you use Twisted, then you can use I/O Completion Ports, which are even better than WSAPoll, and your code will also work with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.