Re: Graph Theory

2006-10-06 Thread diffuser78
Thanks for all your responses.

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


Re: Graph Theory

2006-10-06 Thread diffuser78
Is there any documentation avaialbe for networkx ? I want to have an
implementation of random graphs including watts and strogatz graph.

[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  Thanks for your quick reply. Since I have not read the documentation, I
  was wondering if you can generate random graph and analyze some
  peroperties of it like clustering coefficient or graph density. I am a
  graph theory student and want to use python for development. Somebody
  told me that Python has already so much bultin. Are there any
  visualization tool which would depict the random graph generated by the
  libraries.

 networkx has several random graph generators, including:

barabasi_albert_graph
binomial_graph
erdos_renyi_graph
gnm_random_graph
gnp_random_graph
random_regular_graph
watts_strogatz_graph

 and others (e.g. via configuration_model)

 For drawing you can use pygraphviz (also available at
 networkx.lanl.gov)
 or the built-in drawing tools.

 e.g.

  from networkx import *
  no_nodes=1000
  for p in [ 0.1, 0.2, 0.3]:
 g = watts_strogatz_graph(no_nodes, 4, p)
 print density(g), average_clustering(g)

 be warned that drawing large random graphs are not overly insightful
 
 check the examples

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


shortest mean path length

2006-10-06 Thread diffuser78
Is there any function in networkx which can compute the shortest mean
path length. (Shortest length between all pairs of the nodes in the
graph). 

Thanks,

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


Graph Theory

2006-10-05 Thread diffuser78
Is there any library in Python which has implementation of graph
theoretic algorithms and models ?

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


Re: Graph Theory

2006-10-05 Thread diffuser78
Thanks for your quick reply. Since I have not read the documentation, I
was wondering if you can generate random graph and analyze some
peroperties of it like clustering coefficient or graph density. I am a
graph theory student and want to use python for development. Somebody
told me that Python has already so much bultin. Are there any
visualization tool which would depict the random graph generated by the
libraries.

Thanks for any kind of input.


[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED]:
  Is there any library in Python which has implementation of graph
  theoretic algorithms and models ?

 There are many of them, like:
 https://networkx.lanl.gov/
 Mine:
 http://sourceforge.net/projects/pynetwork/
 ...and some other.
 
 Bye,
 bearophile

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


matplotlib

2006-09-14 Thread diffuser78
Hi, I am a python newbie. I was looking for a plotting tool and
somebody told me matplotlib. But I couldnt find on google some good
starting tutorial on it.

Can somebody give some quick pointers to start off with matplotlib.

Thanks

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


Re: matplotlib

2006-09-14 Thread diffuser78
This site and webpage in particular doesn't open. I tried that too
before posting my question.

Maciej Dziardziel wrote:
 [EMAIL PROTECTED] wrote:

  Can somebody give some quick pointers to start off with matplotlib.
 
  Thanks

 http://matplotlib.sourceforge.net/tutorial.html

 --
 Maciej Fiedzia Dziardziel ([EMAIL PROTECTED])
 
 If you can read this, you are in phaser range.

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


Re: How to write a Installer for a Python App in Linux

2006-08-11 Thread diffuser78
I saw some examples and understood for most part how to write a
setpu.py.

Since I want to bundle python and wxPython along with my
application...how can I do that.

Any code gurus can throw some pointers.

Every help is appreciated.

Bruno Desthuilliers wrote:


 Look for distutil and EasyInstall (- Python Eggs)

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


Re: How to write a Installer for a Python App in Linux

2006-08-11 Thread diffuser78
Hi,

How can we freeze the python program and how will it ensure that all
the python files are packages with the programs (including python and
wxPython). Can anybody give me some pointers on this.

Every help is appreciated. Thanks.

 You could freeze the Python program. That'll ensure all the required
 files are packaged with your program, including Python itself. If you
 build a RPM from that, your users will be quite happy.
 
 Sybren

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


Including python and wxPython in distutils

2006-08-11 Thread diffuser78
I wrote a small app in python and used wxPython in it. Now, I am trying
to create an .rpm file for linux RedHat Distro. I want the ability in
my installer to install python2.4 and wxPython too along with the .py
files which are in the project.

I am trying to use distutils. Can anybody give some pointers to do this
fast ?

Every help is greatly appreciated.

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


Re: How to write a Installer for a Python App in Linux

2006-08-11 Thread diffuser78
Has anybody written a file for cx_freeze. I am running Ubuntu Linux and
downloaded version for Python2.4. When I run it I get an error saying
that I dont have GLIBC_2.4.

I couldnt find this in Synaptic too.

Any clues ?

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


Help with cx_freeze module

2006-08-11 Thread diffuser78
Has anybody written a file for cx_freeze. I am running Ubuntu Linux and
downloaded version for Python2.4. When I run it I get an error saying
that I dont have GLIBC_2.4. I searched around but couldn't find a .deb
for Ubuntu, I couldnt find this in Synaptic too.

Any clues or pointers as to how to get cx_freeze up and running.

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


Re: Client/Server Question

2006-08-10 Thread diffuser78
The subprocess module didn't work here. I tried using os.popen(), that
won't help it either.


What I am trying to achieve is that the server daemon is sitting and
listening to command from the client. As client send MaxSim it
launches MaxSim.exe and then again waits for subsequent commands.
Support client sends DrivingSim it should launch DrivingSim.exe etc.
It does till client sends a SHUTODWN message upon which it shuts down
itself.

Any pointers to achieve this more seamlessly.

Every help is greatly appreciated.

Thanks


Dennis Benzinger wrote:
 os.system() blocks until the called program has finished. Use the
 subprocess module http://docs.python.org/lib/module-subprocess.html:

 untested_code

 import subprocess
 
 subprocess.Popen(notepad)
 
 /untested_code
 
 
 Dennis

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


Re: Client/Server Question

2006-08-10 Thread diffuser78

 The recv() might return MaxiSimDriving Sim. It could return
 MaxiS on one call, and im on the next. If the remote side
 closes the connection, recv() will keep returning the empty
 string, and your program will be stuck in an infinite loop.

How to overcome this problem ?

 Did you understand Faulkner's suggustion? Anyone who connects to
 TCP port 2000 can invoke shutdown -s (which I assume shuts down
 your host).

I did, anyone who connects to port 2000 might be able to send a
shutdown and close the computer. I am aware that its not the best way
to achieve this but my app runs on a small network without actually
connecting to internet.

Can you give any tips to overcome the above mentioned problem.

 --Bryan

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


Re: Client/Server Question

2006-08-10 Thread diffuser78
I apologize.

subprocess did work for me like a charm I made a mistake in my code.
Appreciate your help.

Dennis Benzinger wrote:
 os.system() blocks until the called program has finished. Use the
 subprocess module http://docs.python.org/lib/module-subprocess.html:

 untested_code

 import subprocess
 
 subprocess.Popen(notepad)
 
 /untested_code
 
 
 Dennis

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


How to write a Installer for a Python App in Linux

2006-08-10 Thread diffuser78
Hi,

I have known python for about 3-4 months now. My knowledge is still
very limited.

I wrote a small app using wxPython. Now, I want to create an installer
for it (on Linux platform.) for the people I developed this small
utility.

These people use some customized variant of Red Hat Linux. I found on
the web python2.4 and the corresponding wxPython files.

How can I write a Installer file which will install all the needed
programs in the correct path, so that my wxPython app is ready to run
and end user doesn't need to bother installing required files.

Give me some pointers and I will try to write the script on my own.

Every help is greatly appreciated.

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


Re: paramter passing question

2006-08-09 Thread diffuser78
It partly works but I get error printed out on the console.

Traceback (most recent call last):
  File NewProject.py, line 87, in OnEdit
win = MyFrame4(self, -1, ,sim_name=sim_name)
  File NewProject.py, line 1098, in __init__
wx.Frame.__init__(self, *args, **kwds)
  File
/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_windows.py,
line 476, in __init__
newobj = _windows_.new_Frame(*args, **kwargs)
TypeError: 'sim_name' is an invalid keyword argument for this function

Larry Bates wrote:
 [EMAIL PROTECTED] wrote:
  I wrote a small app in wxPython using wxGlade as designer tool. wxGlade
  brings and writes a lot of code by itself and thats where my confusion
  started. Its about parameter passing. Here is my little confusion.
 
  ***CODE BEGINS
  class MyFrame1(wx.Frame):
  def __init__(self, *args, **kwds):
   .
   .
  def OnEdit(self, event):
   sim_name = 'some_string'
   win = MyFrame2(self, -1, )
   win.Show(True)
  
 
  class MyFrame2(wx.Frame):
  def __init__(self, *args, **kwds):
   .
   .
  def onLaunch(self, event):
   ## This function needs to use the parameter sim_name which is
  in class MyFrame1--OnEdit
  ***CODE ENDS
 
  I want to pass sim_name parameter to MyFrame2 in def OnEdit function
  but I don't know how to do it. I tried couple of things but always got
  some error. I have done some parameter passing in normal Python code
  but *args and **kwds is a little confusing.
 
  Could you please tell me how to send parameter sim_name from
  MyFrame1(in OnEdit function) and how to recieve it in MyFrame2 so that
  I can use that parameter in MyFrame2 namespace.
 
  Every help is appreciated.
 
  Thanks
 
 How about using the keyword args to pass it:

 class MyFrame1(wx.Frame):
 def __init__(self, *args, **kwds):
  .
  .
 def OnEdit(self, event):
  sim_name = 'some_string'
  win = MyFrame2(self, -1, , sim_name=sim_name)
  win.Show(True)
 

 class MyFrame2(wx.Frame):
 def __init__(self, *args, **kwds):
  .
  .
 self.sim_name=kwds.get('sim_name', 'default sim_name')

 def onLaunch(self, event):
  ## This function needs to use the parameter sim_name which is
  ## self.sim_name can be used here
 
 -Larry Bates

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


paramter passing question

2006-08-04 Thread diffuser78
I wrote a small app in wxPython using wxGlade as designer tool. wxGlade
brings and writes a lot of code by itself and thats where my confusion
started. Its about parameter passing. Here is my little confusion.

***CODE BEGINS
class MyFrame1(wx.Frame):
def __init__(self, *args, **kwds):
 .
 .
def OnEdit(self, event):
 sim_name = 'some_string'
 win = MyFrame2(self, -1, )
 win.Show(True)


class MyFrame2(wx.Frame):
def __init__(self, *args, **kwds):
 .
 .
def onLaunch(self, event):
 ## This function needs to use the parameter sim_name which is
in class MyFrame1--OnEdit
***CODE ENDS

I want to pass sim_name parameter to MyFrame2 in def OnEdit function
but I don't know how to do it. I tried couple of things but always got
some error. I have done some parameter passing in normal Python code
but *args and **kwds is a little confusing.

Could you please tell me how to send parameter sim_name from
MyFrame1(in OnEdit function) and how to recieve it in MyFrame2 so that
I can use that parameter in MyFrame2 namespace.

Every help is appreciated.

Thanks

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


Network Game in Python

2006-08-01 Thread diffuser78
I have to create a small and simple GUI app in Python which is similar
to a netwrok game. Let me expalain you. I need some suggestions. I
might use wxPython for GUI because that is the only GUI oolkit I know.

There are 6 players in the game. They are all connected though a LAN
(possible an internal network). There is one main supervirsor who
starts the game and other 5 are players.

Once the supervisor starts the game, a move goes randomly to any player
out of the 5 players. Once a player gets a move he has to act. Based on
his action next move will be generated by supervisor and sent to some
other player in the network. This process goes on untill the simulation
time ends. Winners and Loosers are decided by some point system which
supervisor keeps track of.

Some questions I have are:
1. How can I manage network messages among the players. Should
multicast be used or Actor should send the message to Supervisor and he
sends to all. ? What python modules can be handy in these things.

2. How can I manage moves among players. What move a player makes is
visible to all others in real time, so essentially all players have the
same consistent view of the game. Only the person with access can
actually make a move or carry out action. Any suggestion how to carry
out this thing.

3. Shold I use a flat file or some database in mySQL to measure points
etc ? I want to have a repository which keep tracks of all the mvoes in
the system and who played what move etc..? Any suggestions on this.

4. If you have any other input, it will be greatly appreciated.

Thanks

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


Re: Windows vs. Linux

2006-07-31 Thread diffuser78
Linux can let you do more in Python and this comes from my personal
exprience. Ubuntu Dapper should let you install drivers easily for
wireless...a little bit tweaking might be required but its worth the
effort. Python and Ubuntu rock...go fot it.

[EMAIL PROTECTED] wrote:
 Okay, once-upon-a-time I tried to start programming by learning C.  At
 the time I was younger and didn't really understand all that C had to
 offer.  I eventually moved over to Microsoft's Visual Basic.  It was
 nice to be able to design a visual application with no effort (too bad
 I didn't really learn the ins and outs of programming)

 Long story short, I want to get back into programming, and Python looks
 like a good choice for me to start with, and maybe become advanced
 with.  Right now I run Windows as my main operating system.  On my old
 laptop I ran Ubuntu, and liked it very much; however, my new laptop has
 a Broadcom wireless card, and it's not very Linux friendly.  Is Windows
 an okay enviornment in which to program under Python, or do you
 recommend that I run a dual-boot of Linux or maybe a VMWare install to
 program under Python?

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


Re: Windows vs. Linux

2006-07-31 Thread diffuser78
 I'd never recommend dual-boot for anything!
 Hardware is cheap, time and trouble is expensive.

Dual-booting if so easy and helpful, I have always found it to be
extremely useful.

You might have a bad experience but I have my laptop and desktop both
running dual boot successfully for 4 and a half years now.

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


Math package

2006-07-29 Thread diffuser78
I want to write a program which would have a 2 dimensional array of 1
billion by 1 billion. This is for computational purposes and evaluating
a mathematical concept similar to Erdos number.

Which is the best package for such programs (that would be fast
enough). 

Every help is appreciated.

Thanks

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


Re: Math package

2006-07-29 Thread diffuser78
I will write the problem a little more clearer so that you guys can
recommend me better.

In a graphs of size N ( where, N = 1e9), each node has a degree D=1000.
i.e There are overall (D*N)/2 edges in the graph. This graph needs to
be generated randomly using the program.

Now my task is to find the shortest distance from each node to every
other node. And finally I want to find is the average distance from one
node to another node in the graph. This is an average Erdos number or
equivalently what degree of seperation exists in the graph.

I can start with low values of N and D but my ultimate aim is to
simulate this graph on big values of N and D.

Every help is greatly appreciated.

Thanks


[EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED]:
  I want to write a program which would have a 2 dimensional array of 1
  billion by 1 billion. This is for computational purposes and evaluating
  a mathematical concept similar to Erdos number.

 Maybe you are talking about the edges of a graph with 1e9 nodes. This
 structure is surely quite sparse, so you don't need to store the edges
 in a matrix, you can manage is as a sparse structure, and maybe you
 don't need a Blue Gene.

 If you find ways to clean your data, reduce the vertex and arc count,
 and if you have a lot of memory, then maybe Boost Graph for Python may
 suffice:
 http://www.osl.iu.edu/~dgregor/bgl-python/
 
 Bye,
 bearophile

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


Client/Server Question

2006-07-28 Thread diffuser78
My server.py looks like this

-CODE--
#!/usr/bin/env python
import socket
import sys
import os

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = ''
port = 2000

s.bind((host,port))
s.listen(1)
conn, addr = s.accept()
print 'client is at', addr

while True:
data = conn.recv(100)
if (data == 'MaxSim'):
print 'MaxiSim'
os.system('notepad')
elif (data == 'Driving Sim'):
print 'Driving Sim'
os.system('explorer')
elif (data == 'SHUTDOWN'):
print 'Shutting down...'
os.system('shutdown -s')
conn.close()
break
---CODE
END-

I am running this above program on a windows machine. My client is a
Linux box. What I want to achieve is that server.py should follows
instructions till I send a 'SHUTDOWN' command upon which it should shut
down.

When I run this program and suppose send 'MaxSim' to it, it launches
notepad.exe fine, but then after that it doesn't accept subsequent
command. I want is that it should accept subsequent commands like
Driving Sim and launch windows explorer etc untill I send a 'SHUTDOWN'
command.

Any help on this, it will be greatly appreciated.

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


Re: Client/Server Question

2006-07-28 Thread diffuser78
Is os.system() going to be deprecated in future ?.I read somewhere.

Dennis Benzinger wrote:
 [EMAIL PROTECTED] wrote:
  My server.py looks like this
 
  -CODE--
  #!/usr/bin/env python
  import socket
  import sys
  import os
 
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  host = ''
  port = 2000
 
  s.bind((host,port))
  s.listen(1)
  conn, addr = s.accept()
  print 'client is at', addr
 
  while True:
  data = conn.recv(100)
  if (data == 'MaxSim'):
  print 'MaxiSim'
  os.system('notepad')
  elif (data == 'Driving Sim'):
  print 'Driving Sim'
  os.system('explorer')
  elif (data == 'SHUTDOWN'):
  print 'Shutting down...'
  os.system('shutdown -s')
  conn.close()
  break
  ---CODE
  END-
 
  I am running this above program on a windows machine. My client is a
  Linux box. What I want to achieve is that server.py should follows
  instructions till I send a 'SHUTDOWN' command upon which it should shut
  down.
 
  When I run this program and suppose send 'MaxSim' to it, it launches
  notepad.exe fine, but then after that it doesn't accept subsequent
  command. I want is that it should accept subsequent commands like
  Driving Sim and launch windows explorer etc untill I send a 'SHUTDOWN'
  command.
 
  Any help on this, it will be greatly appreciated.
 


 os.system() blocks until the called program has finished. Use the
 subprocess module http://docs.python.org/lib/module-subprocess.html:

 untested_code

 import subprocess
 
 subprocess.Popen(notepad)
 
 /untested_code
 
 
 Dennis

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


import question on wx ?

2006-07-27 Thread diffuser78
I have installed wx and everything looks fine. I have written a small
app that uses wx.

When I run my program from the console like
ubuntu $ python PROGRAM_NAME.py

it gives error
Traceback (most recent call last):
  File Project.py, line 6, in ?
import wx
ImportError: No module named wx


But if I run the program from SPE (Stani's Python Editor) it just runs
fine.


How can I resolve such an issue. Please help. Is my path settting worng
..?

Every help is appreciated.

Thanks

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


Re: import question on wx ?

2006-07-27 Thread diffuser78
I think what you say makes perfect sense

I am using 2.4.2 python (I typed pthon -V on console to get)

How can I find what my SPE editor is using ?




John Salerno wrote:
 [EMAIL PROTECTED] wrote:
  I have installed wx and everything looks fine. I have written a small
  app that uses wx.
 
  When I run my program from the console like
  ubuntu $ python PROGRAM_NAME.py
 
  it gives error
  Traceback (most recent call last):
File Project.py, line 6, in ?
  import wx
  ImportError: No module named wx
 
 
  But if I run the program from SPE (Stani's Python Editor) it just runs
  fine.

 It could be that the Python version you are using to launch the app from
 the console is the preinstalled version on your system and therefore
 wxPython wasn't installed into that version. Do you have multiple
 versions of Python installed? Probably SPE is using the other version
 which *does* have wxPython in it.

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


Re: import question on wx ?

2006-07-27 Thread diffuser78
That right..on my console it shows python 2.4.2 and on SPE it shows
2.4.3. The wxPython is working fine in SPE i.e with Python 2.4.3.

How can I make sure that when I type python on console I get the 2.4.3
?

Every help is greatly appreciated.

Thanks


John Salerno wrote:
 [EMAIL PROTECTED] wrote:
  I have installed wx and everything looks fine. I have written a small
  app that uses wx.
 
  When I run my program from the console like
  ubuntu $ python PROGRAM_NAME.py
 
  it gives error
  Traceback (most recent call last):
File Project.py, line 6, in ?
  import wx
  ImportError: No module named wx
 
 
  But if I run the program from SPE (Stani's Python Editor) it just runs
  fine.

 It could be that the Python version you are using to launch the app from
 the console is the preinstalled version on your system and therefore
 wxPython wasn't installed into that version. Do you have multiple
 versions of Python installed? Probably SPE is using the other version
 which *does* have wxPython in it.

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


Python Path

2006-07-27 Thread diffuser78
I have two python 2.4s on my Ubuntu Linux box. One  is Python 2.4.2 and
other is Python 2.4.3. I use SPE as an IDE for coding. I have written a
small app in wxPython. If I run it from SPE it just works fine, but if
I run it from console it gives me import wx eror.

Following is the log which you might find helpful to answer my post.


1) ***When I just type python on console I get following
[EMAIL PROTECTED]:~$ python
ActivePython 2.4.2 Build 10 (ActiveState Corp.) based on
Python 2.4.2 (#1, Jan 17 2006, 15:39:23)
[GCC 2.95.3 20010315 (SuSE)] on linux2
Type help, copyright, credits or license for more information.


2) ***AND SPE is using the following version of Python
Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2


3) ***When I type sys.path on console I get following
 sys.path
['', '/opt/ActivePython-2.4/lib/python24.zip', '/opt/ActivePython-
2.4/lib/python 2.4', '/opt/ActivePython-2.4/lib/python2.4/plat-linux2',
'/opt/ActivePython-2.4/ lib/python2.4/lib-tk',
'/opt/ActivePython-2.4/lib/python2.4/lib-dynload', '/opt/
ActivePython-2.4/lib/python2.4/site-packages']

4) ***When I type sys.path on SPE I get following
 sys.path
['/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode',
'/usr/share/spe', '/usr/lib/python24.zip', '/usr/lib/python2.4',
'/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
'/usr/lib/python2.4/lib-dynload',
'/usr/local/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages',
'/usr/lib/python2.4/site-packages/HTMLgen',
'/usr/lib/python2.4/site-packages/Numeric',
'/usr/lib/python2.4/site-packages/PIL',
'/usr/lib/python2.4/site-packages/cairo',
'/usr/lib/python2.4/site-packages/gst- 0.10',
'/usr/lib/python2.4/site-packages/gtk-2.0',
'/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode',
'/usr/lib/site-python', '/usr/lib/python2.4/site-packages/_spe',
'/usr/lib/python2.4/site-packages/_spe/plugins',
u'/home/darshan/Desktop/Project']


5) *** on which python I get the following
which python
/opt/ActivePython-2.4/bin/python


I want to get rid of ActivePython which I happend to install because I
was trying to Test the IDE by ActiveState and I think this version of
Python was installed by it.

I am happy using Python 2.4.3 but there is not way I am being able to
use it on console. 


Every help is appreciated.

Thanks

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


Re: Python Path

2006-07-27 Thread diffuser78
In my .basrc file I commented the line of ActivePyton and after reboot
everything is fine now.

I can use Python 2.4.3 even on console and SPE both.

thanks


[EMAIL PROTECTED] wrote:
 I have two python 2.4s on my Ubuntu Linux box. One  is Python 2.4.2 and
 other is Python 2.4.3. I use SPE as an IDE for coding. I have written a
 small app in wxPython. If I run it from SPE it just works fine, but if
 I run it from console it gives me import wx eror.

 Following is the log which you might find helpful to answer my post.


 1) ***When I just type python on console I get following
 [EMAIL PROTECTED]:~$ python
 ActivePython 2.4.2 Build 10 (ActiveState Corp.) based on
 Python 2.4.2 (#1, Jan 17 2006, 15:39:23)
 [GCC 2.95.3 20010315 (SuSE)] on linux2
 Type help, copyright, credits or license for more information.
 

 2) ***AND SPE is using the following version of Python
 Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
 [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2


 3) ***When I type sys.path on console I get following
  sys.path
 ['', '/opt/ActivePython-2.4/lib/python24.zip', '/opt/ActivePython-
 2.4/lib/python 2.4', '/opt/ActivePython-2.4/lib/python2.4/plat-linux2',
 '/opt/ActivePython-2.4/ lib/python2.4/lib-tk',
 '/opt/ActivePython-2.4/lib/python2.4/lib-dynload', '/opt/
 ActivePython-2.4/lib/python2.4/site-packages']

 4) ***When I type sys.path on SPE I get following
  sys.path
 ['/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode',
 '/usr/share/spe', '/usr/lib/python24.zip', '/usr/lib/python2.4',
 '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk',
 '/usr/lib/python2.4/lib-dynload',
 '/usr/local/lib/python2.4/site-packages',
 '/usr/lib/python2.4/site-packages',
 '/usr/lib/python2.4/site-packages/HTMLgen',
 '/usr/lib/python2.4/site-packages/Numeric',
 '/usr/lib/python2.4/site-packages/PIL',
 '/usr/lib/python2.4/site-packages/cairo',
 '/usr/lib/python2.4/site-packages/gst- 0.10',
 '/usr/lib/python2.4/site-packages/gtk-2.0',
 '/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode',
 '/usr/lib/site-python', '/usr/lib/python2.4/site-packages/_spe',
 '/usr/lib/python2.4/site-packages/_spe/plugins',
 u'/home/darshan/Desktop/Project']


 5) *** on which python I get the following
 which python
 /opt/ActivePython-2.4/bin/python


 I want to get rid of ActivePython which I happend to install because I
 was trying to Test the IDE by ActiveState and I think this version of
 Python was installed by it.

 I am happy using Python 2.4.3 but there is not way I am being able to
 use it on console. 
 
 
 Every help is appreciated.
 
 Thanks

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


Re: wxPython and Linux dependencies

2006-07-07 Thread diffuser78
Let me explain and give you some more details.

When I type python at the command prompt it shows the following info.
python 2.3.4 (#Feb 01 2005), GCC 3.4.3 20041212  Red Hat 3.4.3-9.EL4 on
linux2


In /usr/lib/ there are two directories called python 2.3 and python 2.4

In /usr/lib/python2.3/site-packages I could NOT find anything related
to wx and in particular

wx-2.6-gtk2-unicode
wx.pth
wxversion.py
wxversion.pyc


In /usr/lib/python2.4/ there is only one folder called site-packages
and NO other files.

So /usr/lib/python2.4/site-packages/ has only one folder called
wx-2.6-gtk2-unicode and a file called  wx.pth and another file
wx.version.py (and its compiler version wx.version.pyc). wx.pth
contains wx-2.6-gtk2-unicode

So, what my feeling is that I have python 2.3 and wx package is for
2.4. So my installed variant cannot find the wx package.

What is the easiest way from this point on to get my small wxPython app
running ???

Every help is appreciated.



Nick Vatamaniuc wrote:
 John,
 To see where Python is looking for libraries open an interactive Python
 prompt and type
  import sys
  print sys.path
 You will get a list of paths where Python will look for modules. Also
 check to see if you have the PYTHONPATH environment variable set. If
 /usr/lib is not in the path list then Python won't be able to import wx
 from there. To test your wx app, you can append to sys.path the path of
 your wx module then try to import again.

 Hope this helps,
 Nick V.



 [EMAIL PROTECTED] wrote:
  How can we find that it is not using the right version of Python ?
 
  John Salerno wrote:
   [EMAIL PROTECTED] wrote:
Error message cannot find wx
   
infact I have wxpython in /usr/lib/
   
I installed it using the rpms given on the wxPython website. Do I need
to set some path or something.
  
   Could it be that it is trying to use another, pre-installed version of
   Python -- one which doesn't have wxPython installed with it?

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


wxPython and Linux dependencies

2006-07-06 Thread diffuser78
Hi,

I wrote a small app using wxPython on a Linux distro called Ubuntu (it
is a debain derivative). I ran it on windows and it just worked
perfectly. Now, when I am trying to install the same app on a different
Linux Distro (Red Hat Linux) I cannot get it to work. This Red Hat
variant is a customized version of Red Hat of a Company where I work.
It uses python 2.3.4.
I installed wxPython and other dependencies mentioned on
http://www.wxpython.org/download.php

Can somebody give me some pointers to get it working .?

Every help is appreciated.

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


Re: wxPython and Linux dependencies

2006-07-06 Thread diffuser78
Error message cannot find wx

infact I have wxpython in /usr/lib/

I installed it using the rpms given on the wxPython website. Do I need
to set some path or something.

Nick Vatamaniuc wrote:
 cannot get it to work. is pretty broad, you are more likely to get
 help if you post an error message or any other details.

 [EMAIL PROTECTED] wrote:
  Hi,
 
  I wrote a small app using wxPython on a Linux distro called Ubuntu (it
  is a debain derivative). I ran it on windows and it just worked
  perfectly. Now, when I am trying to install the same app on a different
  Linux Distro (Red Hat Linux) I cannot get it to work. This Red Hat
  variant is a customized version of Red Hat of a Company where I work.
  It uses python 2.3.4.
  I installed wxPython and other dependencies mentioned on
  http://www.wxpython.org/download.php
 
  Can somebody give me some pointers to get it working .?
  
  Every help is appreciated.

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


Re: wxPython and Linux dependencies

2006-07-06 Thread diffuser78
How can we find that it is not using the right version of Python ?

John Salerno wrote:
 [EMAIL PROTECTED] wrote:
  Error message cannot find wx
 
  infact I have wxpython in /usr/lib/
 
  I installed it using the rpms given on the wxPython website. Do I need
  to set some path or something.

 Could it be that it is trying to use another, pre-installed version of
 Python -- one which doesn't have wxPython installed with it?

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


Client Server Connection Program

2006-07-04 Thread diffuser78
Hi,

I have the following code for a cline and server which I got from a
small tutorial on the web.

#!/ usr/bin/env python
# tms.py (SERVER)

import socket
import sys

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = ''
port = int(sys.argv[1])

s.bind((host,port))
s.listen(1)
conn, addr = s.accept()
print 'client is at', addr

data = conn.recv(100)
data = data * 1000

z = raw_input()
conn.send(data)
conn.close()

AND

#/ usr/bin/env python
# filename: tmc.py (CLIENT)

import socket
import sys

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

host = int(sys.argv[1])
port = int(sys.argv[2])

s.connect((host,port))
s.send(sys.argv[3])
i = 0
while True:
data = s.recv(100)
i+=1
if (i5):
print data
if not data:
break
print 'received', len(data), 'bytes'
s.close()


Server is installed on machine 192.168.1.4 and Client is 192.168.1.2


When I start server and the server is listening I start the clinet.

I started Client using 

python tmc.py 192.168.1.4 2000 abcxyz

where 2000 is the port number  and abcxyz is the string I pass to
server, I get the following error...

ValueError: invalid literal for int(): 192.168.1.4

How can I fix this ? I am trying to achieve the most basic level of
networking between a client and a server.

Every help is appreciated.

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


Re: Client Server Connection Program

2006-07-04 Thread diffuser78
removing int frrom host = int(sys.argv[1])  fixed the problem. Thanks
Fred!!!

Fredrik Lundh wrote:
 [EMAIL PROTECTED] wrote:

  #/ usr/bin/env python
  # filename: tmc.py (CLIENT)
 
  import socket
  import sys
 
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 
  host = int(sys.argv[1])
  port = int(sys.argv[2])

 the port number is an integer, but the host name/ip is obviously not an
 integer -- so why are you trying to convert it an integer ?

  s.connect((host,port))
  s.send(sys.argv[3])
  i = 0
  while True:
  data = s.recv(100)
  i+=1
  if (i5):
  print data
  if not data:
  break
  print 'received', len(data), 'bytes'
  s.close()
 
 
  Server is installed on machine 192.168.1.4 and Client is 192.168.1.2
 
 
  When I start server and the server is listening I start the clinet.
 
  I started Client using 
 
  python tmc.py 192.168.1.4 2000 abcxyz
 
  where 2000 is the port number  and abcxyz is the string I pass to
  server, I get the following error...
 
  ValueError: invalid literal for int(): 192.168.1.4
 
  How can I fix this ?

 by reading the *entire* trackback, and looking at the line it tells you
 to look at, before you post.
 
 /F

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


Re: efficiency question

2006-07-01 Thread diffuser78
Thanks for this thing.

http://www.python.org/doc/current/lib/module-dis.html made it more
clear.

Fredrik Lundh wrote:
 David Harvey wrote:

  Suppose I write
 
  if x in (abc, def, xyz):
  doStuff()
 
  elif x in (pqr, tuv, 123):
  doOtherStuff()
 
  elif ...
  When is python building the tuples? Does it need to build the tuple
  every time it comes through this code? Or does it somehow recognise
  that they are constant and cache them?

 when in doubt, ask the compiler:

 def code(x):
 if x in (abc, def, xyz):
 doStuff()
 elif x in (pqr, tuv, 123):
 doOtherStuff()

 import dis
 dis.dis(code)

 prints:

   2   0 LOAD_FAST0 (x)
   3 LOAD_CONST   7 (('abc', 'def', 'xyz'))
   6 COMPARE_OP   6 (in)
   9 JUMP_IF_FALSE   11 (to 23)
  12 POP_TOP

   3  13 LOAD_GLOBAL  1 (doStuff)
  16 CALL_FUNCTION0
  19 POP_TOP
  20 JUMP_FORWARD25 (to 48)
23 POP_TOP

   4  24 LOAD_FAST0 (x)
  27 LOAD_CONST   8 (('pqr', 'tuv', '123'))
  30 COMPARE_OP   6 (in)
  33 JUMP_IF_FALSE   11 (to 47)
  36 POP_TOP

   5  37 LOAD_GLOBAL  2 (doOtherStuff)
  40 CALL_FUNCTION0
  43 POP_TOP
  44 JUMP_FORWARD 1 (to 48)
47 POP_TOP
48 LOAD_CONST   0 (None)
  51 RETURN_VALUE

 so the answer is yes, in this specific case.

  (The tuples I have in mind are of course much longer than three
  elements)

 in that case, you should probably use pre-calculated sets instead of tuples.
 
 /F

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


Re: efficiency question

2006-06-30 Thread diffuser78
So nice to know this that you can compare your own code using this
methodology. I was completely unaware of this. Thank you so much.



Fredrik Lundh wrote:
 David Harvey wrote:

  Suppose I write
 
  if x in (abc, def, xyz):
  doStuff()
 
  elif x in (pqr, tuv, 123):
  doOtherStuff()
 
  elif ...
  When is python building the tuples? Does it need to build the tuple
  every time it comes through this code? Or does it somehow recognise
  that they are constant and cache them?

 when in doubt, ask the compiler:

 def code(x):
 if x in (abc, def, xyz):
 doStuff()
 elif x in (pqr, tuv, 123):
 doOtherStuff()

 import dis
 dis.dis(code)

 prints:

   2   0 LOAD_FAST0 (x)
   3 LOAD_CONST   7 (('abc', 'def', 'xyz'))
   6 COMPARE_OP   6 (in)
   9 JUMP_IF_FALSE   11 (to 23)
  12 POP_TOP

   3  13 LOAD_GLOBAL  1 (doStuff)
  16 CALL_FUNCTION0
  19 POP_TOP
  20 JUMP_FORWARD25 (to 48)
23 POP_TOP

   4  24 LOAD_FAST0 (x)
  27 LOAD_CONST   8 (('pqr', 'tuv', '123'))
  30 COMPARE_OP   6 (in)
  33 JUMP_IF_FALSE   11 (to 47)
  36 POP_TOP

   5  37 LOAD_GLOBAL  2 (doOtherStuff)
  40 CALL_FUNCTION0
  43 POP_TOP
  44 JUMP_FORWARD 1 (to 48)
47 POP_TOP
48 LOAD_CONST   0 (None)
  51 RETURN_VALUE

 so the answer is yes, in this specific case.

  (The tuples I have in mind are of course much longer than three
  elements)

 in that case, you should probably use pre-calculated sets instead of tuples.
 
 /F

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


Re: Py2exe make wxPython window looks bad

2006-06-30 Thread diffuser78
My question is not exactly related. In windows you create exe using
py2exe.

What is the Linux equivalent of it ? I am assuming you just make your
.py file executable by doint this. Please correct me if I am wrong.
***
chmoad a+c file_name.py
***


I recently wrote a small app using wxPython. It is meant to be run on
Windows and Linux both. In Windows I have created the exe as given in
py2exe.org.

What do I need to do in Linux if I need to distribute to people using
Linux who don't have all the dependent libraries installed in their
Linux distro ??

Every help is appreciated.

Thanks





zdp wrote:
 Dear all:

 I made a window program by wxPython. Split windows, treectrl, listctrl
 and textctrl are used. When I program in python, the look  feel of the
 window controls are like the windos XP look  feel, with thin and flat
 border (My os is window XP). It's natural because, as I know,  wxPython
 use native look and feel.

 But when I convert the program to EXE file by Py2exe, and run it, the
 look  feel is bad. It's just like the windows 9x. All controls has a
 thick and emboss border. However, the scrollbars look good, same as the
 window XP.

 So I'm puzzled. What's the problem and how can I get a XP look  feel
 window program? Should I add some code in my program to set the look
 and feel, or, set some options in py2exe script to force the generated
 exe has specified look and feel?

 The setup.py is very simple as following:

 -setup.py-
 import sys, os
 from distutils.core import setup
 import py2exe
 import glob

 setup( name = mainframe,
windows = [mainframe.py]
)

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


Re: efficiency question

2006-06-30 Thread diffuser78
can you please explain how to read these output...I mean how to
understand them.
A quick glance tells you that the latter approach has less number of
instructions and thats why its better. Any more insight would help a
lot.

MTD wrote:
 For the sake of comparison:

  def cod(x):
 ...   tupple1 = (abc, def, xyz)
 ...   tupple2 = (pqr, tuv, 123)
 ...   if x in tupple1:
 ...   doStuff()
 ...   elif x in tupple2:
 ...   doOtherStuff()
 ...
  dis.dis(cod)
   2   0 LOAD_CONST   7 (('abc', 'def', 'xyz'))
   3 STORE_FAST   2 (tupple1)

   3   6 LOAD_CONST   8 (('pqr', 'tuv', '123'))
   9 STORE_FAST   1 (tupple2)

   4  12 LOAD_FAST0 (x)
  15 LOAD_FAST2 (tupple1)
  18 COMPARE_OP   6 (in)
  21 JUMP_IF_FALSE   11 (to 35)
  24 POP_TOP

   5  25 LOAD_GLOBAL  3 (doStuff)
  28 CALL_FUNCTION0
  31 POP_TOP
  32 JUMP_FORWARD25 (to 60)
35 POP_TOP

   6  36 LOAD_FAST0 (x)
  39 LOAD_FAST1 (tupple2)
  42 COMPARE_OP   6 (in)
  45 JUMP_IF_FALSE   11 (to 59)
  48 POP_TOP

   7  49 LOAD_GLOBAL  4 (doOtherStuff)
  52 CALL_FUNCTION0
  55 POP_TOP
  56 JUMP_FORWARD 1 (to 60)
59 POP_TOP
60 LOAD_CONST   0 (None)
  63 RETURN_VALUE

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


String Question

2006-06-28 Thread diffuser78
mac_string = '001485e55503'  (This is the mac address of a computer.)

I am using wake on LAN python script to start computer remote.It uses
format like this 

s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255',
80))

where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.


What I do is break the string into 6 parts like this,

str01=mac_string[0:2]
str02=mac_string[2:4]
str03=mac_string[4:6]
str04=mac_string[6:8]
str05=mac_string[8:10]
str06=mac_string[10:12]

and if I use it like this

s.sendto('\xff'*6 + '\xstr01\xstr02\xstr03\xstr04\xstr05\xstr06'*16,
('192.168.1.255', 80))
I get an error


I also tried like this
s.sendto('\xff'*6 + 'mac_string'*16, ('192.168.1.255', 80))

Thiis also didnt work.


Since the MAC adddress are hexadecimal, how should I go about it here.

Please help, every help is appreciated. Thanks

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


Re: String Question

2006-06-28 Thread diffuser78
Many Thanks!! It worked like a charm.

Fredrik Lundh wrote:
 [EMAIL PROTECTED] wrote:

  mac_string = '001485e55503'  (This is the mac address of a computer.)
 
  I am using wake on LAN python script to start computer remote.It uses
  format like this 
 
  s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255',
  80))
 
  where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.

 s.sendto('\xff'*6 + binascii.unhexlify(mac_string) *16, ('192.168.1.255', 
 80))
 
 /F

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


Re: String Question

2006-06-28 Thread diffuser78
I will try this one too...thanks for your response.
Iain King wrote:
 [EMAIL PROTECTED] wrote:
  mac_string = '001485e55503'  (This is the mac address of a computer.)
 
  I am using wake on LAN python script to start computer remote.It uses
  format like this 
 
  s.sendto('\xff'*6 + '\x00\x014\x85\xe5\x55\x03'*16, ('192.168.1.255',
  80))
 
  where '\x00\x14\x85\xe5\x55\x03' is the MAC address to be used.
 
 
  What I do is break the string into 6 parts like this,
 
  str01=mac_string[0:2]
  str02=mac_string[2:4]
  str03=mac_string[4:6]
  str04=mac_string[6:8]
  str05=mac_string[8:10]
  str06=mac_string[10:12]
 
  and if I use it like this
 
  s.sendto('\xff'*6 + '\xstr01\xstr02\xstr03\xstr04\xstr05\xstr06'*16,
  ('192.168.1.255', 80))
  I get an error
 
 
  I also tried like this
  s.sendto('\xff'*6 + 'mac_string'*16, ('192.168.1.255', 80))
 
  Thiis also didnt work.
 
 
  Since the MAC adddress are hexadecimal, how should I go about it here.
 
  Please help, every help is appreciated. Thanks

 See http://docs.python.org/lib/typesseq-strings.html

 You probably want:

 s.sendto('\xff'*6 + ('\x%s\x%s\x%s\x%s\x%s\x%s' % (str01, str02, str03,
  sttr04, str05, str06))*16, ('192.168.1.255', 80))
 
 Iain

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


file writing question

2006-06-27 Thread diffuser78
Hi, I am a newbie so not very confident in file handling.

I want to write to a file atrributes in this fashion
#NameOfComputer:MAC_Address:IP_Address

--computer_details.txt
begins-
IG1:8f00142a123c:192.168.2.101
IG2:8f00142a124d:192.168.2.102
IG3:8f00142a124e:192.168.2.103
IG4:8f00142a124f:192.168.2.104
IG5:8f00142a124a:192.168.2.105
IG6:8f00142a124b:192.168.2.106
--computer_details.txt
ends---

While writing this file I insert \n after every line so that details
of every new computer goes into next line for readibility.


After I have to read this file. While reading this file \n remains
which I dont want.

Is there a neat way of writing to a file and not having \n ?

Please help

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


Re: file writing question

2006-06-27 Thread diffuser78
Thanks BrunoThis helps me.

Bruno Desthuilliers wrote:
 [EMAIL PROTECTED] wrote:
  Hi, I am a newbie so not very confident in file handling.
 
  I want to write to a file atrributes in this fashion
  #NameOfComputer:MAC_Address:IP_Address
 
  --computer_details.txt
  begins-
  IG1:8f00142a123c:192.168.2.101
  IG2:8f00142a124d:192.168.2.102
  IG3:8f00142a124e:192.168.2.103
  IG4:8f00142a124f:192.168.2.104
  IG5:8f00142a124a:192.168.2.105
  IG6:8f00142a124b:192.168.2.106
  --computer_details.txt
  ends---
 
  While writing this file I insert \n after every line so that details
  of every new computer goes into next line for readibility.
 
 
  After I have to read this file. While reading this file \n remains
  which I dont want.

 Then strip it:

 for line in open('computer_details.txt'):
name, mac, ip = line.strip().split(':')
# ...

  Is there a neat way of writing to a file and not having \n ?

 Yes : don't add the newline after every line. But note that this may
 make the file a bit more difficult to read and parse for both your
 program and you !-)

 Also, may I suggest that you read the doc for the CSV module ?


 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])

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


Re: Python taught in schools?

2006-06-25 Thread diffuser78
I think there is a Python club at UCF, Orlandomight help you
indirectly.

MilkmanDan wrote:
 I'll be a college freshman this fall, attending Florida Institute of
 Tech studying electrical engineering.

 I was considering taking some classes in programming and computer
 science, and I happened to notice that everything taught is using C++.
 After further research, it seems to me that C++ seems to be the
 dominating language in universities.

 By comparison, our local community college teaches a few classes in VB,
 Java, Javascript, C++, and for some reason, PASCAL.

 I'm certianly not against any of this, but out of curiousity does
 anyone know of a school that teaches Python?

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


Re: Python taught in schools?

2006-06-25 Thread diffuser78
I replied to a wrong post. My bad.I know for sure that there is
some kinda Python Club at UCF Orlando. There is Prof called Michael
Johnson who teaches Physics gives you an intro to Python.

http://www.physics.ucf.edu/~mdj/MinimalPython.html

Good Luck

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


Re: Network Programming in Python

2006-06-23 Thread diffuser78
How will Pyon help my cause ?

Bill Maxwell wrote:
 On 22 Jun 2006 12:02:14 -0700, [EMAIL PROTECTED] wrote:

 I am a newbie in python. I want to learn and implement a small
 networking concept. Please help me. Every help is appreciated.
 
 I have one Linux Box and one Windows PC. I want to have a daemon
 running on Windows PC which listens on some specicif port number. I
 want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
 start some application. As Windows PC recieves such a packet from Linux
 Box it executes a certain .exe file. I want to implement this concept.
 
 In short I want to remotely send command from Linux to Windows PC to
 start a particular application.


 Have you checked out Pyro (Python Remote Objects)?
 
   http://pyro.sourceforge.net/
 
 Bill

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


Network Programming in Python

2006-06-22 Thread diffuser78
I am a newbie in python. I want to learn and implement a small
networking concept. Please help me. Every help is appreciated.

I have one Linux Box and one Windows PC. I want to have a daemon
running on Windows PC which listens on some specicif port number. I
want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
start some application. As Windows PC recieves such a packet from Linux
Box it executes a certain .exe file. I want to implement this concept.

In short I want to remotely send command from Linux to Windows PC to
start a particular application.

Thanks, Every help is appreciated.

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


Re: Network Programming in Python

2006-06-22 Thread diffuser78
Thanks...I will read that up...could you give me some more headstart or
if you any sample code which I can study.

Thanks for your help, every help is appreciated


Fredrik Lundh wrote:
 [EMAIL PROTECTED] wrote:

  I am a newbie in python. I want to learn and implement a small
  networking concept. Please help me. Every help is appreciated.
 
  I have one Linux Box and one Windows PC. I want to have a daemon
  running on Windows PC which listens on some specicif port number. I
  want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
  start some application. As Windows PC recieves such a packet from Linux
  Box it executes a certain .exe file. I want to implement this concept.
 
  In short I want to remotely send command from Linux to Windows PC to
  start a particular application.

 server:

  http://docs.python.org/lib/module-SimpleXMLRPCServer.html

 client:
 
  http://docs.python.org/lib/module-xmlrpclib.html
 
 /F

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


Re: Network Programming in Python

2006-06-22 Thread diffuser78
I have Python 2.4.2 on windows and Linux both. I got an import error.
how can we obtain the twisted libraries ?



When I try to run your code
Jean-Paul Calderone wrote:
 On 22 Jun 2006 12:02:14 -0700, [EMAIL PROTECTED] wrote:
 I am a newbie in python. I want to learn and implement a small
 networking concept. Please help me. Every help is appreciated.
 
 I have one Linux Box and one Windows PC. I want to have a daemon
 running on Windows PC which listens on some specicif port number. I
 want to send a TCP/IP or UDP/IP packet from Linux box to Windows PC to
 start some application. As Windows PC recieves such a packet from Linux
 Box it executes a certain .exe file. I want to implement this concept.
 
 In short I want to remotely send command from Linux to Windows PC to
 start a particular application.
 
 Thanks, Every help is appreciated.
 

 Untested:

 from twisted.internet import protocol, reactor
 from twisted.protocols import basic

 COMMANDS = {
 xterm: (/usr/bin/xterm, {DISPLAY: :1.0}),
 }

 class CommandLauncher(basic.LineReceiver):
 def lineReceived(self, line):
 try:
 cmd, env = COMMANDS[line]
 except KeyError:
 self.sendLine(error)
 else:
 reactor.spawnProcess(None, cmd, env=env)
 self.sendLine(okay)

 f = protocol.ServerFactory()
 f.protocol = CommandLauncher
 reactor.listenTCP(12345, f)
 reactor.run()

 You should be able to telnet to this (port 12345) and type in
 names of commands for it to run.  Of course, xterm isn't a very
 good win32 program to run but I couldn't think of a better example.
 You could also write a program to send command requests to this
 server, instead of using telnet.
 
 Jean-Paul

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


Re: Network Programming in Python

2006-06-22 Thread diffuser78
I got it ...initially sourceforge page linked all old libraries..later
then got this link to twistedmatrix. Thanks.
Bruno Desthuilliers wrote:
 [EMAIL PROTECTED] a écrit :
  I have Python 2.4.2 on windows and Linux both. I got an import error.
  how can we obtain the twisted libraries ?
 
 Is google down ?

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


Re: Network Programming in Python

2006-06-22 Thread diffuser78
I just realized that you are the author of Pyro. Will it be of any help
to me ??

Irmen de Jong wrote:
 [EMAIL PROTECTED] wrote:
 
  Really, was that so hard?
 
  Python makes sockets a total breeze. You can write an 80's style HTTP
  server in less than a page of code.

 But making a *good* 80's style http/socket server is a lot of work.
 Better pick one of the high level protocols built on top of it,
 to shield you from the gory details of raw socket programming.
 
 --Irmen

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


Re: OS specific command in Python

2006-06-21 Thread diffuser78
I have a question on getpass. Since I am a newbie you might find it a
little dumb.

By using the getpass, are u trying to retrieve the username and
password of remote mahcine or local ?



Avell Diroll wrote:
 [EMAIL PROTECTED] wrote:
  When you connect (via ssh or telnet) to a remote machine, you need to
  type (manually)
  your username and your password. Programming that is never easy.
 

 This is really eased by the module getpass (std library) :

 ###

 import getpass

 login = getpass.getuser()
 password = getpass.getpass()

 ###

 If the username is different from your system login this can be changed to :

 ###

 import getpass

 login = raw_input('login: ')
 password = getpass.getpass()
 
 ###
 
 
 Python definitely comes with batteries included !

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


Re: OS specific command in Python

2006-06-21 Thread diffuser78
Hi Avell,

I want to communicate using subprocess module but my task is a little
different. May be you can guide me.

I have a linux box, from where I remotely execute all the commands. The
remote machine is windows machine. I installed an OpenSSH server for
windows to send the shutdown command. I setup the public keys in such a
way that I could login to SSH server without using password.

I used

import os
os.system('ssh [EMAIL PROTECTED] shutdown -s')


I was wondering how can I interact with an application . Since you
mentioned about subprocess module, I want a ability that my PYthon
script can actually interact with the windows box and launch and close
application there remotely.

Any suggestions on how to do this ?

Every help is appreciated.

Thanks for your time

Avell Diroll wrote:

 This is an simple way to proceed if you don't need your python script to
 know what happens to the launched process ...
 When you need to :
 * send some input to the command from the python script after it is launched
 * get the output of the command in your python script
 * get the pid associated to your command
 * wait for your command to finish
 * pipe some shell commands
 * ...
 you should use the subprocess module.

 Here is a quick example from the Python Reference Library :
 http://docs.python.org/lib/node242.html

 ##Shell Script :
 output=`dmesg | grep hda`


 ##Python Script :
 from subprocess import Popen
 p1 = Popen([dmesg], stdout=PIPE)
 p2 = Popen([grep, hda], stdin=p1.stdout, stdout=PIPE)
 output = p2.communicate()[0]

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


Remote Boot Manager Scripting (Python)

2006-06-21 Thread diffuser78
I just started to write a small project in Python. I was wondering if
there can be something like remote boot manager.

I have to remotely start a computer. It has dual boot (WinXP and
Linux).
My remote computer is Linux which will send command to remotely boot
the other computer.

Can we write python script or some utility which would let us select
the Operating System to boot ? For example If we send parameter WIN
it boots into Windows and if we send NIX it boots into Linux.

Every help is appreciated.

Thanks

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


Re: OS specific command in Python

2006-06-20 Thread diffuser78
When you connect (via ssh or telnet) to a remote machine, you need to
 type (manually)
 your username and your password. Programming that is never easy.

I have setup the public keys to AUTO LOGIN so that it doesn't ask the
password.

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


Re: OS specific command in Python

2006-06-20 Thread diffuser78
I tried the following and it seemed to work

import os
os.system('system command here')

Any comments

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


OS specific command in Python

2006-06-19 Thread diffuser78
I want to write a python program and call OS specific commands in it.
So basically, instead of typing in on the command line argument I want
to have it in a python program and let it do the action.

for example. in my program I would want to call the ssh feature like
one does on the command line

ssh [EMAIL PROTECTED]  .etc

How can I do this easily ?

Every help is appreciated.

Thanks

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


wxPython GUI designer

2006-06-18 Thread diffuser78
I am newbie learning wxPython. I tried using GUI designer called
wxGlade. When it generated code I couldnt get the same level of
flexibility as writing the code by oneself.

Any view on what you think about using GUI designer tools.

Every help is appreciated.

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


Re: wxPython GUI designer

2006-06-18 Thread diffuser78
Are there any good commercial project built with wx ? I am a newbie and
a have to write a small application in Python. I was wondering which
optin would be best for me in terms of least learning curve and getting
the final product ASAP.

Thanks

DH wrote:

 In my opinion none of the wx* or gtk* related designer tools are
 any good.  QT Designer (which can be used with pyqt) is excellent,
 however, you probably would only want to use that if you are
 developing non-commercial software or else can afford a commercial
 license from Trolltech.  For wx and gtk projects, I usually just write
 the gui by hand like you have already been doing.

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


Re: GUI in Python using wxGlade

2006-06-16 Thread diffuser78
Did you paste any code ?

Also the link for the next message is not working .


John Salerno wrote:
 [EMAIL PROTECTED] wrote:
  I am a newbie. I was looking for some code where I could a list of
  different items from a file and display it in a list box. Then give a
  user the capability to select some.
 
  Basically, reading and writing to a file and displaying them in
  different widgets...thats something I am looking for. If anybody can
  point me to some good example tutorials...I will be greatly helped.
 
  Thanks,
 
  Every help is appreciated
 

 Have you tried looking at the code in the wxPython demo? In the ListBox
 control demo, it populates a ListBox with items from a list, but you
 could easily translate that into reading from a file, I think. Here's
 the full code in case you don't have the demo:


 
  import  wx
 
  #---
 
  # This listbox subclass lets you type the starting letters of what you want 
  to
  # select, and scrolls the list to the match if it is found.
  class FindPrefixListBox(wx.ListBox):
  def __init__(self, parent, id, pos=wx.DefaultPosition, 
  size=wx.DefaultSize,
   choices=[], style=0, validator=wx.DefaultValidator):
  wx.ListBox.__init__(self, parent, id, pos, size, choices, style, 
  validator)
  self.typedText = ''
  self.log = parent.log
  self.Bind(wx.EVT_KEY_DOWN, self.OnKey)
 
 
  def FindPrefix(self, prefix):
  self.log.WriteText('Looking for prefix: %s\n' % prefix)
 
  if prefix:
  prefix = prefix.lower()
  length = len(prefix)
 
  # Changed in 2.5 because ListBox.Number() is no longer 
  supported.
  # ListBox.GetCount() is now the appropriate way to go.
  for x in range(self.GetCount()):
  text = self.GetString(x)
  text = text.lower()
 
  if text[:length] == prefix:
  self.log.WriteText('Prefix %s is found.\n' % prefix)
  return x
 
  self.log.WriteText('Prefix %s is not found.\n' % prefix)
  return -1
 
 
  def OnKey(self, evt):
  key = evt.GetKeyCode()
 
  if key = 32 and key = 127:
  self.typedText = self.typedText + chr(key)
  item = self.FindPrefix(self.typedText)
 
  if item != -1:
  self.SetSelection(item)
 
  elif key == wx.WXK_BACK:   # backspace removes one character and 
  backs up
  self.typedText = self.typedText[:-1]
 
  if not self.typedText:
  self.SetSelection(0)
  else:
  item = self.FindPrefix(self.typedText)
 
  if item != -1:
  self.SetSelection(item)
  else:
  self.typedText = ''
  evt.Skip()
 
  def OnKeyDown(self, evt):
  pass
 
 
  #---
 
  class TestListBox(wx.Panel):
  def __init__(self, parent, log):
  self.log = log
  wx.Panel.__init__(self, parent, -1)
 
  sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
'twelve', 'thirteen', 'fourteen']
 
  wx.StaticText(self, -1, This example uses the wx.ListBox 
  control., (45, 10))
  wx.StaticText(self, -1, Select one:, (15, 50))
  self.lb1 = wx.ListBox(self, 60, (100, 50), (90, 120), sampleList, 
  wx.LB_SINGLE)
  self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.lb1)
  self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.lb1)
  self.lb1.Bind(wx.EVT_RIGHT_UP, self.EvtRightButton)
  self.lb1.SetSelection(3)
  self.lb1.Append(with data, This one has data);
  self.lb1.SetClientData(2, This one has data);
 
 
  wx.StaticText(self, -1, Select many:, (220, 50))
  self.lb2 = wx.ListBox(self, 70, (320, 50), (90, 120), sampleList, 
  wx.LB_EXTENDED)
  self.Bind(wx.EVT_LISTBOX, self.EvtMultiListBox, self.lb2)
  self.lb2.Bind(wx.EVT_RIGHT_UP, self.EvtRightButton)
  self.lb2.SetSelection(0)
 
  sampleList = sampleList + ['test a', 'test aa', 'test aab',
 'test ab', 'test abc', 'test abcc',
 'test abcd' ]
  sampleList.sort()
  wx.StaticText(self, -1, Find Prefix:, (15, 250))
  fp = FindPrefixListBox(self, -1, (100, 250), (90, 120), sampleList, 
  wx.LB_SINGLE)
  fp.SetSelection(0)
 
 
  def EvtListBox(self, event):
  self.log.WriteText('EvtListBox: %s, %s, %s, %s\n' %
 (event.GetString(),
  event.IsSelection(),
  event.GetSelection(),
 

wxPython question

2006-06-16 Thread diffuser78
I tried to follow wxPython Demo examples to understand it better. I
used wxGlade to generate my code from the GUI builder.

When I try to see the code for Menu and Menubar I see a little mismatch
in the way functions are being used.

For example, wxGlade produces code like this

self.Action = wx.Menu()
self.AddComputer = wx.MenuItem(self.Action, wx.NewId(), _(Add
Computer), ,wx.ITEM_NORMAL)
self.Action.AppendItem(self.AddComputer)
## Code end

and in the demo it is gives as

self.Action = wx.Menu()
Action.append(201, Add Computer)
# Code end

Can somebody please explain this discrepancy ?

Thanks, every help is appreciated.

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


GUI in Python using wxGlade

2006-06-15 Thread diffuser78
I recently tried a hand at wxGlade and was happy to see it designs a
GUI for you in minutes. I am a newbie Python coder. I am not completely
aware of GUI programming.

I can easily make menubars etc but I am not too sure sure how to get
more windows poppping to get more information. I mean when you click
something, a new windows would open and ask for input like that. Since
I am using wxGlade and wxPythoncan you suggest me a quick tutorial
for GUI programming. 

Every help is appreciate,

Thanks

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


Re: GUI in Python using wxGlade

2006-06-15 Thread diffuser78
I am pasting my code. I created a small little GUI without any
functionality as of yet. I wanted to ask few questions on that.

[code]
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# generated by wxGlade 0.4cvs on Thu Jun 15 10:51:12 2006

import wx

class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds[style] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.panel_1 = wx.Panel(self, -1)

# Menu Bar
self.frame_1_menubar = wx.MenuBar()
self.SetMenuBar(self.frame_1_menubar)
self.File = wx.Menu()
self.CreateNewConfigFile = wx.MenuItem(self.File, wx.NewId(),
_(Create New Config File), , wx.ITEM_NORMAL)
self.File.AppendItem(self.CreateNewConfigFile)
self.OpenConfigFile = wx.MenuItem(self.File, wx.NewId(),
_(Open Config File), , wx.ITEM_NORMAL)
self.File.AppendItem(self.OpenConfigFile)
self.EditConfigFile = wx.MenuItem(self.File, wx.NewId(),
_(Edit Config File), , wx.ITEM_NORMAL)
self.File.AppendItem(self.EditConfigFile)
self.Close = wx.MenuItem(self.File, wx.NewId(), _(Close), ,
wx.ITEM_NORMAL)
self.File.AppendItem(self.Close)
self.Exit = wx.MenuItem(self.File, wx.NewId(), _(Exit), ,
wx.ITEM_NORMAL)
self.File.AppendItem(self.Exit)
self.frame_1_menubar.Append(self.File, _(File))
self.Action = wx.Menu()
self.AddComputer = wx.MenuItem(self.Action, wx.NewId(), _(Add
Computer), , wx.ITEM_NORMAL)
self.Action.AppendItem(self.AddComputer)
self.Shutdown = wx.MenuItem(self.Action, wx.NewId(),
_(Shutdown...), , wx.ITEM_NORMAL)
self.Action.AppendItem(self.Shutdown)
self.ShutdownAll = wx.MenuItem(self.Action, wx.NewId(),
_(Shutdown All), , wx.ITEM_NORMAL)
self.Action.AppendItem(self.ShutdownAll)
self.frame_1_menubar.Append(self.Action, _(Action))
self.Help = wx.Menu()
self.Tutorial = wx.MenuItem(self.Help, wx.NewId(),
_(Tutorial), , wx.ITEM_NORMAL)
self.Help.AppendItem(self.Tutorial)
self.AboutUs = wx.MenuItem(self.Help, wx.NewId(), _(About
us), , wx.ITEM_NORMAL)
self.Help.AppendItem(self.AboutUs)
self.frame_1_menubar.Append(self.Help, _(Help))
# Menu Bar end
self.frame_1_statusbar = self.CreateStatusBar(1, 0)

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

def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle(_(Test))
self.SetSize((600, 450))
self.frame_1_statusbar.SetStatusWidths([-1])
# statusbar fields
frame_1_statusbar_fields = [_(Test Application)]
for i in range(len(frame_1_statusbar_fields)):

self.frame_1_statusbar.SetStatusText(frame_1_statusbar_fields[i], i)
# end wxGlade

def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade

# end of class MyFrame


class MyApp(wx.App):
def OnInit(self):
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, )
self.SetTopWindow(frame_1)
frame_1.Show()
return 1

# end of class MyApp

if __name__ == __main__:
import gettext
gettext.install(app) # replace with the appropriate catalog name

app = MyApp(0)
app.MainLoop()
[/code]

If I click on any of the items of the File Menu, say I click on Open
config File, I want a new windows to come up.

My questions is when I create a new Frame/Windows in wxGlade, will it
be wxFrame or wxMDI Frame..which one should I choose and why ?

I am not completely aware of all the small tools that wxGlade gives and
how to place them.


Any kind of help is greatly appreciated.

Thanks



 Without having time to go into a full, the way to proceed with Glade
 (unless I am mistaken) is to design each window independently of the
 others, and to use a button press in one window to create an instance of
 another type of window.

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


Re: GUI in Python using wxGlade

2006-06-15 Thread diffuser78
I am a newbie. I was looking for some code where I could a list of
different items from a file and display it in a list box. Then give a
user the capability to select some.

Basically, reading and writing to a file and displaying them in
different widgets...thats something I am looking for. If anybody can
point me to some good example tutorials...I will be greatly helped.

Thanks,

Every help is appreciated

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


Customized Boot Manager in Python

2006-06-13 Thread diffuser78
I have to create a small visual interface program called as Boot
Manager which is customized accoring to the needs.

I have around 8 pc's and 2 linux boxes. One Linux box is always on and
all other are closed in sleep state.

I have to perform the following things:

1. Boot up all of them. I used Wake on LAN and wrote a small python
script for that. It works fine.
2. To shutdown all pc's when the work is done. For this I installed an
OpenSSH server for Windows in PC. When I send a command using ssh it
shuts it down.


Now, I have to create a visual interface for such kind of small
program.

I have 2 questions
(i) How can we use operating system specific commands like ssh within
the python program (ii) Which grphics library (wxPython or any other)
would be the fastest with least learning curve to get this thing done.

Thanks

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


Python script for remotely shutting down Windows PC from Linux ?

2006-05-16 Thread diffuser78
I am a newbie in Python and want your help in writing python script.

I have to remotely shut the windows px from linux box. I run OpenSSH on
windows PC. I remotely connect it from Linux box using


ssh [EMAIL PROTECTED]# connects me fine now without problems
(LOCAL)

Next, I wrote a script that would log me in and also shut the windows
pc down, so I wrote a script

ssh [EMAIL PROTECTED]  # connects me fine now without problems (LOCAL)
shutdown -s# This is a windows command (REMOTE)

Now, when I run this script, it successfully logs me into the windows
box but doesn't run the second part of the script which is to shut down
the windows PC. Can you please tell me why ??

Is there a way using Python script to perform this operation ?

Every help is appreciated.

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


Re: Python script for remotely shutting down Windows PC from Linux ?

2006-05-16 Thread diffuser78
 ssh [EMAIL PROTECTED] shutdown -s

Than indeed workedThanks

  use the subprocess module or shellutils to execute the above.

I am a python newbie and how easy or difficult it is using the sub
process module and shell utils.

Thanks,

I really appreciate your help.

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


listener program in Python

2006-05-12 Thread diffuser78
I want to write a simple clinet/server program that does the following.

On Windows, the program listens to the request from linux box

On Linux Box, client program send server a shutdown request and the
program at server i.e windows shuts windows sown,

I basically want to remotely shut down windows from linux and write
such a program in python.

Every help is appreciated.

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


Re: Memory leak in Python

2006-05-10 Thread diffuser78
Sure, are there any available simulators...since i am modifying some
stuff i thought of creating one of my own. But if you know some
exisiting simlators , those can be of great help to me.

Thanks

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


Re: Memory leak in Python

2006-05-10 Thread diffuser78
With 1024 nodes it runs fine...but takes around4 hours to run on AMD
3100.

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


Re: Memory leak in Python

2006-05-10 Thread diffuser78
I ran simulation for 128 nodes and used the following

oo = gc.get_objects()
print len(oo)

on every time step the number of objects are increasing. For 128 nodes
I had 1058177 objects.

I think I need to revisit the code and remove the referencesbut how
to do that. I am still a newbie coder and every help will be greatly
appreciated.

thanks

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


Re: Memory leak in Python

2006-05-09 Thread diffuser78
I am using Ubuntu Linux.

My program is a simulation program with four classes and it mimics bit
torrent file sharing systems on 2000 nodes. Now, each node has lot of
attributes and my program kinds of tries to keep tab of everything. As
I mentioned its a simulation program, it starts at time T=0 and goes on
untill all nodes have recieved all parts of the file(BitTorrent
concept). The ending time goes to thousands of seconds. In each sec I
process all the 2000 nodes.

Psuedo Code

Time = 0
while (True){
For all nodes in the system{
Process + computation
}
   Time++
   If (DownloadFinished == True) exit;
}


Dennis Lee Bieber wrote:
 On 8 May 2006 18:15:02 -0700, [EMAIL PROTECTED] declaimed the
 following in comp.lang.python:

  I have a python code which is running on a huge data set. After
  starting the program the computer becomes unstable and gets very
  diffucult to even open konsole to kill that process. What I am assuming
  is that I am running out of memory.
 
  What should I do to make sure that my code runs fine without becoming
  unstable. How should I address the memory leak problem if any ? I have
  a gig of RAM.
 
   Does the memory come back after the process exits?

   You don't show any sample of code or data... Nor do you mention what
 OS/processor is involved.

   Many systems do not return /allocated/ memory to the OS until the
 top-level process exits, even if the memory is freed from the
 viewpoint of the process.
 --
   WulfraedDennis Lee Bieber   KD6MOG
   [EMAIL PROTECTED]   [EMAIL PROTECTED]
   HTTP://wlfraed.home.netcom.com/
   (Bestiaria Support Staff:   [EMAIL PROTECTED])
   HTTP://www.bestiaria.com/

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


Re: Memory leak in Python

2006-05-09 Thread diffuser78
The amount of data I read in is actually small.

If you see my algorithm above it deals with 2000 nodes and each node
has ot of attributes.

When I close the program my computer becomes stable and performs as
usual. I check the performance in Performance monitor and using top
and the total memory is being used and on top of that around half a gig
swap memory is also being used.

Please give some helpful pointers to overcome such memory errors.

I revisited my code to find nothing so obvious which would let this
leak happen. How to kill cross references in the program. I am kinda
newbie and not completely aware of the finetuning such programming
process.

Thanks


bruno at modulix wrote:
 [EMAIL PROTECTED] wrote:
  I have a python code which is running on a huge data set. After
  starting the program the computer becomes unstable and gets very
  diffucult to even open konsole to kill that process. What I am assuming
  is that I am running out of memory.
 
  What should I do to make sure that my code runs fine without becoming
  unstable. How should I address the memory leak problem if any ? I have
  a gig of RAM.
 
  Every help is appreciated.

 Just a hint : if you're trying to load your whole huge data set in
 memory, you're in for trouble whatever the language - for an example,
 doing a 'buf = openedFile.read()' on a 100 gig file may not be a good
 idea...



 --
 bruno desthuilliers
 python -c print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
 p in '[EMAIL PROTECTED]'.split('@')])

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


Memory leak in Python

2006-05-08 Thread diffuser78
I have a python code which is running on a huge data set. After
starting the program the computer becomes unstable and gets very
diffucult to even open konsole to kill that process. What I am assuming
is that I am running out of memory.

What should I do to make sure that my code runs fine without becoming
unstable. How should I address the memory leak problem if any ? I have
a gig of RAM.

Every help is appreciated.

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


Re: Memory leak in Python

2006-05-08 Thread diffuser78
Its kinda 65o lines of code...not the best idea to paste the code.
[EMAIL PROTECTED] wrote:
 Can you paste an example of the code you're using?

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


Re: cross platform libraries

2006-05-05 Thread diffuser78
Hi Ravi,

Do you have any idea how to perform such triigers ?
Every help is appreciated.


Ravi Teja wrote:
 No! That's not the way things work. Such code needs to run locally (in
 this case, Windows). You can run this program as a daemon on Windows
 with some nice simple remote interface (Eg: xmlrpc) and send a message
 to trigger the shutdown.

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


Re: cross platform libraries

2006-05-05 Thread diffuser78
I went to this webpage

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649

Isn't it supposed to run on the network and close the connected
machine.

Every help is appreciate,


Dennis Lee Bieber wrote:
 On 4 May 2006 09:57:15 -0700, [EMAIL PROTECTED] declaimed the
 following in comp.lang.python:

  I am using python on a linux terminal.
 
  I want to shutdown a remote windows box. I found a script which does
  something like this. My question is can we use windows libraries in
  linux as follows 
 
  import win32api
  import win32con
  import win32netcon
  import win32security
  import win32wnet
 
   That set... HIGHLY UNLIKELY... They all rely upon having the M$
 kernel DLLs available...

   Now, if the remote box is running a telnet server, you might be able
 to telnet over (logging in as the boxes admin account) and initiate a
 shutdown from it... (I seem to have a shutdown.exe on my system).
 --
   WulfraedDennis Lee Bieber   KD6MOG
   [EMAIL PROTECTED]   [EMAIL PROTECTED]
   HTTP://wlfraed.home.netcom.com/
   (Bestiaria Support Staff:   [EMAIL PROTECTED])
   HTTP://www.bestiaria.com/

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


Re: cross platform libraries

2006-05-05 Thread diffuser78
Can we have some program in Linux which shuts down the windows computer
remotely.

Every help is appreciated.


Max Erickson wrote:
 [EMAIL PROTECTED] wrote in
 news:[EMAIL PROTECTED]:

  I went to this webpage
 
  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649
 
  Isn't it supposed to run on the network and close the connected
  machine.

 That code uses the windows libraries on the machine it is run on to
 generate a request to the networked machine to shutdown. The code
 executes locally and sends the request over the network.

  Every help is appreciate,
 

 If you have some way of remotely running programs on the windows
 machine(ssh, telnet, etc.), you might try pstools:

 http://www.sysinternals.com/Utilities/PsTools.html
 
 specifically, psshutdown.
 
 max

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


Re: Wake on LAN and Shutdown for Windows and Linux

2006-05-04 Thread diffuser78
Any help is appreciated

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


cross platform libraries

2006-05-04 Thread diffuser78
I am using python on a linux terminal.

I want to shutdown a remote windows box. I found a script which does
something like this. My question is can we use windows libraries in
linux as follows 

import win32api
import win32con
import win32netcon
import win32security
import win32wnet

def shutdown(parameters):
OTHER CODE HERE

Every help is appreciated.

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


Re: Wake on LAN and Shutdown for Windows and Linux

2006-05-03 Thread diffuser78
Thanks, In fact I checked that.

I thought that any other literature would help.


David Murmann wrote:
 [EMAIL PROTECTED] schrieb:
  How can I shutdown Windows box from my Main (Linux) ?

 Have you seen this?

 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/360649

 it probably won't work on linux (maybe with wine or similar?), but you
 can try to invoke this script on a windows machine somehow...
 
 have fun, David.

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


Re: Wake on LAN and Shutdown for Windows and Linux

2006-05-03 Thread diffuser78
because you can write scripts in python so easily as compared to other
scripting languages.

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


Wake on LAN and Shutdown for Windows and Linux

2006-05-02 Thread diffuser78
I am using 8 computers on a small network. I have one Main computer
which should be able to remotely start other computers. I used Wake on
LAN to start them all.

My Main computer is Linux.

Other 4 are Windows and 3 are Linux.

How can I shutdown Windows box from my Main (Linux) ?

Also, How can I shutdown other Linux terminals from my Main (Linux) ?


Help is appreciated.

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


Automated Graph Plotting in Python

2006-04-08 Thread diffuser78
My python program spits lot of data. I take that data and plot graphs
using OfficeOrg spredsheet. I want to automate this task as this takes
so much of time. I have some questions.

1. Which is the best graph plotting utility in python or linux. Can I
write a code in such a way that my python code automatically gives me a
graph. I know little about gnuplot. If you know any better tool without
much learning curve please tell me in Linux.

2. I want to write a script such that my python code writes to a file,
some graph utility like gnuplot takes that data from the file and I get
my graph ready made. Do you think its possible ?

Any feedback regarding above is appreciated.

Thanks

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


wxPython Question

2006-04-07 Thread diffuser78
I am learning wxPython for one of my projects.

I was wondering if there is drag and  drop in any Python IDE like there
is Visual Basic where you select an object like command_button and put
onto the frame. Is there any help to make life easier in Python.

Every help is greatly appreciated,

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


Re: performance degradation when looping through lists

2006-04-07 Thread diffuser78
Hi,

I wrote a program some days back and I was using lists heavily for
performing operations such as pop, remove, append. My list size was
around 1024x3 and there were around 20 different objects like this.

What I want to ask you is that my program also degraded over a period
of time. I cannot post the code as its lot of code.

 But I want to ask a question why List degrade. What other alternative
for lists is a faster measure. 

Eveyr help is greatly appreciated,

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


Re: wxPython Question

2006-04-07 Thread diffuser78
Can we download wxPython doc as an offline folder because if I dont
have internet its difficult to have the access to all the docs.

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


Re: wxPython Question

2006-04-07 Thread diffuser78
Thanks, I use Ubuntu Linux and there is tool called xchm which lets you
do that.


RunLevelZero wrote:
 Well you will need to download the  docs demos and tools  and that
 contains a windows help file that is easily searchable.  If you run
 Linux there is a Gnome tool to run the help file in Linux if you so
 wish.

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


Re: Newbie wxPython questions.

2006-04-07 Thread diffuser78
I am also a newbie and learning like you are. I was wondering if do you
know any wxPython forum just for GUIs ?
Good luck with your project and hope that some guru helps us out.

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


GUI issues in Python

2006-04-06 Thread diffuser78
Hi,

I want to create a GUI where a user can select drag and drop kind of
boxes, circles and make connections between them.

This is basically for depicting states and dependencies. I am writing a
program where I let the user input states and dependencies in a certain
domain. Based on input given by user in the GUI, I grab it and run my
algorithm to generate the output.

I am wondering if there is any library like that in Python, or if
anybody of you has done something similar in past, could you post some
pointers.

thanks

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


Re: GUI issues in Python

2006-04-06 Thread diffuser78
My question basically revolves around... that I dont want to draw
circles and boxes for drawing purposes.

I want the end user to be able to draw the GUI boxes and circles and
makes connection to depict states and dependencies. So its a little
unconventional and more like a SIMULATION TOOL.

I am pretty sure Python must have something like this. Any idea how to
go about it.

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


Re: GUI issues in Python

2006-04-06 Thread diffuser78
Thanks Daniel, I really think that this should be the solution to my
problem.

A quick Question...is wxPython Operating System dependent or it can be
used with anu OS like Linux, Windows and Mac ?

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


specialized GUI

2006-04-05 Thread diffuser78
I am new to python. I got  a new project where I have to create a GUI
and
attch my code to it.

The GUI should look like  vsTASKER  www.virtualsim.com

I mean GUI lets user create diagram, and my code should read that
diagram and run the algorithm.

Do you know any other tool like this where I can integrate my code
with.

Every help is appreciated

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


how to convert string

2006-04-05 Thread diffuser78
I want to print number 0 to 9 in one line like this
0 1 2 3 4 5 6 7 8 9

if I do like this, it prints in different lines

for i in xrange(10):
print i

so i tried like this

str = 
for i in xrange(10):
str = i +  
print str

but i want to know how convert int i to string.

Every help is appreciate.

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


how to comment lot of lines in python

2006-03-30 Thread diffuser78
Like in C we comment like
/*
Bunch of lines of code
*/

Should we use docstring  

Or there is something else too ??

Every help is appreciated.

Thanks

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


GUI in python

2006-03-29 Thread diffuser78
Hi,

I am a python newbie and have used it for about a month. I want to make
a simple GUI app in Python ( I take input form user and do processing
and show results).

Which gui package is good for me. I need to do it quick and I would not
want a long learning curve.

I was taking look at wxPython, pyGTK etc.


Please suggest me the most simplest and easiest one as I dont need
super cool aesthetics just a plain simple GUI app.

Thanks

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


python question about classes

2006-03-13 Thread diffuser78
I have following two classes
Code:

## file_A.py
class A(object):
## a contains is instances of A
a= [ ] def __init__(self, node):
self.nodes_in_A = []
self.nodes_in_A.append(node) packet_queue = [ ] ...etc

## file_B.py
import A
class B(object):
## n contains instances of B
n = [ ] def some_func(self):
_len = len (A.A.a[0].packet_queue)


I get an error AttributeError: 'A' object has no attribute
'packet_queue'


Can you please explain me ...why ? and How to fix this ?

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


Python and C

2006-03-10 Thread diffuser78
I was a C Programmer for a while. Lately started to learn Python for
one small project at school. I joined a small company where they use
C++ for development.

Can we use Python and C together ? I mean create some classes in Python
and some number crunching algorithms coded in C (for speed) and
integreate both of them.

Could somebody just show a real small example or give pointers to the
same.

Thanks

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


  1   2   >