Carroll, Barry | 1 Nov 2005 02:07

Talking to UDPServer

Greetings:

 

I am writing a browser-based interface to a server program which extends SocketServer.UDPServer.  The program listens on a well-known socket, receiving commands, verifying them and using their content to drive our test hardware, returning status to the client.  The current client interface is a command line interface that allows the user to type in a command and sends it to the server, receives the status response and displays it for the user.  My job is to duplicate the client functionality in a set of web pages. 

 

My problem is that, while I can find documentation on UDPServer, I cannot find anything on how a remote client talks to the server.  How is this done in Python?  Can someone point me to a how-to, tutorial or the like? 

 

Thanks in advance.

 

Barry

 

 

 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Pujo Aji | 1 Nov 2005 02:14
Picon

Re: while/if/elif/else loops

Let's comment something:
1. If you have error please show us your error message.
2. When you code python be aware of indention, be persistent for example use tab space 4.
3. import should be on the top of your code.
4. to choose random between integer 1 or 0 use randint(0,1)
5. your last code use Print it should be print (small letter please).

Cheers,
pujo

On 10/31/05, Zameer Manji <zmanji <at> gmail.com> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

I'm new to programming and python. I've have recently been experimenting
with while/if/elif/else loops and I've created a simple number guessing
game. Now I want to create a coin tossing game, but I don't know how to
structure it in python. The code I already have (but it's not working)
is below.


#Coin Toss Game

print "This game will simulate 100 coin tosses and then tell you the
number of head's and tails"

import random

tosses = 0
heads = 0
tails = 0

while tosses = 100<0:
   coin = randrange(1)
   tosses +=1
   if coin == 0:
      heads +=1
      print "Heads"
    else:
      tails +=1
      Print "Tails"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)

iQEVAwUBQ2accw759sZQuQ1BAQqoyQgAsmVhRidMC1/WpQms6fChX+z62DWSpmRW
qiY9F7bZAYZusyNsHHDUpuTAYdI0LXxgLVmYBKDz3tKhVCbEZTn9FUwgw5A2thYy
I5o82tWXZnIpgmFIN2AysAj2dCI4mSfi/IJjE5JvG+IFELWigMb9Pf6tap4HiB71
IBayql8MN1XrA2zv8fXQs35zVwxnBUSvAHZuUBLi4hDcPxY/d71X/JHqfqpf3svS
ClzUlYqLhXld+39/aiRFKOXHyVCnfsEUcAXB45r110Q3K+7KegwgX4Js8qL5dA66
d74HlLMb6Cp6G5AlNdQoKDin8jlMloxeQpb60hS+HmnBwkEFukyNHA==
=QMuB
-----END PGP SIGNATURE-----
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Kent Johnson | 1 Nov 2005 02:55
Gravatar

Re: Talking to UDPServer

Carroll, Barry wrote:
> I am writing a browser-based interface to a server program which extends 
> SocketServer.UDPServer.  The program listens on a well-known socket, 
> receiving commands, verifying them and using their content to drive our 
> test hardware, returning status to the client.  The current client 
> interface is a command line interface that allows the user to type in a 
> command and sends it to the server, receives the status response and 
> displays it for the user.  My job is to duplicate the client 
> functionality in a set of web pages. 
> 
> My problem is that, while I can find documentation on UDPServer, I 
> cannot find anything on how a remote client talks to the server.  How is 
> this done in Python?  Can someone point me to a how-to, tutorial or the 
> like? 

Are you trying to write a browser-based client, or a Python client? As far as I know, it is not possible to
write a browser client in Python, or a browser UDP client. You can write a UDP client in Python, I think you
have to use the socket module directly.

Kent

--

-- 
http://www.kentsjohnson.com

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Orri Ganel | 1 Nov 2005 03:40
Picon

: [Slightly OT] Using Python to intercept audio from a program

Hello all,

A week or two ago I sent in a few emails regarding using threads in automating conversion between wav's and mp3's using lame.  However, the program I use to generate these wav's, Audacity (a great program, btw), can't record directly from another program, but instead catches all audio directed at the speakers.  Being the person I am, I'm never patient enough to sit there and do nothing else while I record these wav's, so I do other things in the background.  Unfortunately, with the current setup, any sounds generated by these background activities end up in the wav files.  So I asked on the audacity-help mailing list whether audacity has the capability to record directly from another program, and the answer, sadly, was no. At least, not for Windows.  So what I would like to do is attempt the same with Python, though right now I have only the vaguest of ideas on how to proceed.  If anyone could point me in the right direction, I would be very grateful.

Thanks in advance,
Orri
-- Email: singingxduck AT gmail DOT com AIM: singingxduck Programming Python for the fun of it.
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Johan Geldenhuys | 1 Nov 2005 02:34
Picon

Re: Talking to UDPServer

Maybe you could tel us if you already have the server listening on the socket that you expec connections on? If, yes, do you want an example of how a client connects to that socket?

Johan

Carroll, Barry wrote:

Greetings:

 

I am writing a browser-based interface to a server program which extends SocketServer.UDPServer.  The program listens on a well-known socket, receiving commands, verifying them and using their content to drive our test hardware, returning status to the client.  The current client interface is a command line interface that allows the user to type in a command and sends it to the server, receives the status response and displays it for the user.  My job is to duplicate the client functionality in a set of web pages. 

 

My problem is that, while I can find documentation on UDPServer, I cannot find anything on how a remote client talks to the server.  How is this done in Python?  Can someone point me to a how-to, tutorial or the like? 

 

Thanks in advance.

 

Barry

 

 

 

_______________________________________________ Tutor maillist - Tutor <at> python.org http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Orri Ganel | 1 Nov 2005 04:20
Picon

Re: : [Slightly OT] Using Python to intercept audio from a program

By the way, if it makes a difference, the program I intend to attempt 
this with is Rhapsody <http://www.rhapsody.com/>, a part of the 
RealPlayer collection of media software.

--

-- 
Email: singingxduck AT gmail DOT com
AIM: singingxduck
Programming Python for the fun of it.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

R. Alan Monroe | 1 Nov 2005 04:10
Picon
Favicon

Re: while/if/elif/else loops


> while tosses = 100<0:

I didn't run the program, but this immediately caught my eye as
looking kind of suspect. Was it a typo? Most programs usually
have a need for comparisons of equal, or greater/less, but it's really
rare to need both combined in one statement...

Also if you really _do_ want to check two things being equal, don't
forget to use double equal ( == ).

Alan

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Danny Yoo | 1 Nov 2005 05:34
Picon

Re: help with prime number program


On Mon, 31 Oct 2005, Kent Johnson wrote:

> Norman Silverstone wrote:
> > I am a beginner so, I hope what I give, makes sense. In it's simplest
> > form what is wrong with :-
> >
> > n = input("Enter a number")
> > if n % 2 != 0 and n % 3 != 0:
> >    print n, " Is a prime number"
> >
> This only gives the correct answer if n < 25. You can't test against a
> fixed list of divisors, there will always be a non-prime whose divisors
> are not in your list.

Kent's comment is actually a paraphrase of Euclid's "There are an infinite
number of primes" argument used in mathematics.  *grin*

    http://mathworld.wolfram.com/EuclidsTheorems.html

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Steve Bergman | 1 Nov 2005 05:52

Turning kwargs into scalars

Say I have a function:

def f(self, **kwargs) :

and I want to take the key/value pairs and create a set of variables 
with the names of the keys.

For example, if I say:

f(x=5, y=2)

I want to create local variables 'x' and 'y' in the function, with 
values of 5 and 2 respectively.

How could I do this?

Thanks,
Steve Bergman

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Liam Clarke | 1 Nov 2005 07:15
Picon

Random Q on Python's internals?

Hi all,

I was perusing the standard library, and was wondering if anyone knew
how the internals of Python work, roughly or no.

Basically, I assume os.pipe() resides in a DLL somewhere, yet when I
open up Python24.DLL in PEexplorer I can't find mention of pipes
anywhere...

am I looking the right place?

Regards,

Liam Clarke
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane