32 OS on 64-bit machine

2007-05-03 Thread SamG
If anyone has a x86_64 machine and is running a 32bit OS on top of
that could you tell me what output would you get for the following
program

#==
import platform
print platform.processor()
print platform.architecture()
#==

Thanks in advance
: )~

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


Re: 32 OS on 64-bit machine

2007-05-03 Thread SamG
On May 3, 2:58 pm, Harald Karner <[EMAIL PROTECTED]> wrote:
> SamG wrote:
> > If anyone has a x86_64 machine and is running a 32bit OS on top of
> > that could you tell me what output would you get for the following
> > program
>
> > #==
> > import platform
> > print platform.processor()
> > print platform.architecture()
> > #==
>
> > Thanks in advance
> > : )~
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\>python
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit
> (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>  >>> import platform
>  >>> print platform.processor ()
>
>  >>> print platform.architecture ()
> ('32bit', 'WindowsPE')
>  >>>

Thanks, I would be more interested in the output on Linux's or Unix

Thanks again : )~

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


enable-shared

2007-05-03 Thread SamG
How we do if find that python that we are using is compiled with the --
enable-shared  option. There is can actually be done using 

distutils.sysconfig module but this modules is ported only with python-
devel but not with standard python install.

Is there another way apart from checking the pyconfig.h file.

Thanks in advance
: )~

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


Re: How to find the present working directory using python.

2007-05-04 Thread SamG
On May 4, 12:03 pm, pradeep nair <[EMAIL PROTECTED]> wrote:
> how to find out the present working directory using python.
>
> os.system('pwd') works good. But i need some specific one in
> python rather than embedding shell command into python.


os.path.getcwd()

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


OSError[Error 5]

2007-05-22 Thread SamG
Hi,

I do this on PowerPC..

>>> import os
>>> os.listdir('/usr/bin')

And endup getting this ...

OSError: [Error 5] Input/output error:/usr/bin

I use python 2.4.4 (Framework edition)

Could anybody help

PS: I have clean listing with python 2.3.5 but my requirement is for
python 2.4.4.

Thanx in advance.

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


Re: OSError[Error 5]

2007-05-23 Thread SamG
On May 23, 1:39 am, Miki <[EMAIL PROTECTED]> wrote:
> Hello SamG,
>
> > I do this on PowerPC..
>
> > >>> import os
> > >>> os.listdir('/usr/bin')
>
> > And endup getting this ...
>
> > OSError: [Error 5] Input/output error:/usr/bin
>
> What happens when you run "ls /usr/bin" in the terminal?
>
> HTH,
> --
> Miki <[EMAIL PROTECTED]>http://pythonwise.blogspot.com


I get a perfect listing of /usr/bin folder.

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


redirecting stdout to a file as well as screen

2007-04-12 Thread SamG
How could i make, from inside the program, to have the stdout and
stderr to be printed both to a file as well the terminal(as usual).

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


Re: redirecting stdout to a file as well as screen

2007-04-12 Thread SamG
On Apr 12, 1:00 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Thu, 12 Apr 2007 04:14:32 -0300, SamG <[EMAIL PROTECTED]> escribió:
>
> > How could i make, from inside the program, to have the stdout and
> > stderr to be printed both to a file as well the terminal(as usual).
>
> A very minimal example:
>
> import sys
>
> class Tee(file):
>  others = ()
>
>  def write(self, data):
>  file.write(self, data)
>  for f in others:
>  f.write(data)
>
> tee = Tee(r"c:\temp\output.log","wt")
> tee.others = [sys.stdout, sys.stderr]
> sys.stdout = sys.stderr = tee
>
> print dir(sys)
> sys.foo # error
>
> --
> Gabriel Genellina

This is only creating an out.log file and all the stdout and stderr
are logged there.

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


Re: redirecting stdout to a file as well as screen

2007-04-12 Thread SamG
On Apr 12, 12:40 pm, "Ant" <[EMAIL PROTECTED]> wrote:
> On Apr 12, 8:14 am, "SamG" <[EMAIL PROTECTED]> wrote:
>
> > How could i make, from inside the program, to have the stdout and
> > stderr to be printed both to a file as well the terminal(as usual).
>
> One way would be to create a custom class which has the same methods
> as the file type, and held a list of file-like objects to write to.
> e.g.
>
> class multicaster(object):
> def __init__(self, filelist):
> self.filelist = filelist
>
> def write(self, str):
> for f in self.filelist:
> f.write(str)
> def writelines(self, str_list):
> #etc
>
> Then assign stdout and stderr to a new instance of one of these
> objects:
>
> mc = multicaster([sys.stdout, sys.stderr, log_file])
> sys.stdout = mc
> sys.stderr = mc
>
> HTH



I have written this

import sys

class multicaster(object):
def __init__(self, filelist):
self.filelist = filelist

def write(self, str):
for f in self.filelist:
f.write(str)

log_file='out.log'
mc = multicaster([sys.stdout, sys.stderr, log_file])
sys.stdout = mc
sys.stderr = mc

print "Hello"

And i get this when i run the porgram.

HelloHelloTraceback (most recent call last):
Traceback (most recent call last):

Kindly advice!


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


Re: redirecting stdout to a file as well as screen

2007-04-12 Thread SamG
On Apr 12, 3:16 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Thu, 12 Apr 2007 06:01:18 -0300, SamG <[EMAIL PROTECTED]> escribió:
>
>
>
> > On Apr 12, 1:00 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> > wrote:
> >> En Thu, 12 Apr 2007 04:14:32 -0300, SamG <[EMAIL PROTECTED]> escribió:
>
> >> > How could i make, from inside the program, to have the stdout and
> >> > stderr to be printed both to a file as well the terminal(as usual).
>
> >> class Tee(file):
> >>  others = ()
>
> >>  def write(self, data):
> >>  file.write(self, data)
> >>  for f in others:
> >>  f.write(data)
>
> > This is only creating an out.log file and all the stdout and stderr
> > are logged there.
>
> Sorry, `for f in others:` should read `for f in self.others:`
>
> --
> Gabriel Genellina


Does not make difference, does this work for you? Im working on linux.
But this code looks portable except for the file path :)

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


Re: redirecting stdout to a file as well as screen

2007-04-12 Thread SamG
On Apr 12, 3:42 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Thu, 12 Apr 2007 07:23:43 -0300, SamG <[EMAIL PROTECTED]> escribió:
>
>
>
> >> >> > How could i make, from inside the program, to have the stdout and
> >> >> > stderr to be printed both to a file as well the terminal(as usual).
>
> >> >> class Tee(file):
> >> >>  others = ()
>
> >> >>  def write(self, data):
> >> >>  file.write(self, data)
> >> >>  for f in others:
> >> >>  f.write(data)
>
> >> > This is only creating an out.log file and all the stdout and stderr
> >> > are logged there.
>
> >> Sorry, `for f in others:` should read `for f in self.others:`
>
> > Does not make difference, does this work for you? Im working on linux.
> > But this code looks portable except for the file path :)
>
> Yes. And it's rather similar to your other example... Omit sys.stderr as
> Antoon Pardon suggested.
>
> --
> Gabriel Genellina


Thanks people i have got it working now...

with this program!

#END
import sys

class multicaster(object):
def __init__(self, filelist):
self.filelist = filelist

def write(self, str):
for f in self.filelist:
f.write(str)

log_file=open('out.log','w')
mc = multicaster([sys.stderr, log_file])
sys.stdout = mc
sys.stderr = mc
sys.stdout.write( "Mojozoox\n")
sys.stderr.write( "Hello\n")
#END

works perfect for my needs.

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


Capturing the entry point of a script

2007-04-12 Thread SamG
If a function does not have main function defined and there is only a

if __name__="__main__":

how do i make a call to that using

profile.runcall( ...)

in my profiling script. Is there a way to find the entry point of a
script and indentify it with module method.

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


Capturing the entry point of a script

2007-04-12 Thread SamG
If a function does not have main function defined and there is only a

if __name__="__main__":

how do i make a call to that using

profile.runcall( ...)

in my profiling script. Is there a way to find the entry point of a
script and indentify it with module method.

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


Try problem

2007-04-13 Thread SamG
import sys
try:
 s=1
 if s==1:
  sys.exit(0)
 else:
  sys.exit(1)
except SystemExit,s:
 if (s==0):
  print s
 else:
  print "Hello"

How come i always end up getting the "Hello" printed on the screen as
logically i should a '0' printed?

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


Re: Try problem

2007-04-13 Thread SamG
On Apr 13, 2:25 pm, [EMAIL PROTECTED] wrote:
> On Apr 13, 5:14 pm, "SamG" <[EMAIL PROTECTED]> wrote:
>
> > import sys
> > try:
> >  s=1
> >  if s==1:
> >   sys.exit(0)
> >  else:
> >   sys.exit(1)
> > except SystemExit,s:
> >  if (s==0):
> >   print s
> >  else:
> >   print "Hello"
>
> > How come i always end up getting the "Hello" printed on the screen as
> > logically i should a '0' printed?
>
> if you put a debug print statement, eg
>
> ...
> except SystemExit,s:
> print "s in exception " , s, type(s)
> if (s==0):
> 
>
> you will notice 's' is an "instance". so when it reaches the if
> (s==0), which you are comparing with a number, it will fail and then
> hello is printed.

Then how do we check the value of the s's instance?

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


Crypto headaches.

2009-02-18 Thread SamG
Hi,

Using the python's Crypto.Cipher.Blowfish is create and encrypted file
in the CBC mode. Now... when try to decrypt it with OpenSSL i get an
error stating "bad magic number".

I tried
$ cat encr-file | openssl bf-cbc -d -pass pass:sam > org-file
or
$ openssl bf-cbc -d -pass pass:sam -in encr-file -out org-file

BTW, decryption using a python code works well. But i m of the
impression a file encry with one program should/can be decrypt with
another program (in my case openssl) using the same parameters.

Pls help.

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


Re: Crypto headaches.

2009-02-18 Thread SamG
On Feb 18, 7:10 pm, "M.-A. Lemburg"  wrote:
> On 2009-02-18 14:23, SamG wrote:
>
> > Hi,
>
> > Using the python's Crypto.Cipher.Blowfish is create and encrypted file
> > in the CBC mode. Now... when try to decrypt it with OpenSSL i get an
> > error stating "bad magic number".
>
> Are you getting the error message from openssl ? It looks a lot
> like an error message from Python.
>
> > I tried
> > $ cat encr-file | openssl bf-cbc -d -pass pass:sam > org-file
> > or
> > $ openssl bf-cbc -d -pass pass:sam -in encr-file -out org-file
>
> > BTW, decryption using a python code works well. But i m of the
> > impression a file encry with one program should/can be decrypt with
> > another program (in my case openssl) using the same parameters.
>
> Ideally, that should work, but you also have to make sure that
> the following two details are the same for both applications:
>
>  1. the way padding is done (Blowfish is a block cipher)
>
>  2. the way the initialization vector is set
>
> Otherwise the two won't interoperate properly.
>
> --
> Marc-Andre Lemburg
> eGenix.com
>
> Professional Python Services directly from the Source  (#1, Feb 18 2009)>>> 
> Python/Zope Consulting and Support ...http://www.egenix.com/
> >>> mxODBC.Zope.Database.Adapter ...http://zope.egenix.com/
> >>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/
>
> 
>
> ::: Try our new mxODBC.Connect Python Database Interface for free ! 
>
>eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
> D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
>Registered at Amtsgericht Duesseldorf: HRB 46611
>http://www.egenix.com/company/contact/

That must be it...

But given a password how do i generate a (key, IV) pair???

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


Problem obtaining an object reference...

2008-08-06 Thread SamG
I have two windowing classes A and B.

Inside A's constructor i created an instance B to display its Modal
window. Only on clicking OK/ Closing this modal window do i proceed to
display the A's window.

All that is fine. Now the problem is i would like to write a python
script to test the this GUI app simulating all the events that make
A's window work through my script. No the problem is to get past my
B's window. Which i'm unable to do since the A's instance would any be
created completely if i click OK/Close button on the B's window. Im
unable to simulate that event since i have little idea about how to
get the object reference to B's window? Here is a sample of the code.


class Awindow:

def __init__(self):


self.showBwindow()
def showBwindow(self):
dialog = Bwindow()
dialog.ShowModal()
dialog.Destroy()

class Bwindow:
def __init__(self):



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


Re: os.system question

2008-08-07 Thread SamG
On Aug 7, 6:07 am, Kevin Walzer <[EMAIL PROTECTED]> wrote:
>  >>> import os
>  >>> foo = os.system('whoami')
> kevin
>  >>> print foo
> 0
>  >>>
>
> The standard output of the system command 'whoami' is my login name. Yet
> the value of the 'foo' object is '0,' not 'kevin.' How can I get the
> value of 'kevin' associated with foo?
>
> --
> Kevin Walzer
> Code by Kevinhttp://www.codebykevin.com

Why dont you try commands module instead

In [28]: import commands

In [29]: dir(commands)
Out[29]:
['__all__',
 '__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 'getoutput',
 'getstatus',
 'getstatusoutput',
 'mk2arg',
 'mkarg']

In [30]: (a,b) = commands.getstatusoutput('whoami')

In [31]: print a
0

In [32]: print b
luma35

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


Threading and wx.....

2008-08-08 Thread SamG
Hi,

Im trying my hand at threading with wx applications. I have written
the following code...

import wx
from threading import Thread, Lock

class createWindow(Thread):
def __init__(self):
Thread.__init__(self)
self.lock = Lock()
self.app=None

def run(self):
#self.lock.acquire()
self.app = wx.PySimpleApp()
frame = wx.Frame(None, title="Hello wx")
frame.Show()
#self.lock.release()
self.app.MainLoop()


if __name__=='__main__':
c = createWindow()
c.start()
c.join()

Now when i run this program i get a window but the application just
does not respond. Is there something that im missing here. Pls let me
know. Thanks in advance.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Threading and wx.....

2008-08-08 Thread SamG
On Aug 8, 12:01 pm, SamG <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Im trying my hand at threading with wx applications. I have written
> the following code...
>
> import wx
> from threading import Thread, Lock
>
> class createWindow(Thread):
> def __init__(self):
> Thread.__init__(self)
> self.lock = Lock()
> self.app=None
>
> def run(self):
> #self.lock.acquire()
> self.app = wx.PySimpleApp()
> frame = wx.Frame(None, title="Hello wx")
> frame.Show()
> #self.lock.release()
> self.app.MainLoop()
>
> if __name__=='__main__':
> c = createWindow()
> c.start()
> c.join()
>
> Now when i run this program i get a window but the application just
> does not respond. Is there something that im missing here. Pls let me
> know. Thanks in advance.

Oops! Murphy's law works again! And the above code is working fine.
--
http://mail.python.org/mailman/listinfo/python-list