Re: CONNECTION TIMED OUT ERROR using urllib2

2008-12-04 Thread rishi pathak
Before executing script do
export http_proxy=http://:/


On Fri, Dec 5, 2008 at 12:06 PM, svalbard colaco
<[EMAIL PROTECTED]>wrote:

> Hi rishi,
>
> Thanks for ur reply,
> yes i set the following enviroment variables (FC6 platform)
> http_proxy,http_user,http_password
>
> But i get the same error; Can u tell me which other  variables i need to
> set or am i going wrong in the syntax of these
> variables?
>
> Regards
> sv
>
>
> On Fri, Dec 5, 2008 at 11:57 AM, rishi pathak <[EMAIL PROTECTED]>wrote:
>
>> Are you sitting behind a proxy. If so then you have to set proxy for http
>>
>> On Fri, Dec 5, 2008 at 11:47 AM, svalbard colaco <
>> [EMAIL PROTECTED]> wrote:
>>
>>> Hi all
>>>
>>> I have written a small code snippet to open a URL using urllib2 to open a
>>> web page , my python version is 2.4 but i get an urlopen error called
>>> connection timed out
>>>
>>> The following is the code snippet
>>>
>>> *import urllib2
>>>
>>> f = urllib2.urlopen('http://www.google.com/')
>>> print f.read(100)*
>>>
>>>
>>> where as the same url http://www.google.com/ works through my browser.
>>>
>>> The following is the back trace :
>>>
>>> File "test_url.py", line 3, in ?
>>> f = urllib2.urlopen('http://www.google.com/')
>>>   File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
>>> return _opener.open(url, data)
>>>   File "/usr/lib/python2.4/urllib2.py", line 358, in open
>>> response = self._open(req, data)
>>>   File "/usr/lib/python2.4/urllib2.py", line 376, in _open
>>> '_open', req)
>>>   File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
>>> result = func(*args)
>>>   File "/usr/lib/python2.4/urllib2.py", line 1021, in http_open
>>> return self.do_open(httplib.HTTPConnection, req)
>>>   File "/usr/lib/python2.4/urllib2.py", line 996, in do_open
>>> raise URLError(err)
>>> *urllib2.URLError: 
>>>
>>>
>>> Any pointers in this regard will be of great help.
>>>
>>> Thanking you'll in advance.
>>>
>>> Regards,
>>> sv
>>>
>>>
>>>
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>>
>>
>>
>> --
>> Regards--
>> Rishi Pathak
>> Pune-Maharastra
>>
>
>


-- 
Regards--
Rishi Pathak
Pune-Maharastra
--
http://mail.python.org/mailman/listinfo/python-list


Re: CONNECTION TIMED OUT ERROR using urllib2

2008-12-04 Thread rishi pathak
Are you sitting behind a proxy. If so then you have to set proxy for http

On Fri, Dec 5, 2008 at 11:47 AM, svalbard colaco
<[EMAIL PROTECTED]>wrote:

> Hi all
>
> I have written a small code snippet to open a URL using urllib2 to open a
> web page , my python version is 2.4 but i get an urlopen error called
> connection timed out
>
> The following is the code snippet
>
> *import urllib2
>
> f = urllib2.urlopen('http://www.google.com/')
> print f.read(100)*
>
>
> where as the same url http://www.google.com/ works through my browser.
>
> The following is the back trace :
>
> File "test_url.py", line 3, in ?
> f = urllib2.urlopen('http://www.google.com/')
>   File "/usr/lib/python2.4/urllib2.py", line 130, in urlopen
> return _opener.open(url, data)
>   File "/usr/lib/python2.4/urllib2.py", line 358, in open
> response = self._open(req, data)
>   File "/usr/lib/python2.4/urllib2.py", line 376, in _open
> '_open', req)
>   File "/usr/lib/python2.4/urllib2.py", line 337, in _call_chain
> result = func(*args)
>   File "/usr/lib/python2.4/urllib2.py", line 1021, in http_open
> return self.do_open(httplib.HTTPConnection, req)
>   File "/usr/lib/python2.4/urllib2.py", line 996, in do_open
> raise URLError(err)
> *urllib2.URLError: 
>
>
> Any pointers in this regard will be of great help.
>
> Thanking you'll in advance.
>
> Regards,
> sv
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


-- 
Regards--
Rishi Pathak
Pune-Maharastra
--
http://mail.python.org/mailman/listinfo/python-list


Re: return a value to shell script

2008-11-12 Thread rishi pathak
Look at os._exit()

On Wed, Nov 12, 2008 at 6:36 PM, devi thapa <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I am executing a python script in a shell script.  The python script
> actually returns a value.
> So, can I get the return value in a shell script? If yes, then help me out.
>
> Regards,
> Devi
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards--
Rishi Pathak
Pune-Maharastra
--
http://mail.python.org/mailman/listinfo/python-list


Re: How can I handle the char immediately after its input, without waiting an endline?

2008-10-22 Thread rishi pathak
The below piece of code should give you some understanding

import tty
import sys
tty.setraw(sys.stdin.fileno())
char=''
print "Press x to exit"
while char != 'x' :
char = sys.stdin.read(1)
print "You entered : ",char
# Your code here


On Wed, Oct 22, 2008 at 2:34 PM, Lave <[EMAIL PROTECTED]> wrote:

> Hi, all.
>
> I'm a new comer. So This question maybe sutpid.:)
>
> I want to write something that handle every char immediately after its
> input. Then tehe user don't need to type [RETURN] each time. How can I
> do this?
>
> Thanks in advance.
>
>
> --
> Regards
>
> Lave
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards--
Rishi Pathak
Pune-Maharastra
--
http://mail.python.org/mailman/listinfo/python-list


Re: running a daemon in python

2008-02-25 Thread rishi pathak
Use the function goDaemon just before starting the server loop:

###Begin Module###
import os
import sys
# Default daemon parameters.
# File mode creation mask of the daemon.
UMASK = 0
# Default working directory for the daemon.
WORKDIR = "/"
# Default maximum for the number of available file descriptors.
MAXFD = 1024
# The standard I/O file descriptors are redirected to /dev/null by default.
if (hasattr(os, "devnull")):
   REDIRECT_TO = os.devnull
else:
   REDIRECT_TO = "/dev/null"
def goDaemon():
   try:
  pid = os.fork()
   except OSError, e:
  raise Exception, "%s [%d]" % (e.strerror, e.errno)
   if (pid == 0):   # The first child.
  os.setsid()
  try:
 pid = os.fork()# Fork a second child.
  except OSError, e:
 raise Exception, "%s [%d]" % (e.strerror, e.errno)
  if (pid == 0):# The second child.
 os.chdir(WORKDIR)
 os.umask(UMASK)
  else:
 os._exit(0)
   else:
  os._exit(0)   # Exit parent of the first child.
   import resource
   maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
   if (maxfd == resource.RLIM_INFINITY):
  maxfd = MAXFD
   for fd in range(0, maxfd):
  try:
 os.close(fd)
  except OSError:   # ERROR, fd wasn't open to begin with (ignored)
 pass
   os.open(REDIRECT_TO, os.O_RDWR)  # standard input (0)
   os.dup2(0, 1)# standard output (1)
   os.dup2(0, 2)# standard error (2)
   return(0)
###End Module###

On Tue, Feb 26, 2008 at 12:06 PM, bharath venkatesh <[EMAIL PROTECTED]>
wrote:

> hi ..
>hi i want a program to start running as daemon in background .. my
> program is server listen to a client ... so i want to make that program run
> as daemon .. when i execute the program the program for ex server.py it
> should automatically start running as daemon in the background even if i
> close the terminal it shouldn't stop executing.. (right now if i close the
> terminal the process exits) can any one tell how to do it  in python as i
> have implemented the server  in python  ...
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
Regards--
Rishi Pathak
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: standalone python web server

2007-12-26 Thread rishi pathak
See if this helps
www.*django*project.com


On 12/27/07, eric <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I want to setup simple python web server and I want it to just unzip
> and run, without any installation steps (have no right to do it).
>
> I've tried to write by myself, however, I find I am getting into more
> details like processing image file, different file type(like FLV) ..
> etc. Any recommendation or tools suggested for me?
>
> Thanks,
> Eric
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
Regards--
Rishi Pathak
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Happy Christmas Pythoneers

2007-12-23 Thread rishi pathak
Is santa clause subscribed to the list .
I want a gift:)

On 12/24/07, Paddy <[EMAIL PROTECTED]> wrote:
>
> After quite enjoying participating in the group in 2007, I'd like to
> wish you all a Merry Xmas.
>
> - Paddy.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards--
Rishi Pathak
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: ['a', 'b'][True] results 'b' But how?

2007-07-05 Thread rishi pathak

True stands for 1 and False stands for 0
so list[True] is equivalent to list[1]
and list[False] is equivalent to list[0]

On 7/5/07, kath <[EMAIL PROTECTED]> wrote:


Hi,

Can any one please tell me how is the following code is working?
['a','b'] is a list of string, and [True] is list of boolean value.
How is it making effect?


>>> ['a','b] [True]
'b'
>>> ['a','b'] [False]
'a'
>>> ['a','b']['some_string' == r'some_string']
'b'
>>> ['a','b']['some_string' == r'somestring']
'a'




Thanks in advance,
regards,
kath.

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Execute script on remote computer

2007-06-19 Thread rishi pathak

Does the script resides on the remote machine or do we have to transfer the
script to the remote machine.If remote and agent machine are linux then you
can use rsh/ssh to do so.

On 6/19/07, Vikas Saini <[EMAIL PROTECTED]> wrote:


 I am trying to run the agent on one machine that will execute the script
of a remote machine.

Could you please help me in this regards.



vikas


 "Legal Disclaimer: This electronic message and all contents contain
information from Cybage Software Private Limited which may be privileged,
confidential, or otherwise protected from disclosure. The information is
intended to be for the addressee(s) only. If you are not an addressee, any
disclosure, copy, distribution, or use of the contents of this message is
strictly prohibited. If you have received this electronic message in error
please notify the sender by reply e-mail to and destroy the original message
and all copies. Cybage has taken every reasonable precaution to minimize the
risk of malicious content in the mail, but is not liable for any damage you
may sustain as a result of any malicious content in this e-mail. You should
carry out your own malicious content checks before opening the e-mail or
attachment."
www.cybage.com
--
http://mail.python.org/mailman/listinfo/python-list





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Good Python style?

2007-05-31 Thread rishi pathak

What if I want to process lines.In this case I would have to iterate over
the set and do the processing

On 5/31/07, Andreas Beyer <[EMAIL PROTECTED]> wrote:


Hi,

I found the following quite cryptic code, which basically reads the
first column of some_file into a set.
In Python I am used to seeing much more verbose/explicit code. However,
the example below _may_ actually be faster than the usual "for line in
..."
Do you consider this code good Python style? Or would you recommend to
refrain from such complex single-line code??

Thanks!
Andreas

inp = resource(some_file)
# read first entries of all non-empty lines into a set
some_set = frozenset([line.split()[0] for line in \
  filter(None, [ln.strip() for ln in inp])])
--
http://mail.python.org/mailman/listinfo/python-list





--
Regards--
Rishi Pathak
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Usage of the __and__ method

2007-05-30 Thread rishi pathak

This works perfectly well.
class Person:
  def __init__(self,name):
  self.name = name
  def print_name(self):
  print self.name
  def __and__(self,other):
  print "self.name : ",self.name
  print "other.name : ",other.name
  self.name = '%s AND %s' %(self.name,other.name)
  return self.name

p = Person("John")
q = Person("George")

print Person.__and__(p,q)


On 30 May 2007 22:11:45 -0700, theju <[EMAIL PROTECTED]> wrote:


Hello all,
I've two objects (both instances of a class called Person) and I want
to use the __and__ method and print the combined attributes of the two
instances.

To be precise, here is my code

class Person:
def __init__(self,name):
self.name = name
def print_name(self):
print self.name
def __and__(self,other):
self.name = '%s AND %s' %(self.name,other.name)
return self.name

p = Person("John")
q = Person("George")

r = p and q
print r.print_name()

Output:
---
George
None

I've also tried this:
class Person:
def __init__(self,name):
self.name = name
def print_name(self):
print self.name
def __and__(self,other):
a = Person()
a.name = '%s AND %s' %(self.name,other.name)
return a

p = Person("John")
q = Person("George")

r = p and q
print r.print_name()

Output:
---
George
None

The above output in both cases is giving me a doubt if __and__ method
is over-ridable or not?

The output that I am accepting is:
John AND George

What are the changes if to be made?

Thanking You
Thejaswi Puthraya
http://thejuhyd.blogspot.com

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Usage of the __and__ method

2007-05-30 Thread rishi pathak

class Person:
  def __init__(self,name):
  self.name = name
  def print_name(self):
  print self.name
  def __and__(self,other):
  print "self.name : ",self.name
  print "other.name : ",other.name
  self.name = '%s AND %s' %(self.name,other.name)
  return self.name

p = Person("John")
q = Person("George")

#r = p and q #This does'nt call __and__
print p.__and__(q) #this works
#print r.print_name()


On 30 May 2007 22:11:45 -0700, theju <[EMAIL PROTECTED]> wrote:


Hello all,
I've two objects (both instances of a class called Person) and I want
to use the __and__ method and print the combined attributes of the two
instances.

To be precise, here is my code

class Person:
def __init__(self,name):
self.name = name
def print_name(self):
print self.name
def __and__(self,other):
self.name = '%s AND %s' %(self.name,other.name)
return self.name

p = Person("John")
q = Person("George")

r = p and q
print r.print_name()

Output:
---
George
None

I've also tried this:
class Person:
def __init__(self,name):
self.name = name
def print_name(self):
print self.name
def __and__(self,other):
a = Person()
a.name = '%s AND %s' %(self.name,other.name)
return a

p = Person("John")
q = Person("George")

r = p and q
print r.print_name()

Output:
---
George
None

The above output in both cases is giving me a doubt if __and__ method
is over-ridable or not?

The output that I am accepting is:
John AND George

What are the changes if to be made?

Thanking You
Thejaswi Puthraya
http://thejuhyd.blogspot.com

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Lindsay Lohans TITS OOPSIE!!!

2007-05-17 Thread rishi pathak

Is there not a way to block these kind of mails
Their quantity is increasing day by day


On 17 May 2007 22:25:25 -0700, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:


Download http://scargo.in Lindsay Lohans Tits free tits and videos!
MUST CLICK! I mean see... .

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Code Explanation

2007-05-17 Thread rishi pathak

On 5/17/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]>
wrote:


 Hello Guys,



I'm currently working on a non-python project, and I'm trying to overcome
a task of parsing a text file into a database and/or xml file. I've managed
to find a parser example written in python, and I'm hoping to deconstruct
the code methodology a bit so I can write it in another language. So I'm
hoping someone can explain to me what these following bits of code are
doing.



lines = range(data.count("\n"))

lined_data = data.split("\n")



eg:
data="abc\n123\ngh\nxyz\n"
data.split("\n") will give you an array(list in python) in the following
manner
['abc', '123', 'gh', 'xyz']


print "Read %i vendors, now processing" % data.count("(hex)")




I've not used the split() function before, but it partly makes sense to
me. What is that piece of code doing? 'Data' is the content of the text
file, presumably the first line there is counting the number of lines in the
file, but I don't get the rest of it.



The rest of the code seems like a relatively simple set of loops, but it's
just this splitting stuff that's got me confused.



Thanks,



Rob

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: newb: Python Module and Class Scope

2007-05-10 Thread rishi pathak

This works for me.Also tried importing this module into another program.
The class is inside the module so like the different function's of a module
can access each other,the same thing applies to a class and
functions/classes
#Test Module
class foo:
   def __init__(self):
   self.data=1

   def outData(self):
   print self.data
   main()

def main():
   print "I am the main"
#Module test
if __name__=="__main__":
   fooObj=foo()
   fooObj.outData()


On 10 May 2007 07:02:49 -0700, johnny <[EMAIL PROTECTED]> wrote:


Can a class inside a module, access a method, outside of class, but
inside of the module?

Eg.  Can instance of class a access main, if so how?  What is the
scope of "def main()" interms of class A?

myModule:

class A:
   main()

def main():


thnx.

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: File Name Format

2007-05-08 Thread rishi pathak

One thing you could do is to create assign dir for c drive d drive etc as /c
, /d etc
then this would work
unix_name = win_name.replace("\\","/").replace("c:","/c").replace("d:","/d")

On 5/8/07, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:


Anand wrote:

> Greetings,
>
> How do I convert programmatically the file names from WIN32 to UNIX
> format?
>
> A code snippet would be of great help.
> We are new to python! :)

unix_name = win_name.replace("\\", "/")

But this of course won't work for anything that starts with a drive letter
for example.

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: N00b question on Py modules

2007-05-07 Thread rishi pathak

Hi
this  variable is local to function
do this
def setExitCode():
  global _exitcode
  _exitcode = 1
On 7 May 2007 00:00:38 -0700, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:


Hi. Sorry to sound like a noob but that's what I am when it comes to
Python. I just wrote the below module and it behaves funny.

My python module:

_exitcode = 0

def setExitCode():
_exitcode = 1



this  variable is local to function

if __name__ == '__main__':

print _exitcode
setExitCode()
print _exitcode

Actual O/P:
0
0

I expected to see an output of 0 followed by 1. But it turns out that
the _exitcode variable is not changed at all. It seems that
setExitCode() might be editing a local copy of the _exitcode variable.
But then, how do I tell it to change the value of the module variable
and not its local variable.

I've been through the modules section of Python docs and a few ebooks
as well, all suggest that it shouldn't be working this way.

Please help out ppl.

Thanks

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Searching for a piece of string

2007-05-03 Thread rishi pathak

s="CastinTime"
if s.find("Time") != -1:
   print "found"
else:
   print "not found"

On 3 May 2007 00:35:57 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:


Hi,
How can i match a part of string and branch to some part of code.
Ex If there is a string like "Timeout" and i want to search only
whether the word "Time" is present in it(which is valid in this
case).so if i have "CastinTime",still this should hold.
   I need to use this in a "if" statement and code.Can someone help me
in this.
   Thanks .

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: FInd files with .so extension

2007-05-02 Thread rishi pathak

May be this would work
import os
grep="so"
dir="."
lst = os.listdir(dir)
filelst=[]
for i in lst:
   if i.split(".")[len(i.split("."))-1] == grep:
   lst.append(i)
print lst


On 2 May 2007 21:58:41 -0700, pradeep nair <[EMAIL PROTECTED]> wrote:


HI,


 How do i find files with .so extension using python .

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Can I place a question on the mailing list

2007-04-19 Thread rishi pathak

Any one can post if it's regarding python

On 4/20/07, chachou martel juvet <[EMAIL PROTECTED]> wrote:


Good Morning Dear Sir ,
   I will like you allowing me to place question on
the web.

Kind Regards:
Martel.

--
*All new Yahoo! Mail - 
*<http://us.rd.yahoo.com/evt=40705/*http://mrd.mail.yahoo.com/try_beta?.intl=ca>
--
Get a sneak peak at messages with a handy reading pane.


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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Arrays, Got Me Confused

2007-04-13 Thread rishi pathak

HI,
You will have to import Numeric module
Add
from Numeric import *
to the script
For the second question:
Suppose you wrote the code for your class in firewall.py
and your main script is main.py
Put the file firewall.py in the directory where you have main.py
Then in main.py do :
import firewall.py

To create an object of class Firewall
firewallDemo=firewall.Firewall()
May be this will help

On 4/13/07, Robert Rawlins - Think Blue <[EMAIL PROTECTED]>
wrote:


 Hello Guys,



I'm struggling to get my head into arrays in python, I've used them plenty
in other languages but I'm struggling to find any decent documentation for
them in python. I'm looking to build a list of network MAC address's into an
array, which will probably be used for logging and firewalling and things.



I've build the basic class, the idea is that the class represents the
firewall, and I have functions for the firewall like addDevice() and
isFirewalled() where I pass in the address and it returns a value or updates
the array. However I'm getting an error when trying to create an empty array
on the init.



#!/usr/bin/python

# Filename: Firewall.py



class Firewall:



   def __init__(self):

  Self.FireArray = array(c)



p = Firewall()

print p





Throws:



Traceback (most recent call last):

  File "./firewall.py", line 9, in ?

p = Firewall()

  File "./firewall.py", line 7, in __init__

Self.FireArray = array(c)

NameError: global name 'array' is not defined



How can I solve this problem? From what I've seen writing I can't see
anything wrong with my syntax, perhaps you can shed some light on the
situation. Whilst I'm writing there is also another question I would like to
pose briefly. How do a create an object from an external file? Obviously in
my one above all I need do is call Firewall() and it creates an instance,
but I'm used to creating my class's as separate files, how do I create them
as an object in my main application?



Thanks,



Rob

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Newbie help with array handling

2007-04-12 Thread rishi pathak

do something like this
{keyvalue1:[ value1, value2, value3],keyvalue2:[value1,value2,
value3],keyvalue3,:[value1,value2,value3]}

On 12 Apr 2007 00:58:54 -0700, loial <[EMAIL PROTECTED]> wrote:


I am new to python and am converting an awk script to python

I need to store some data in an array/table of some form

keyvalue1, value1, value2, value3
keyvalue2, value1,value2, value3
keyvalue3, value1,value2,value3
etc

I will later need to sort in keyvalue order and also need to be able
to check if a key already exists

It is not clear how to do this in python. All the examples I see have
just a key and a single value

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Pass A Var To a Python Script?

2007-04-11 Thread rishi pathak

Hi,
Use sys.argv to access the command line arguments
eg:
import sys
print sys.argv[0]
print sys.argv[1]

Run the above script as
/test.py hello world

On 4/7/07, Eric Price <[EMAIL PROTECTED]> wrote:


Hi;
How do I pass a variable to a python script? Something like this (which
doesn't work):

./test.py?var=hello_world

TIA,
Eric

_
Mortgage refinance is Hot. *Terms. Get a 5.375%* fix rate. Check savings

https://www2.nextag.com/goto.jsp?product=10035&url=%2fst.jsp&tm=y&search=mortgage_text_links_88_h2bbb&disc=y&vers=925&s=4056&p=5117

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Create new processes over telnet in XP

2007-03-23 Thread rishi pathak

You could use pexpect module.
Open a telnet session
Then run the script in nohup mode
It's assumed that the binary is available over there

On 23 Mar 2007 03:47:14 -0700, Godzilla <[EMAIL PROTECTED]> wrote:


Hello,

How do you create/spawn new processes in XP over telnet using python?
I.e. I would like to create a new process and have it running in the
background... when I terminate the telnet connection, I would what the
spawned processes to keep running until I shut it off...

I got the os.popen method to spawn a new process running in the
backgroun, but not over telnet... tried os.popen[2, 3, 4] and also
subprocesses.popen without any luck...

Any help will be appreciated... thankyou.

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Re: python & java

2007-03-20 Thread rishi pathak

Jython is written in pure java.
You can use java classes inside python and also can use python classes
inside java
You can write applets too in python using jython.
It converts your python code in java code.


On 20 Mar 2007 10:06:00 -, sandeep patil <[EMAIL PROTECTED]>
wrote:


  what diff betn python & jython


On Tue, 20 Mar 2007 rishi pathak wrote :

>See www.*jython*.org
>
>On 20 Mar 2007 02:23:07 -0700, sandeep patil <[EMAIL PROTECTED]>
>wrote:
>>
>>hi
>>
>>i am fresher i python can any bady tell me who i will use python in
>>web technologies in java base application.
>>what it roll
>>
>>sandeep patil
>>
>>--
>>http://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
>-- Regards--
>Rishi Pathak
>National PARAM Supercomputing Facility
>Center for Development of Advanced Computing(C-DAC)
>Pune University Campus,Ganesh Khind Road
>Pune-Maharastra



[image: 
Diageo]<http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signature-home.htm/[EMAIL
 PROTECTED]/1119380_1113690/1118605/1?PARTNER=3&OAS_QUERY=null+target=new+>





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: python & java

2007-03-20 Thread rishi pathak

See www.*jython*.org

On 20 Mar 2007 02:23:07 -0700, sandeep patil <[EMAIL PROTECTED]>
wrote:


hi

i am fresher i python can any bady tell me who i will use python in
web technologies in java base application.
what it roll

sandeep patil

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Starting an external, independent process from a script

2007-03-13 Thread rishi pathak

You can do something like this:
pid = os.fork()
if pid != 0:
   os.execl("mencoder variables here and its arguments")
else:
   continue
exec will replace the current child process with the given command and as we
are doing fork the command will get executed in a child process.You can also
use os.system there

On 12 Mar 2007 16:13:51 -0700, Henrik Lied <[EMAIL PROTECTED]> wrote:


Hi there!

I'm trying to create a video uploading service (just to learn). The
system is mostly based on Django, but the question I'm looking an
answer for is more related to Python.

So, the user gets to upload a video file. This can either be a mpg,
avi or mp4-file. When the file is saved to its location, I want to
convert it to FLA (Flash Video). I'm currently using Mplayers
Mencoder, and this works great. The Mencoder is retrieved through
running os.system("mencoder variables here")

The problem with this is that the user has to wait until the movie is
done encoding until he can go around with his business. I don't look
upon this as ideal.

So - I want to spawn a new system process. I need some good pointers
on how to do this right.

Any input? :-)

Thanks a lot in advance!

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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: MPI in python?

2007-03-09 Thread rishi pathak

try this

http://sourceforge.net/projects/pympi/

On 3/9/07, Joydeep Mitra <[EMAIL PROTECTED]> wrote:


Hi guys,
I am a relatively new user of python.
I wanted to know what are the minimum requirements (modules, etc) are
required for paralleliing python programs on a multiproc linux cluster.
Is there a tutorial that explains the MPI syntax in python with examples?

Thanking in advance,
Joydeep


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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python books?

2007-03-08 Thread rishi pathak

I would suggest you the python docs available on python.org.They are the
best and latest

On 3/9/07, Tommy Nordgren <[EMAIL PROTECTED]> wrote:


Could some kind soul please recommend a few text books on Python 2.5
and it's class library?


Kine dies, Kinfolk dies, and thus at last yourself
This I know that never dies, how a dead mans deeds are deemed. --
Elder edda
Tommy Nordgren
[EMAIL PROTECTED]



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





--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list

Device Drivers in python(kernel modules)

2007-03-06 Thread rishi pathak

I am not much of a kernel programmer , I have a requirement to shift a
python code to work as a kernel module.
So I was just wondering whether we can write a kernel module in python.
A thought is that if we can somehow convert python code into a C object code
then it can be done.
Can some one suggest something..anything

--
Regards--
Rishi Pathak
National PARAM Supercomputing Facility
Center for Development of Advanced Computing(C-DAC)
Pune University Campus,Ganesh Khind Road
Pune-Maharastra
-- 
http://mail.python.org/mailman/listinfo/python-list