UML from py sources

2006-03-22 Thread Sbaush
Hi all, i'm searching for a tool that draw the UML of a python project. Have you idea about the best way to do it? I prefer a Linux tool, but it's the same, i have only a little bit of time...
-- Sbaush

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

UML from py sources

2006-03-22 Thread Sbaush
Hi all, i'm searching for a tool that draw the UML of a python project. Have you idea about the best way to do it? I prefer a Linux tool, but it's the same, i have only a little bit of time...-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Fail in sending UDP packet

2006-02-23 Thread Sbaush
No one of you has a idea??On 2/23/06, Sbaush <[EMAIL PROTECTED]> wrote:
Hi all. I've attached my SendReceive class. I have e a big problem! My program create a packet, then call the send function to send this. the first time the packet is not sent, then it works perfectly!WHY??? Have you idea??
-- Sbaush

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

Fail in sending UDP packet

2006-02-23 Thread Sbaush
Hi all. I've attached my SendReceive class. I have e a big problem! My program create a packet, then call the send function to send this. the first time the packet is not sent, then it works perfectly!WHY??? Have you idea??
-- Sbaush
from socket import *
from struct import *
from string import *

class SendReceive:
	def __init__(self):
		self.UDPSock = socket(AF_INET,SOCK_DGRAM)
		
	def receive(self,timeout):
		# Set the socket parameters
		
		buf = 10
		
		# Receive messages
		
		try:
			self.UDPSock.settimeout(timeout)
			xmlrcv,addr = self.UDPSock.recvfrom(buf)
			
			xmlrcv=xmlrcv[4:]#questo comando di slicing notation elimina i primi quattro bytes della stringa ricevuta, corrispondenti all'intero del pacchetto.
			(hostfrom,portfrom)=addr
			
			#print "Received response from ",hostfrom
			#print "on port ",portfrom
			#print xmlrcv	
			return (xmlrcv,hostfrom)
		
		except :
			#print "TimeOut"
			return False
		
		#UDPSock.close()




	def send(self,hostto,xml):	
		try:
			name=hostto
			#name=raw_input('Insert IP or name to send command >> ') #"192.168.2.138"
			host=gethostbyname(name)
			port = 40004
			buf = 5000
			addr = (host,port)
			dtd=" "
			xml=dtd+xml
			lenght=4+len(xml)
			packet=pack('i 5000s',lenght,xml)
			
	
			
			self.UDPSock.sendto(packet,addr)
			print "Sending message '",packet,"'."
			
			#UDPSock.close()
		except:
			return False-- 
http://mail.python.org/mailman/listinfo/python-list

Re: editor for Python on Linux

2006-02-21 Thread Sbaush
My favourite is Kate, available on KDE but working great also on Gnome!2006/2/21, Fabio Zadrozny <[EMAIL PROTECTED]>:
Well... pydev has it: http://pydev.sf.net and pydev extensions goes muchfurther: http://www.fabioz.com/pydevCheers,Fabio
jean-michel bain-cornu wrote:>>Boa-Constructor is an IDE rather than an editor.  Although it focuses>>on wxPython, it has a good editor.>>>>>Yes, some possibilities are pretty good, like for instance the
>findAll/findInFiles keeping the results in a new tab (I never saw this>elsewhere). Another useful is having the debugger launching the>application in a separate process, an excellent way to avoid bugs
>pollution coming into the IDE.>rgds>jm>>--Fabio Zadrozny--Software DeveloperESSS - Engineering Simulation and Scientific Software
www.esss.com.brPydev Extensionshttp://www.fabioz.com/pydevPyDev - Python Development Enviroment for Eclipse
http://pydev.sf.nethttp://pydev.blogspot.com--http://mail.python.org/mailman/listinfo/python-list
-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Delete a file

2006-02-17 Thread Sbaush
Hi.In my application i create a PNG image and i view it in a frame.How can delete it from my python code?Bye...-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

PyDot problem

2006-02-15 Thread Sbaush
Hi all. I use pydot for drawing nework link.the code is at bottom of mail.i have a png like this attachedIf you look png you can see that 10.0.0.1 and 
10.0.0.2 are linked by 2 arrow, one from 1 to 2, one form 2 to 1. Is possible to draw only one line with both arrow?I would have a result like in route2.png but i don't know how!!!Help me!!!
#---#code#---import pydot
edges=[("10.0.0.1","10.0.0.2"), ("10.0.0.2","10.0.0.1"),("
10.0.0.2","10.0.0.7"),("10.0.0.2","10.0.0.9"),("
10.0.0.2","10.0.0.6"),("10.0.0.9","10.0.0.8"),("10.0.0.6","
10.0.0.7") ]g=pydot.graph_from_edges(edges,directed=True)
g.write_png('route.png')-- Sbaush


route.png
Description: PNG image


route2.png
Description: PNG image
-- 
http://mail.python.org/mailman/listinfo/python-list

problem in ElementTree SubElement

2006-02-06 Thread Sbaush
Hi all. I would get this element in xml:I have write this:
date=ET.SubElement(idsreq,"date")        
date.set("month",month)        date.set("day",day)but i get this:
The attributes are not in my order!!how i can get the attributes in right order???
Thanks all.-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [wxPython-users] Problem in threading

2006-02-06 Thread Sbaush
oops...I tried it but i got a bad segmentation fault!!Is really a good threading implementation?2006/2/2, Josiah Carlson <[EMAIL PROTECTED]
>:My response is at the end.Sbaush <
[EMAIL PROTECTED]> wrote:> Hi all.> I've a problem with thread in python.> My applications has a GUI that has some button.> I've a MVC-like architecture.> If i click on a button there is this effect:
>> view.button_1_delete.Bind(EVT_BUTTON,self.OnDelete)> view.button_1_list.Bind(EVT_BUTTON,self.OnList)>> def OnDelete(self, evt):> self.presenter.updateModel("delete")
> def OnList(self, evt):> self.presenter.updateModel("list")>> Probably you image that the boss of this program is updateModel function.> this function has this code:
>> def updateModel(self,Type):> iptType=Type> self.readGUI(iptType)  # This function takes the request info from> GUI> packet=self.ipt_writeXML(iptType) # Put info in XML string
> self.sender.send(packet) #Send the XML string> (xmlresponse,hostfrom)=self.receiver.receive() # Receive a XML> string response from agent and the IP of agent> self.iptResponse.run
(xmlresponse,hostfrom) # view response in a> separate view.>> Now it works great, but there is a big problem: my app wait for response> before allow user to do another request.> I thought that with threads it could works perfectly.
> I tried to apply threads but without any good result.> Have you idea how can i do it and how can i apply thread to it?import wximport wx.lib.neweventimport threadingResponseEvent, EVT_RESPONSE = 
wx.lib.newevent.NewEvent()...def __init__(self, ...):...self.Bind(EVT_RESPONSE, self.GotResponse, self)...def _updateModel(self, Type):iptType=Type
self.readGUI(iptType)packet=self.ipt_writeXML(iptType)self.sender.send(packet)(xmlresponse,hostfrom)=self.receiver.receive()wx.PostEvent(self, ResponseEvent(xml=xmlresponse,
   host=hostfrom))def updateModel(self, Type):threading.Thread(target=self._updateModel,  args=(Type,)).start()def GotResponse(self, evt):
self.iptResponse.run(evt.xml, xml.host)... - Josiah-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Control if a input text is IP

2006-02-02 Thread Sbaush
thanks!! your ipcheck is perfect fo me!!2006/2/3, Fredrik Lundh <[EMAIL PROTECTED]>:
Sbaush wrote:> My app has in input an ip address in IPv4 notation.> is there a function that control if input is a string in IPv4 notation?here's one way to do it:def ipcheck(s):try:
a, b, c, d = [chr(int(c)) for c in s.split(".")]except ValueError:return Falseelse:return Trueanother way is to use regular expressions; see
http://www.regular-expressions.info/examples.html--http://mail.python.org/mailman/listinfo/python-list
-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Control if a input text is IP

2006-02-02 Thread Sbaush
Hi all.My app has in input an ip address in IPv4 notation. is there a function that control if input is a string in IPv4 notation?Thanks all.bye-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Problem in threading

2006-02-02 Thread Sbaush
Hi all.I've a problem with thread in python.My applications has a GUI that has some button. I've a MVC-like architecture.If i click on a button there is this effect:view.button_1_delete.Bind(EVT_BUTTON,
self.OnDelete)view.button_1_list.Bind(EVT_BUTTON,self.OnList)def OnDelete(self, evt):        self.presenter.updateModel("delete")def OnList(self, evt):        self.presenter.updateModel("list")
Probably you image that the boss of this program is updateModel function.this function has this code:def updateModel(self,Type):        iptType=Type        self.readGUI(iptType)  # This function takes the request info from GUI
        packet=self.ipt_writeXML(iptType) # Put info in XML string            self.sender.send(packet) #Send the XML string        (xmlresponse,hostfrom)=self.receiver.receive() # Receive a XML string response from agent and the IP of agent
        self.iptResponse.run(xmlresponse,hostfrom) # view response in a separate view.Now it works great, but there is a big problem: my app wait for response before allow user to do another request.I thought that with threads it could works perfectly. 
I tried to apply threads but without any good result.Have you idea how can i do it and how can i apply thread to it?Thanks all!-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Represent XML

2006-01-27 Thread Sbaush
Hi all.I attach to you a example XML file to parse and the demo of my objective.The iptRequest.xml is the file to parse in one mode. I can't parse it.The demo.py is my ideal result, manually built, that should be built by parsing the XML.
How can i do to do it?Bye all!
#!/usr/bin/env python
# -*- coding: ISO-8859-15 -*-
# generated by wxGlade 0.4 on Fri Jan 27 12:24:48 2006

from wxPython.wx import *
from wxPython.grid import *

class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.grid_1 = wxGrid(self, -1, size=(1, 1))

self.__set_properties()
self.__do_layout()
# end wxGlade

def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.SetSize(wxDLG_SZE(self, (390, 136)))
self.grid_1.CreateGrid(8, 8)
self.grid_1.EnableDragColSize(0)
self.grid_1.SetColLabelValue(0, "Chain")
self.grid_1.SetColLabelValue(1, "Policy")
self.grid_1.SetColLabelValue(2, "Num")
self.grid_1.SetColLabelValue(3, "Target")
self.grid_1.SetColLabelValue(4, "Protocol")
self.grid_1.SetColLabelValue(5, "Option")
self.grid_1.SetColLabelValue(6, "Source")
self.grid_1.SetColLabelValue(7, "Destination")
self.grid_1.SetMinSize(wxDLG_SZE(self.grid_1, (387, 150)))
# end wxGlade
	
	self.grid_1.SetCellValue(0,0,"INPUT")
	self.grid_1.SetCellValue(1,0,"INPUT")
	self.grid_1.SetCellValue(2,0,"INPUT")
	self.grid_1.SetCellValue(3,0,"OUTPUT")
	self.grid_1.SetCellValue(4,0,"OUTPUT")
	self.grid_1.SetCellValue(5,0,"OUTPUT")
	self.grid_1.SetCellValue(6,0,"FORWARD")
	self.grid_1.SetCellValue(7,0,"FORWARD")
	
	self.grid_1.SetCellValue(0,1,"ACCEPT")
	self.grid_1.SetCellValue(1,1,"ACCEPT")
	self.grid_1.SetCellValue(2,1,"ACCEPT")
	self.grid_1.SetCellValue(3,1,"ACCEPT")
	self.grid_1.SetCellValue(4,1,"ACCEPT")
	self.grid_1.SetCellValue(5,1,"ACCEPT")
	self.grid_1.SetCellValue(6,1,"ACCEPT")
	self.grid_1.SetCellValue(7,1,"ACCEPT")
	
	self.grid_1.SetCellValue(0,2,"1")
	self.grid_1.SetCellValue(1,2,"2")
	self.grid_1.SetCellValue(2,2,"3")
	self.grid_1.SetCellValue(3,2,"1")
	self.grid_1.SetCellValue(4,2,"2")
	self.grid_1.SetCellValue(5,2,"3")
	self.grid_1.SetCellValue(6,2,"1")
	self.grid_1.SetCellValue(7,2,"2")
	
	self.grid_1.SetCellValue(0,3,"ACCEPT")
	self.grid_1.SetCellValue(1,3,"ACCEPT")
	self.grid_1.SetCellValue(2,3,"ACCEPT")
	self.grid_1.SetCellValue(3,3,"ACCEPT")
	self.grid_1.SetCellValue(4,3,"ACCEPT")
	self.grid_1.SetCellValue(5,3,"ACCEPT")
	self.grid_1.SetCellValue(6,3,"ACCEPT")
	self.grid_1.SetCellValue(7,3,"ACCEPT")
	
	self.grid_1.SetCellValue(0,4,"icmp")
	self.grid_1.SetCellValue(1,4,"tcp")
	self.grid_1.SetCellValue(2,4,"udp")
	self.grid_1.SetCellValue(3,4,"icmp")
	self.grid_1.SetCellValue(4,4,"icmp")
	self.grid_1.SetCellValue(5,4,"icmp")
	self.grid_1.SetCellValue(6,4,"icmp")
	self.grid_1.SetCellValue(7,4,"udp")
	
	self.grid_1.SetCellValue(0,5,"--")
	self.grid_1.SetCellValue(1,5,"--")
	self.grid_1.SetCellValue(2,5,"--")
	self.grid_1.SetCellValue(3,5,"--")
	self.grid_1.SetCellValue(4,5,"--")
	self.grid_1.SetCellValue(5,5,"--")
	self.grid_1.SetCellValue(6,5,"--")
	self.grid_1.SetCellValue(7,5,"--")
	
	self.grid_1.SetCellValue(0,6,"localhost.localdomain")
	self.grid_1.SetCellValue(1,6,"127.0.0.3")
	self.grid_1.SetCellValue(2,6,"127.0.0.3")
	self.grid_1.SetCellValue(3,6,"localhost.localdomain")
	self.grid_1.SetCellValue(4,6,"127.0.0.2")
	self.grid_1.SetCellValue(5,6,"127.0.0.3")
	self.grid_1.SetCellValue(6,6,"localhost.localdomain")
	self.grid_1.SetCellValue(7,6,"127.0.0.3")
	
	self.grid_1.SetCellValue(0,7,"anywhere")
	self.grid_1.SetCellValue(1,7,"anywhere")
	self.grid_1.SetCellValue(2,7,"anywhere")
	self.grid_1.SetCellValue(3,7,"anywhere")
	self.grid_1.SetCellValue(4,7,"anywhere")
	self.grid_1.SetCellValue(5,7,"anywhere")
	self.grid_1.SetCellValue(6,7,"anywhere")
	self.grid_1.SetCellValue(7,7,"anywhere")
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wxBoxSizer(wxVERTICAL)
sizer_1.Add(self.grid_1, 1, wxEXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade

# end of class MyFrame


if __name__ == "__main__":
app = wxPySimpleApp(0)
wxInitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()


  

  



  
  



  
  


  

  

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

Represent XML

2006-01-27 Thread Sbaush
Hi all.I attach to you a example XML file to parse and the demo of my objective.The iptRequest.xml is the file to parse in one mode. I can't parse it.The demo.py is my ideal result, manually built, that should be built by parsing the XML.
How can i do to do it?Bye all!
#!/usr/bin/env python
# -*- coding: ISO-8859-15 -*-
# generated by wxGlade 0.4 on Fri Jan 27 12:24:48 2006

from wxPython.wx import *
from wxPython.grid import *

class MyFrame(wxFrame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wxDEFAULT_FRAME_STYLE
wxFrame.__init__(self, *args, **kwds)
self.grid_1 = wxGrid(self, -1, size=(1, 1))

self.__set_properties()
self.__do_layout()
# end wxGlade

def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
self.SetSize(wxDLG_SZE(self, (390, 136)))
self.grid_1.CreateGrid(8, 8)
self.grid_1.EnableDragColSize(0)
self.grid_1.SetColLabelValue(0, "Chain")
self.grid_1.SetColLabelValue(1, "Policy")
self.grid_1.SetColLabelValue(2, "Num")
self.grid_1.SetColLabelValue(3, "Target")
self.grid_1.SetColLabelValue(4, "Protocol")
self.grid_1.SetColLabelValue(5, "Option")
self.grid_1.SetColLabelValue(6, "Source")
self.grid_1.SetColLabelValue(7, "Destination")
self.grid_1.SetMinSize(wxDLG_SZE(self.grid_1, (387, 150)))
# end wxGlade
	
	self.grid_1.SetCellValue(0,0,"INPUT")
	self.grid_1.SetCellValue(1,0,"INPUT")
	self.grid_1.SetCellValue(2,0,"INPUT")
	self.grid_1.SetCellValue(3,0,"OUTPUT")
	self.grid_1.SetCellValue(4,0,"OUTPUT")
	self.grid_1.SetCellValue(5,0,"OUTPUT")
	self.grid_1.SetCellValue(6,0,"FORWARD")
	self.grid_1.SetCellValue(7,0,"FORWARD")
	
	self.grid_1.SetCellValue(0,1,"ACCEPT")
	self.grid_1.SetCellValue(1,1,"ACCEPT")
	self.grid_1.SetCellValue(2,1,"ACCEPT")
	self.grid_1.SetCellValue(3,1,"ACCEPT")
	self.grid_1.SetCellValue(4,1,"ACCEPT")
	self.grid_1.SetCellValue(5,1,"ACCEPT")
	self.grid_1.SetCellValue(6,1,"ACCEPT")
	self.grid_1.SetCellValue(7,1,"ACCEPT")
	
	self.grid_1.SetCellValue(0,2,"1")
	self.grid_1.SetCellValue(1,2,"2")
	self.grid_1.SetCellValue(2,2,"3")
	self.grid_1.SetCellValue(3,2,"1")
	self.grid_1.SetCellValue(4,2,"2")
	self.grid_1.SetCellValue(5,2,"3")
	self.grid_1.SetCellValue(6,2,"1")
	self.grid_1.SetCellValue(7,2,"2")
	
	self.grid_1.SetCellValue(0,3,"ACCEPT")
	self.grid_1.SetCellValue(1,3,"ACCEPT")
	self.grid_1.SetCellValue(2,3,"ACCEPT")
	self.grid_1.SetCellValue(3,3,"ACCEPT")
	self.grid_1.SetCellValue(4,3,"ACCEPT")
	self.grid_1.SetCellValue(5,3,"ACCEPT")
	self.grid_1.SetCellValue(6,3,"ACCEPT")
	self.grid_1.SetCellValue(7,3,"ACCEPT")
	
	self.grid_1.SetCellValue(0,4,"icmp")
	self.grid_1.SetCellValue(1,4,"tcp")
	self.grid_1.SetCellValue(2,4,"udp")
	self.grid_1.SetCellValue(3,4,"icmp")
	self.grid_1.SetCellValue(4,4,"icmp")
	self.grid_1.SetCellValue(5,4,"icmp")
	self.grid_1.SetCellValue(6,4,"icmp")
	self.grid_1.SetCellValue(7,4,"udp")
	
	self.grid_1.SetCellValue(0,5,"--")
	self.grid_1.SetCellValue(1,5,"--")
	self.grid_1.SetCellValue(2,5,"--")
	self.grid_1.SetCellValue(3,5,"--")
	self.grid_1.SetCellValue(4,5,"--")
	self.grid_1.SetCellValue(5,5,"--")
	self.grid_1.SetCellValue(6,5,"--")
	self.grid_1.SetCellValue(7,5,"--")
	
	self.grid_1.SetCellValue(0,6,"localhost.localdomain")
	self.grid_1.SetCellValue(1,6,"127.0.0.3")
	self.grid_1.SetCellValue(2,6,"127.0.0.3")
	self.grid_1.SetCellValue(3,6,"localhost.localdomain")
	self.grid_1.SetCellValue(4,6,"127.0.0.2")
	self.grid_1.SetCellValue(5,6,"127.0.0.3")
	self.grid_1.SetCellValue(6,6,"localhost.localdomain")
	self.grid_1.SetCellValue(7,6,"127.0.0.3")
	
	self.grid_1.SetCellValue(0,7,"anywhere")
	self.grid_1.SetCellValue(1,7,"anywhere")
	self.grid_1.SetCellValue(2,7,"anywhere")
	self.grid_1.SetCellValue(3,7,"anywhere")
	self.grid_1.SetCellValue(4,7,"anywhere")
	self.grid_1.SetCellValue(5,7,"anywhere")
	self.grid_1.SetCellValue(6,7,"anywhere")
	self.grid_1.SetCellValue(7,7,"anywhere")
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wxBoxSizer(wxVERTICAL)
sizer_1.Add(self.grid_1, 1, wxEXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade

# end of class MyFrame


if __name__ == "__main__":
app = wxPySimpleApp(0)
wxInitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()


  

  



  
  



  
  


  

  

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

Re: Send a particular packet with this python client

2006-01-24 Thread Sbaush
Now i can explain better than previous messages.This string has to be sent to another host via UDP with the previous attached simple client/server udp implementation in python. The big problem is:The packet 
MUST be like this c struct:
#define PAYLOAD_LENGHT 5000

 struct command_hdr {    int lenght; // sizeof(payload) = sizeof(int) + strlen(payload)

    unsigned char payload[PAYLOAD_LENGHT]; // the xml string} __attribute__ ((packed));
How can i do it in python?2006/1/24, Sbaush <
[EMAIL PROTECTED]>:I can specify the question, so you can request me easily...
The int should be an integer of 32 bit fixed. This is total packet size. The string should contain XML.In this example the string is taken from keyboard, so for example.
Thanks all for your helps...2006/1/24, Sbaush <[EMAIL PROTECTED]>:

Hi all, i have a python udp client/server.I would send a packed like this: |int|string| . How can i do it with tih client?Another question: buf is the total packet size?





from socket import *

# Set the socket parameters
host = "192.168.11.49"

port = 21567
buf = 1024
addr = (host,port)

# Create socket
UDPSock = socket(AF_INET,SOCK_DGRAM)

def_msg = "===Enter message to send to server===";
print "\n",def_msg# Send messages
while (1):
	data = raw_input('>> '


)
	if not data:
		break
	else:
		if(UDPSock.sendto(data,addr)):
			print "Sending message '",data,"'."

# Close socket
UDPSock.close()-- Sbaush

-- Sbaush

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

Re: Send a particular packet with this python client

2006-01-24 Thread Sbaush
I can specify the question, so you can request me easily...The int should be an integer of 32 bit fixed. This is total packet size. The string should contain XML.In this example the string is taken from keyboard, so for example.
Thanks all for your helps...2006/1/24, Sbaush <[EMAIL PROTECTED]>:
Hi all, i have a python udp client/server.I would send a packed like this: |int|string| . How can i do it with tih client?Another question: buf is the total packet size?





from socket import *

# Set the socket parameters
host = "192.168.11.49"

port = 21567
buf = 1024
addr = (host,port)

# Create socket
UDPSock = socket(AF_INET,SOCK_DGRAM)

def_msg = "===Enter message to send to server===";
print "\n",def_msg# Send messages
while (1):
	data = raw_input('>> '

)
	if not data:
		break
	else:
		if(UDPSock.sendto(data,addr)):
			print "Sending message '",data,"'."

# Close socket
UDPSock.close()-- Sbaush

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

Send a particular packet with this python client

2006-01-24 Thread Sbaush
Hi all, i have a python udp client/server.I would send a packed like this: |int|string| . How can i do it with tih client?Another question: buf is the total packet size?





from socket import *

# Set the socket parameters
host = "192.168.11.49"
port = 21567
buf = 1024
addr = (host,port)

# Create socket
UDPSock = socket(AF_INET,SOCK_DGRAM)

def_msg = "===Enter message to send to server===";
print "\n",def_msg

# Send messages
while (1):
	data = raw_input('>> '
)
	if not data:
		break
	else:
		if(UDPSock.sendto(data,addr)):
			print "Sending message '",data,"'."

# Close socket
UDPSock.close()-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Help] HOWTO Send a string???

2006-01-24 Thread Sbaush
Firstly i would like to do the Send/Receive function. In the second moment i would implement the threading with this functions. is it a good way?In your opinion where could i found a valid implementation of udp send/receive?
2006/1/23, Eric Brunson <[EMAIL PROTECTED]>:
This is a reasonably simple thing to do.  The specifications soundremarkably like a homework program I might assign in a basic networkprogramming class, but even if it isn't a school assignment, yourrequest is so broad you need to do a little background reading before we
can offer more specific help.Start by reading the Python manual section 11.16(http://docs.python.org/lib/module-SocketServer.html) which covers the
base SocketServer classes.  There's a simple Threading mix-in class thatcan be included to get your threaded model.If you read that, try to write some code and then have more specificquestions, then post back and I'll see if I can help further.
e.Sbaush wrote:> Hi all.> In my application I have to do implement a lot of networking in python> My application can create with a GUI a XML file in a string.(and now> my application can do it wow!!)
> This string has to be sended to another host. i need a python> application that send this string via UDP.> The packet of this communication is |int|payload| where payload is the> XML string.
> After the send my application has to wait for a response and has to> receive response.> For the heaven it should be implemented with separated thread. A> thread send/receive while another indipendent thread do same.
>> Have you any ideas to do it more simply as possible?> What is the best way to di it??> What is the best way to thread programming in python?>> Thanks all for your help with me!
> --> Sbaush>> --> Sbaush> >> ___> Python-Help maillist  -  
[EMAIL PROTECTED]> http://mail.python.org/mailman/listinfo/python-help>
-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: HOWTO Send a string???

2006-01-23 Thread Sbaush
oh thanks i read the howto.Why i should use pyro? What is in poor words?2006/1/23, Martin Franklin <[EMAIL PROTECTED]
>:Sbaush wrote:> Hi all.> In my application I have to do implement a lot of networking in python
> My application can create with a GUI a XML file in a string.(and now my> application can do it wow!!)> This string has to be sended to another host. i need a python application> that send this string via UDP.
> The packet of this communication is |int|payload| where payload is the XML> string.> After the send my application has to wait for a response and has to receive> response.> For the heaven it should be implemented with separated thread. A thread
> send/receive while another indipendent thread do same.>> Have you any ideas to do it more simply as possible?> What is the best way to di it??> What is the best way to thread programming in python?
>> Thanks all for your help with me!> --for python & socket how to :http://www.amk.ca/python/howto/sockets/You may also want to look at:
http://pyro.sourceforge.net/which gives you a pythonic solutionHTH,Martin.--
http://mail.python.org/mailman/listinfo/python-list-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

HOWTO Send a string???

2006-01-23 Thread Sbaush
Hi all.In my application I have to do implement a lot of networking in pythonMy application can create with a GUI a XML file in a string.(and now my application can do it wow!!)This string has to be sended to another host. i need a python application that send this string via UDP. 
The packet of this communication is |int|payload| where payload is the XML string.After the send my application has to wait for a response and has to receive response.For the heaven it should be implemented with separated thread. A thread send/receive while another indipendent thread do same.
Have you any ideas to do it more simply as possible?What is the best way to di it??What is the best way to thread programming in python?Thanks all for your help with me!-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [XML-SIG] Howto create this XML string?

2006-01-22 Thread Sbaush
Thanks all, i've perfectly undestand the way. Thanks again.2006/1/19, Luis Miguel Morillas <[EMAIL PROTECTED]>:
2006/1/19, Sbaush <[EMAIL PROTECTED]>:

Hi all.I've this XML:                



127.0.0.1"/>            How can i write this in a Python String? I would like use a xml.dom



 implementation and not a banal print...print...I can't do it... Is there anyone that can explain me what is the way?Thank you!Another taste with amara:import amara
doc = amara.create_document
(u"manager")doc.manager.xml_append(doc.xml_create_element(u'request'))doc.manager.request.xml_append(doc.xml_create_element(    u'append',    attributes={u'mode':u'INPUT'}))doc.manager.request.append.xml_append

(doc.xml_create_element(    u'method',    attributes={u'type':u'GOOD'}))doc.manager.request.append.xml_append(doc.xml_create_element(    u'source',    attributes={u'source':u'

127.0.0.1'}))doc.manager.request.append.xml_append(doc.xml_create_element(    u'action',    attributes={u'option':u'OK'}))print doc.xml(indent='yes')   

--Luis Miguel

___XML-SIG maillist  -  XML-SIG@python.org
http://mail.python.org/mailman/listinfo/xml-sig-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Howto create this XML string?

2006-01-20 Thread Sbaush
in the elementtree implementation the tostring function doesn't work with a tree, work only with an element. What is the way to put the tree in a string?2006/1/20, Fredrik Lundh <
[EMAIL PROTECTED]>:Sbaush wrote:> Is possible to have the XML in a string (for example xmlstring) and for
> printing do a print xmlstring ?most about anything that can be written to a file can be written to a stringusing the StringIO module:
http://www.effbot.org/librarybook/stringio.htmfile = StringIO.StringIO()tree.write(file)data = "">for elementtree, you can also use the tostring function:data = 
"">--http://mail.python.org/mailman/listinfo/python-list
-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Howto create this XML string?

2006-01-20 Thread Sbaush
I have a xml tree like this 





tree = ET.ElementTree(root)
How can i put tree in a string?tree is generated like this:import elementtree.ElementTree as ET
root = ET.Element("manager")
req=ET.SubElement(root,"request")app=ET.SubElement(req,"append")
app.set("mode","INPUT")met=ET.SubElement(app,"method")
met.set("type","GOOD")
src="">src.set("address","
127.0.0.1")act=ET.SubElement(app,"action")
act.set("option","OK")
tree = ET.ElementTree(root)-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Howto create this XML string?

2006-01-19 Thread Sbaush
Hi all.I've this XML:                
127.0.0.1"/>            How can i write this in a Python String? I would like use a xml.dom
 implementation and not a banal print...print...I can't do it... Is there anyone that can explain me what is the way?Thank you!-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list

Dom or MiniDom example

2006-01-19 Thread Sbaush
Hi, i'm searching for a dom or a minidom examples. I'm building a GUI. This gui should create a XML string. What's the best way to implement this? Dom, minidom or another way?Thanks.-- Sbaush

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

Re: MVC Help

2006-01-17 Thread Sbaush
Thanks!!Is there a wx example? 2006/1/17, Fredrik Lundh <[EMAIL PROTECTED]>:
"Sbaush" <[EMAIL PROTECTED]> wrote:> The View must be only the clickable button> The Control must be the event listener on the button> The Model must be the action of the button.
> If we can complete this MVC simple implementation we could publish this like> a "MVC SIMPLE TUTORIAL" because with only a button this could explain the> MVC Observer based Architecture.
if you think that an "action" is a good model, you've probably already lost trackof what MVC really is.if you want something simple, I suggest using a simple model that's updated bya simple user action.  here's a straightforward WCK example, which uses a click
counter as the model.  note that the test script creates a single model instance,and displays it in multiple views.from WCK import Widget, Controller, Observablefrom WCK import FOREGROUND, FONT # platform default
class MyModel(Observable):count = 0def increment(self):self.count += 1self.notify(None) # notify observersclass MyController(Controller):def create(self, handle):
handle("", self.handle_button_release_1)def handle_button_release_1(self, event):# update the modelmodel = event.widget.modelif model:
model.increment()class MyView(Widget):model = Noneui_controller = MyControllerdef _notify(self, event, data):# called by the model via the observable mixin
self.ui_damage() # update myselfdef setmodel(self, model):# install new modelassert isinstance(model, Observable)if self.model:self.model.removeobserver
(self._notify)self.model = modelself.model.addobserver(self._notify)def ui_handle_repair(self, draw, x0, y0, x1, y1):# repair widget contentsif not self.model:
returnfont = self.ui_font(FOREGROUND, FONT)text = str(self.model.count)draw.text((10, 10), text, font)def ui_handle_destroy(self):# cleanup (called when the widget is destroyed)
if self.model:self.model.removeobserver(self._notify)if __name__ == "__main__":# try it outfrom Tkinter import Tkroot = Tk()model = MyModel()
view = MyView(root, background="" blue")view.pack(side="left")view.setmodel(model)another_view = MyView(root, background="" yellow")another_view.pack(side="left")
another_view.setmodel(model) # shares the same model!if 0:# enable this to illustrate external updates to the modeldef tick():model.increment()    
root.after(1000, tick)tick() # start tickingroot.mainloop()--http://mail.python.org/mailman/listinfo/python-list
-- Sbaush
-- 
http://mail.python.org/mailman/listinfo/python-list