how to measure TCP congestion windows using python ??

2010-12-19 Thread plz
hi! i'm newbie about python and i want to measure the value of cwnd in TCP 
socket.

I have searched from an internet and got that we could handle it from SOL_TCP, 
TCP_INFO...since unix had #include  and we could  refer to 
tcp_info
for getting the information of TCP by using this method

but i don't know how to declare the tcp_info in Python..
does anyone know how to handle this? please suggest me 

Thanks in advance 


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


Re: how to measure TCP congestion windows using python ??

2010-12-19 Thread plz
hi 
many thanks for helping me
i also tried to manipulate it last night
here is my code...

import socket
import struct

sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
tcp_info = sock.getsockopt(socket.SOL_TCP, socket.TCP_INFO, 
struct.calcsize('BBB'))
print struct.unpack('BBB', tcp_info)

the result of struct.unpack of tcp_info is following
in /usr/include/linux/tcp.h 
used Linux Redhat and Python 2.7

anyway your code is very useful 
Thxs again ;)



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


Download parts not whole file in ones

2007-02-13 Thread NOSPAM plz
Hey,

My problem is, is it possible to download parts of a file while. i think 
is it is called threading

My code thats download the whole webpage, and stunds the app while is is 
downloading:

---CODE---
import urllib
# the heavy file to download
f = urllib.urlopen("http://da.wikipedia.org/wiki/Wiki";)
# This was supposed to print the file while it downloads
while 1:
print f.read(100)
---/CODE---

In my example it just download the whole file, and then print it.

Any suggestions?

Regards
Andreas


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


Regex highlight html

2007-02-13 Thread NOSPAM plz
Hey,

I want to write a function that highlights html code.

I have read the wiki page http://en.wikipedia.org/wiki/Regular_expressions

just like this:


test

to this:


test

Just example colors - not so pretty :)

Any suggestions?

Andreas



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


Re: Regex highlight html

2007-02-13 Thread NOSPAM plz




Hey,

I want to write a function that highlights html code.

I have read the wiki page http://en.wikipedia.org/wiki/Regular_expressions

just like this:


test

to this:

="test.png" alt="test pic" height="100" width="100">
="#">test

Just example colors - not so pretty :)

Any suggestions?

Andreas




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

Re: Mulig SPAM: float print formatting

2007-02-13 Thread NOSPAM plz
hg skrev:
> Hi,
>
> Considering the float 0.0, I would like to print 00.00.
>
> I tried '%02.02f' % 0.0 ... but I get 0.00
>
> Any clue ?
>
> Thanks,
>
> hg
>
>   
Try this:

a = 45.45 # the floating number

print "some text",
print a,
print "some text again"

or just this:

print "some text",
print 45.45,
print "some text again"

Hope it helped :D

Andreas


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


Re: Regex highlight html

2007-02-13 Thread NOSPAM plz
Gabriel Genellina skrev:
> En Tue, 13 Feb 2007 10:13:26 -0300, NOSPAM plz <[EMAIL PROTECTED]>  
> escribió:
>
>   
>> I want to write a function that highlights html code.
>> 
>
> Well, it's already done, you have Pygments http://pygments.pocoo.org/
> and SilverCity http://silvercity.sourceforge.net/
>
>   
>> I have read the wiki page  
>> http://en.wikipedia.org/wiki/Regular_expressions
>> 
>
> Ouch... Read some previous posts on why it's not a good idea to use  
> regexps for parsing html code.
>
>   
Thanks just what i needed :D!


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