Re: ISO Python example projects (like in Perl Cookbook)

2008-01-10 Thread kyosohma
On Jan 10, 10:13 am, kj [EMAIL PROTECTED] wrote:
 I'm looking for example implementations of small projects in
 Python, similar to the ones given at the end of most chapters of
 The Perl Cookbook (2nd edition, isbn: 0596003137).  (Unfortunately,
 the otherwise excellent Python Cookbook (2nd edition, isbn:
 0596007973), by the same publisher (O'Reilly), does not have this
 great feature.)

 The subchapters devoted to these small projects (which are called
 Programs in the book), each consists of a description of the
 task, a discussion of the relevant design considerations, and one
 or more illustrative implementations.  As such, these programs are
 larger and more complex than the typical recipe in the book, but
 are still short enough to be read and understood in a few minutes.

 I find the study of such small programs invaluable when learning
 a new language.

 Does anyone know of a source of similar material for Python?

 TIA!

 kynn
 --
 NOTE: In my address everything before the first period is backwards;
 and the last period, and everything after it, should be discarded.

I know that Hetland's book, Beginning Python has some projects in
the back. Zelle's book (Python Programming: An Introduction to
Computer Science) has exercises of sorts at the end of each of the
chapters.

Python Programming for the Absolute Beginner walks the reader through
designing some games with the pygame module...and for some involved
reading, I would recommend Lutz's tome, Programming Python 3rd Ed.,
which has various projects throughout that the author goes into in
depth.

I've seen tutorials of varying worth on devshed.com and good articles
on IBM's site as well.

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


Re: SQLObject 0.9.3

2008-01-10 Thread kyosohma
On Jan 10, 6:38 am, Oleg Broytmann [EMAIL PROTECTED] wrote:
 Hello!

 I'm pleased to announce the 0.9.3 release of SQLObject.

 What is SQLObject
 =

 SQLObject is an object-relational mapper.  Your database tables are described
 as classes, and rows are instances of those classes.  SQLObject is meant to be
 easy to use and quick to get started with.

 SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and
 Firebird.  It also has newly added support for Sybase, MSSQL and MaxDB (also
 known as SAPDB).

 Where is SQLObject
 ==

 Site:http://sqlobject.org

 Development:http://sqlobject.org/devel/

 Mailing list:https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

 Archives:http://news.gmane.org/gmane.comp.python.sqlobject

 Download:http://cheeseshop.python.org/pypi/SQLObject/0.9.3

 News and changes:http://sqlobject.org/News.html

 What's New
 ==

 Bug Fixes
 ~

 * With PySQLite2 do not use encode()/decode() from PySQLite1 - always use
   base64 for BLOBs.

 * MySQLConnection doesn't convert query strings to unicode (but allows to
   pass unicode query strings if the user build ones). DB URI parameter
   sqlobject_encoding is no longer used.

 For a more complete list, please see the news:http://sqlobject.org/News.html

 Oleg.
 --
  Oleg Broytmannhttp://phd.pp.ru/   [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.

I've been wondering about this for a while...Do all three versions
(0.9.3, 0.8.7, 0.7.10) work the same? The website seems to only have
docs for the 0.9 version. Do you maintain and update the 3 versions
for backwards compatibility?

Just curious.

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


Re: getting absolute path ?

2008-01-09 Thread kyosohma
On Jan 9, 3:22 pm, Stef Mientki [EMAIL PROTECTED] wrote:
 hello,

 I'm trying to convert the links in html pages to absolute links,
 these pages can either be webpages or files on local harddisk (winXP).
 Now I've struggling for a while, and this code works a lilttle:

   i = line.find ( 'href=' )
   if i  0 :
   i = line.find ( ' src=' )
   if i = 0 :
 ii = line.find ( '', i+6 )
 file = line [ i+6 : ii ]
 #print urlparse.urljoin ( p, file )
 if file.find ( 'http:' )  0 :
 abspath = os.path.normpath ( os.path.join ( p, file ) )
 line = line.replace ( file, abspath )
 print line

 but it only covers files on local disk and just 1 link per line,
 so I guess it's a lot of trouble to catch all cases.
 Isn't there a convenient function for (OS independent preferable) ?
 Googled for it, but can't find it.

 thanks,
 Stef Mientki

I googled a bit too. The Perl forums talk about using a regular
expression. You can probably take that and translate it into the
Python equivalent:

http://forums.devshed.com/perl-programming-6/how-to-parse-relatives-links-to-absolute-links-8173.html

I also found this, which appears to be an old c.l.py thread:

http://www.dbforums.com/archive/index.php/t-320359.html

You might have more luck if you google for relative to absolute
links. I would also take a look at how django or cherrypy creates
their URLs.

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


Re: windows service

2008-01-08 Thread kyosohma
On Jan 7, 6:42 pm, Michael Chesterton [EMAIL PROTECTED] wrote:
 I'm trying to get a program that uses M2Crypto ThreadingSSLServer to
 run in windows as a service. I have a few problem, it doesn't listen
 on its port and I don't know how to debug it.

 I used the pipeservice example as a framework to get it running as a
 service

  def SvcDoRun(self):
  # Write an event log record - in debug mode we will also
  # see this message printed.
  servicemanager.LogMsg(
  servicemanager.EVENTLOG_INFORMATION_TYPE,
  servicemanager.PYS_SERVICE_STARTED,
  (self._svc_name_, '')
  )

  daemonserver = do_daemon()
  while 1:
  daemonserver.handle_request()

 I think I need a way to break out of that while loop when a service
 stop is sent, but not knowing what happening at that point I'm not
 sure how. It's not even listening on its port.

 daemonserver is

  daemonserver = SSL.ThreadingSSLServer((host_ip_addr, int
 (host_port_num)), TestRequestHandler, ctx)

 any help?

 --
 Michael Chestertonhttp://chesterton.id.au/blog/http://barrang.com.au/

 --
 Michael Chestertonhttp://chesterton.id.au/blog/http://barrang.com.au/

Before you get it going as a service, test it as just a regular Python
script. I've created local servers using CherryPy before and been able
to test them. I recommend you do the same with yours before changing
it to a service.

If you have a firewall installed (which you should), you may need to
allow your program access through it. I've occasionally had to allow
localhost with some of the more stringent firewalls.

I found this post on creating a Windows Service for Windows 2000,
which can probably be modified for XP:
http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html

There's also this one: 
http://essiene.blogspot.com/2005/04/python-windows-services.html

They both sound different from the way you did it, but maybe I
misunderstood.

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


Re: Python or PowerShell ?

2008-01-08 Thread kyosohma
On Jan 8, 1:57 pm, Martin P. Hellwig [EMAIL PROTECTED] wrote:
 Torsten Bronger wrote:
  Hallöchen!

  [EMAIL PROTECTED] writes:

  I am all about using the right tool for the right purposes, [...]

  Which purpose?

  I dug up one article from Google that talked about comparison but
  that was about it.

 http://www.simple-talk.com/sql/database-administration/comparing-pyth...

  This comparison is about a very narrow field; additionally, it is a
  field PowerShell was optimised for.

  Tschö,
  Torsten.

 And adding to that, if you don't care about cross platform anyway, why
 even bother with python? I am sure that MS has tools that can do in a
 point and click kind of way all the things you might encounter.

 --
 mph

I code mostly for Windows users, but I use Python almost exclusively.
Why?

1) Python is free
2) Microsoft Visual Studio is very expensive
3) Python is Open Source
4) Visual Studio is not Open Source
5) I can actually take the code from IDLE and refine it for my
purposes if it doesn't suit me. Good luck doing that with practically
anything Microsoft supplies.
6) With relative ease, I can go cross-platform with my code if
requirements change

I could go on. There are many good reasons to use Python (or some
other good open source language, like Ruby) even if you just program
for Windows.

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


Re: Newbie question: Classes

2008-01-08 Thread kyosohma
On Jan 8, 3:31 pm, Daniel Fetchinson [EMAIL PROTECTED]
wrote:
  Basically, I have created a program using tkinter without using any class
  structure, simply creating widgets and functions (and finding ways around
  passing variables from function to function, using global variables etc).
  The program has become rather large ( lines?) I am trying to now put it into
  a class structure, because I hear it is easier to handle.

  So basically, I put all the stuff into a class, making the widgets in the
  def __init__(self, root) (root being my Tk() ) and then I have had to put
  a self. in front of any instance of any variable or widget. Is this right?
  it seems like nothing is any easier (except having variables locally). Is
  this right? Should I be creating more classes for different things or what?

 Use the method that works best for you. If you like the procedural
 approach more then don't worry about being object oriented. The good
 thing is that python is multi-paradigm so if custom objects don't make
 your life easier then just forget about them :)

One great benefit to classes is the ability to take a generic class
and then subclass it. Or the ability to instantiate various objects
from one class.

Say you have a dog class. If you pass in the correct data, you can
instantiate a dalmatian, a Labrador or a mutt. They're all dogs, but
their all different too.

Enough of my babbling. Check out the following links for more info:

http://www.freenetpages.co.uk/hp/alan.gauld/tutclass.htm
http://www.diveintopython.org/object_oriented_framework/defining_classes.html
http://docs.python.org/tut/node11.html

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


Re: Killing worker threads

2008-01-07 Thread kyosohma
On Jan 6, 7:48 am, Fredrik Lundh [EMAIL PROTECTED] wrote:
 tarun wrote:
  Can anyone help me with a simple code through which the main thread can
  kill the worker thread it started.

 it cannot.  threads cannot be killed from the outside.

 /F

The only way to kill a thread is to have the spawned thread have
some kind of passed in argument which will trigger it to shut down.
You could have the thread read a file or file-like object periodically
(like a timer) and if it meets some condition, have the thread quit.

It's kind of like a subscription process. The thread subscribes to the
main program and can accept signals. I suggest that the OP read the
docs on threads:

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

Of special interest to this user: 
http://docs.python.org/lib/condition-objects.html

I have messed with KillProcName, a PyWin32 script with limited
success. There's also the following snippet which is Windows only and
works for some processes and not others (i.e. unreliable):

subprocess.Popen('taskkill /s %s /im %s' % (computer_id, proc))

Hopefully I didn't muddy the waters or write something too off the
mark.

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


Re: Does Python cache the startup module?

2008-01-07 Thread kyosohma
On Jan 7, 12:30 pm, Baz Walter [EMAIL PROTECTED] wrote:
 Hello

 I remember reading somewhere (probably this list) that python may cache the
 module that starts a program (e.g. 'main.py'). I'm asking because I have found
 that this can sometimes cause problems when making small edits to the module.
 For instance, in my current module I changed the name of the main gui widget.
 When I ran the program, the program started to leak memory like a sieve. I 
 then
 changed the name back again, and the problem went away. This looks very much
 like some sort of weird caching behaviour to me.

 I've tried deleting the .pyc file and even re-booting, but I can't make the
 problem go away!

 Can anyone confirm that this caching happens? And if so, is it documented
 anywhere?

 TIA

You can run a dir() in the GUI IDLE or the command line IDLE and see
what's currently cached, so to speak. In the GUI IDLE, you can
flush it out by going to the Shell menu and choosing Restart Shell.

It should only display the following after a restart:

 dir()
['__builtins__', '__doc__', '__name__']


HTH

Mike

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


Re: Who's to blame?

2008-01-04 Thread kyosohma
On Jan 4, 3:35 am, Nicola Musatti [EMAIL PROTECTED] wrote:
 Hallo, Mike.
 First of all, thanks to both you and Rob for your answers. I now see
 that the wxPython group would have been a better place to post to, all
 the more so given the tight connection between the wxPython and
 wxWidgets projects, of which at first I wasn't aware.

 On Jan 3, 8:19 pm, [EMAIL PROTECTED] wrote:
 [...]



  I've never created a modal dialog like this. Instead, I follow the
  wxPython in Action book examples (most of the time), which would do a
  yes/no dialog like this:

  code

  dlg = wx.MessageDialog(None, 'Some Message', 'A Message Box',
  wx.YES_NO | wx.QUESTION)
  retCode = dlg.ShowModal()
  if retCode == wx.ID_YES:
 # do something
 print 'yes'
  else:
 # do something else
 print 'no'
  dlg.Destroy()

  /code

 Actually my example started out as something like

 if wx.MessageBox(message=Some message, caption=Some caption,
 style=wx.YES|wx.NO) == wx.YES:
 pass

 I had to change it because the actual message can become very long, so
 I assembled a dialog with a scrollable text field. Maybe I'm expecting
 to much of wxStdDialogButtonSizer, but I still feel that given that
 both your method and mine above work straight away, it should provide
 the same behaviour with Yes/No buttons as with OK/Cancel ones.

 Cheers,
 Nicola Musatti

Nicola,

I have sub-classed wx.Dialog to do my own custom modal dialogs as
well. You can use sizers and put whatever widgets you want onto it
that way. Just make sure that when you create the Yes/No buttons, you
give them the wx.ID_YES or wx.ID_NO ids, rather than -1 or wx.ID_ANY.

yesBtn = wx.Button(parent, wx.ID_YES, 'Yes')
noBtn  = wx.Button(parent, wx.ID_NO, 'No')

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


Tabnanny errors when Migrating Python 2.4 code to 2.5

2008-01-04 Thread kyosohma
Hi,

When Python 2.5 first came out, I eagerly downloaded it and
immediately had issues with getting it to run my 2.4 code. So I just
stuck to 2.4. However, I decided this week that I really should try to
get 2.5 to work. Does anyone know why code that works perfectly for
months in a 2.4 environment throws indentation errors in 2.5?

And why does 2.5 default to indenting 8 characters instead of 4 in
IDLE? That's just weird. When I did a select all and did a Tabify
region, it indented everything 8 characters then too.

I haven't changed the configuration at all. Any ideas?

Thanks,

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


Re: Tabnanny errors when Migrating Python 2.4 code to 2.5

2008-01-04 Thread kyosohma
On Jan 4, 2:06 pm, John Machin [EMAIL PROTECTED] wrote:
 On Jan 5, 3:56 am, [EMAIL PROTECTED] wrote:

  Hi,

  When Python 2.5 first came out, I eagerly downloaded it and
  immediately had issues with getting it to run my 2.4 code. So I just
  stuck to 2.4. However, I decided this week that I really should try to
  get 2.5 to work. Does anyone know why code that works perfectly for
  months in a 2.4 environment throws indentation errors in 2.5?

 No, not until you go to the bother of reproducing the problem with a
 small file, tell us what platform you are on, how you are running this
 code (IDLE, shell prompt, ...), how you installed Python 2.5
 (2.5.1?), ...


I'm using Windows XP, using IDLE (which was mentioned already) and I
downloaded the 2.5.1 exe/msi file from python.org to install it.

I have yet to find a simple one which exhibits the issue to post. It
seems to happen to my complex files, not the simple ones.

Sorry to bother you.

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


Re: Skill Resume Achievements, What Good Goes Here?

2008-01-04 Thread kyosohma
On Jan 4, 3:06 pm, apatheticagnostic [EMAIL PROTECTED]
wrote:
 On Jan 2, 11:31 am, [EMAIL PROTECTED] wrote:



  On Jan 2, 9:59 am, vbgunz [EMAIL PROTECTED] wrote:

   I spent some time working on a skill resume, the kind of resume
   college students put together and realized, I am not in college and
   everything I learned was self-taught. Of course I would like some real
   world achievements but don't consider throw-away code an achievement
   and am failing to really see any. I don't even wish to entertain the
   thought of lying about anything.

   What are some achievements an employer may be looking for in someone
   willing to start at ground level, entry level, intern, etc? What are
   some real world achievements every n00b will need under his/her belt
   in order to be taken seriously?

  Internships are always a good thing to have. If you've contributed to
  open source projects, I'd put that on there. If you're applying for
  some kind of programming job, they'll probably want to see some of
  your code, know what home-brewed projects you've done and how long
  they took to complete, issues you ran into, etc.

  That might get you started anyway.

  Mike

 As someone else who's self-educated and curious about this, would
 listing canonical comp-sci books that you've gone through on your own
 and understood be a reasonable thing to mention? For example, SICP,
 PLAI, etc?

I should mention that it's certainly not hopeless. My boss is self-
taught and so is our webmaster...you'll probably just have to start
somewhere low on the ladder. Such as small businesses like computer
repair shops or local ISPs where you can show your stuff.

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


Re: Skill Resume Achievements, What Good Goes Here?

2008-01-04 Thread kyosohma
On Jan 4, 3:06 pm, apatheticagnostic [EMAIL PROTECTED]
wrote:
 On Jan 2, 11:31 am, [EMAIL PROTECTED] wrote:



  On Jan 2, 9:59 am, vbgunz [EMAIL PROTECTED] wrote:

   I spent some time working on a skill resume, the kind of resume
   college students put together and realized, I am not in college and
   everything I learned was self-taught. Of course I would like some real
   world achievements but don't consider throw-away code an achievement
   and am failing to really see any. I don't even wish to entertain the
   thought of lying about anything.

   What are some achievements an employer may be looking for in someone
   willing to start at ground level, entry level, intern, etc? What are
   some real world achievements every n00b will need under his/her belt
   in order to be taken seriously?

  Internships are always a good thing to have. If you've contributed to
  open source projects, I'd put that on there. If you're applying for
  some kind of programming job, they'll probably want to see some of
  your code, know what home-brewed projects you've done and how long
  they took to complete, issues you ran into, etc.

  That might get you started anyway.

  Mike

 As someone else who's self-educated and curious about this, would
 listing canonical comp-sci books that you've gone through on your own
 and understood be a reasonable thing to mention? For example, SICP,
 PLAI, etc?

I'm not sure...I went through a ton of interviews and was never asked
about what books I'd read. I did get questions about group projects /
assignments and a couple companies wanted to know what I programs I
created on my own.

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


Re: PyOpenGL, wxPython weird behaviour

2008-01-03 Thread kyosohma
On Jan 3, 11:50 am, Adeola Bannis [EMAIL PROTECTED] wrote:
 Hi everyone,

 I'm doing a project using wxPython and pyopengl, and I seem to have a
 problem rendering textures. This is code that worked before my hard
 drive had a meltdown, but not since I re-installed everything.

 I've determined the problem is in the OpenGL part of my program. I do
 some calculations to generate a 2D numpy array that holds the image
 data, and pylab.imshow() shows me the image as it is meant to be. I
 used the same algorithm in Octave and MATLAB, and all are giving me
 the right picture.

 However, using pyOpenGL and the numpyhandler functions (http://cours-
 info.iut-bm.univ-fcomte.fr/docs/python/OpenGL/
 OpenGL.arrays.numpymodule.NumpyHandler-class.html) doesn't seem to
 work. I get a garbled screen pocked with black pixels. I am including
 my openGL code below. What am I doing wrong?

 And yes, I did make the dtype of my array 'float32'.

 ---code snippets--

 import wx
 from wx.glcanvas import GLCanvas

 from OpenGL.GLU import *
 from OpenGL.GL import *
 from OpenGL.arrays.numpymodule import NumpyHandler

 PC = 1
 RI = 0

 class myGLCanvas(GLCanvas):
 def __init__(self, parent):
 GLCanvas.__init__(self, parent,-1)
 wx.EVT_PAINT(self, self.OnPaint)
 self.init = 0
 self.mode = -1
 # making a texture for the range image
 self.texture = glGenTextures(1)
 # making a spot for the point cloud points
 self.cloud = None
 return

 def OnPaint(self,event):
 dc = wx.PaintDC(self)
 self.SetCurrent()
 if not self.init:
 self.InitGL()
 self.init = 1
 self.OnDraw()
 return

 def OnDraw(self):
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
 if self.mode == RI:
 self.drawRange()
 elif self.mode == PC:
 self.drawCloud()

 def InitGL(self):
 glClearColor(0.0, 0.0, 0.0, 0.0);
 glClearDepth(1.0)
 glEnable(GL_DEPTH_TEST)
 glDepthFunc(GL_LEQUAL)
 glClear(GL_COLOR_BUFFER_BIT)

 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 glPixelStorei(GL_PACK_ALIGNMENT, 1)

 #NTSC colour scales...
 glPixelTransferf(GL_RED_SCALE, 0.299);
 glPixelTransferf(GL_GREEN_SCALE, 0.587);
 glPixelTransferf(GL_BLUE_SCALE, 0.114);

 glMatrixMode(GL_PROJECTION)
 glLoadIdentity()
 glOrtho(0.0,1.0,0,1.0,-1.0,1.0)
 glMatrixMode(GL_MODELVIEW)
 glLoadIdentity()

 return

 def rangeImage(self, image):

 glBindTexture(GL_TEXTURE_2D, self.texture)
 glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE )

 glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
 GL_LINEAR)
 glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, 
 GL_LINEAR)
 glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
 glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)

 # flatten it into a list so the OpenGL calls work
 n = NumpyHandler()
 fI = image.flatten()
 flatImage = n.dataPointer(n.contiguous(fI))

 print n.contiguous(fI)

 gluBuild2DMipmaps(GL_TEXTURE_2D, 1, image.shape[0]+1,
 image.shape[1]+1,
 GL_LUMINANCE, 
 GL_FLOAT, flatImage)
 self.mode = RI
 self.OnDraw()

 def drawRange(self):
 ''' Controls the actual drawing of the range image'''

 glMatrixMode(GL_MODELVIEW)
 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

 glColor3f(1.0,1.0,1.0)
 glEnable(GL_TEXTURE_2D)
 glBindTexture(GL_TEXTURE_2D, self.texture)
 glBegin(GL_TRIANGLE_FAN)
 glTexCoord2d(1,1); glVertex3f(0.0, 0.0, 0.0)
 glTexCoord2d(1,0); glVertex3f(0.0, 1.0, 0.0)
 glTexCoord2d(0,0); glVertex3f(1.0, 1.0, 0.0)
 glTexCoord2d(0,1); glVertex3f(1.0, 0.0, 0.0)
 glEnd()
 self.SwapBuffers()

 end snippet---

I've never messed with pyOpenGL, but it seems that they have their own
user's group, which would probably be better at answering your
question:

http://sourceforge.net/mail/?group_id=5988

Of course, it could be that you upgraded your wxPython to the latest
version and as I recall, they were 

Re: Who's to blame?

2008-01-03 Thread kyosohma
On Jan 3, 8:48 am, Nicola Musatti [EMAIL PROTECTED] wrote:
 Hallo,
 First of all I apologize for the longish example at the bottom, but
 the biggest source file is automatically generated and I didn't want
 to modify more than strictly necessary. Also, it would be shorter if
 XML wasn't so verbose ;-)

 The following is a wxPython/XRC toy program with a form with a button
 which, when pressed, causes a simple dialog to be displayed. The
 problem lies in the fact that apparently ShowModal() does not return
 when either the Yes or the No buttons are pressed. Curiously, if you
 change the Yes and No buttons with the OK and Cancel ones that are
 currently commented everything works as expected.

 As the sbs_test_xrc.py file below is automatically generated by
 wxPython 2.8.6.1's XRCed tool from a XRC file which in turn is
 generated by wxFormBuilder (http://wxformbuilder.org/), I really cant
 figure out to whom I should report this problem, assuming I'm not
 missing some obvious mistake of mine, that is.

 Thanks for your help.

 Cheers,
 Nicola Musatti

 # sbs_test.py
 import wx
 import sbs_test_xrc

 class MainFrame(sbs_test_xrc.xrcMainFrame):
 def __init__(self, parent):
 sbs_test_xrc.xrcMainFrame.__init__(self, parent)
 self.button.Bind(wx.EVT_BUTTON, self.OnButton)

 def OnButton(self, event=None):
 d = sbs_test_xrc.xrcDialog(self)
 ##if d.ShowModal() == wx.ID_OK:
 if d.ShowModal() == wx.ID_YES:
 self.Close()

 class Application(wx.App):
 def OnInit(self):
 self.frame = MainFrame(None)
 self.frame.Show()
 self.SetTopWindow(self.frame)
 return True

 if __name__ == '__main__':
 app = Application()
 app.MainLoop()

 # sbs_test_xrc.py
 # This file was automatically generated by pywxrc, do not edit by
 hand.
 # -*- coding: UTF-8 -*-

 import wx
 import wx.xrc as xrc

 __res = None

 def get_resources():
  This function provides access to the XML resources in this
 module.
 global __res
 if __res == None:
 __init_resources()
 return __res

 class xrcDialog(wx.Dialog):
 def PreCreate(self, pre):
  This function is called during the class's initialization.

 Override it for custom setup before the window is created
 usually to
 set additional window styles using SetWindowStyle() and
 SetExtraStyle().
 pass

 def __init__(self, parent):
 # Two stage creation 
 (seehttp://wiki.wxpython.org/index.cgi/TwoStageCreation)
 pre = wx.PreDialog()
 self.PreCreate(pre)
 get_resources().LoadOnDialog(pre, parent, Dialog)
 self.PostCreate(pre)

 # create attributes for the named items in this container
 self.wxID_YES = xrc.XRCCTRL(self, wxID_YES)
 self.wxID_NO = xrc.XRCCTRL(self, wxID_NO)

 class xrcMainFrame(wx.Frame):
 def PreCreate(self, pre):
  This function is called during the class's initialization.

 Override it for custom setup before the window is created
 usually to
 set additional window styles using SetWindowStyle() and
 SetExtraStyle().
 pass

 def __init__(self, parent):
 # Two stage creation 
 (seehttp://wiki.wxpython.org/index.cgi/TwoStageCreation)
 pre = wx.PreFrame()
 self.PreCreate(pre)
 get_resources().LoadOnFrame(pre, parent, MainFrame)
 self.PostCreate(pre)

 # create attributes for the named items in this container
 self.button = xrc.XRCCTRL(self, button)

 #  Resource data --

 def __init_resources():
 global __res
 __res = xrc.EmptyXmlResource()

 wx.FileSystem.AddHandler(wx.MemoryFSHandler())

 sbs_test_xrc = '''\
 ?xml version=1.0 ?resource version=2.3.0.1 
 xmlns=http://www.wxwindows.org/wxxrc;
 object class=wxDialog name=Dialog
 stylewxDEFAULT_DIALOG_STYLE/style
 title/
 object class=wxFlexGridSizer
 rows2/rows
 cols2/cols
 vgap0/vgap
 hgap0/hgap
 growablecols/
 growablerows/
 object class=sizeritem
 option1/option
 flagwxEXPAND/flag
 border5/border
 object class=wxStdDialogButtonSizer
 object class=button
 
 flagwxALIGN_CENTER_HORIZONTAL|wxALL/flag
 border5/border
 !--
 object class=wxButton 
 name=wxID_OK
 labelamp;OK/label
 /object
 --
 

Re: How is AI implemented

2008-01-03 Thread kyosohma
On Jan 3, 11:49 am, Martin Marcher [EMAIL PROTECTED] wrote:
 Hi,

 I know it's not a trivial field but I had some readings about
 artificial intelligence lately and my personal conclusion is that it's
 mostly just statistics.

 Naively explained:

 continiously gather and store information and apply a default rating

 1) answer questions with gathered information according to rating
 2) store/calculate rating based upon input (be it an interface or user input)
 3) goto 1 (sorry for the goto)

 So I think that in general there hasn't yet been any artificial
 intelligence programmed (Note: I believe I'm aware of the difference
 between artificial intelligence and artificial conscusiness where the
 second would be able to answer things like: How are you today and
 the first can answer factual knowledge)

 Am I thinking right here or is there some (preferrably) web reading
 available on that or in depth links about the topic?

 thanks and sorry for OT posting
 martin

 --http://noneisyours.marcher.namehttp://feeds.feedburner.com/NoneIsYours


Some readings:

http://www-formal.stanford.edu/jmc/whatisai/whatisai.html
http://www.sciencedaily.com/news/computers_math/artificial_intelligence/
http://www.jair.org/
http://dir.yahoo.com/Science/computer_science/artificial_intelligence/

Fuzzy Logic usually crops up as a related topic:

http://www.seattlerobotics.org/encoder/mar98/fuz/flindex.html
http://www.austinlinks.com/Fuzzy/

I'm not involved in this field, but I think saying that AI is just
statistics is a pretty sweeping statement. It's more like super
complicated stats using algorithms worthy of Calculus with branch
logic thrown in for good measure.

How's that for a load of buzz words!?

Hope those links give you lots of info. Let us know when you've got a
cool talking Python program!

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


Re: wxpython application ( problem ? )

2008-01-02 Thread kyosohma
On Jan 2, 5:24 am, [EMAIL PROTECTED] wrote:
 Hello,

 Here is sample of my simple script with wxpython and modules:
 subprocess,threading, directpython...

 Code sample:

 import wx
 import wx.aui
 app=wx.App()
 frame=wx.Frame(None,title=New project)

 #There is also part with wx.aui

 frame.Show()
 app.MainLoop()

 After a few minutes wx application does destroy. Any ides why?

I highly recommend reading this wxPython wiki entry about using
threads in wxPython:

http://wiki.wxpython.org/LongRunningTasks

I've found it quite helpful in my own programming.

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


Re: Bind mouse over event for panel (or Static text) wxPython

2008-01-02 Thread kyosohma
On Jan 2, 6:55 am, SMALLp [EMAIL PROTECTED] wrote:
 How to?

 I couldn't find anything except EVT_ENTER_WINDOW that didn't work.

I use wx.EVT_MOTION, which you would have found had you googled for
wxpython mouse events. The first result is:

http://www.wxpython.org/docs/api/wx.MouseEvent-class.html

which details all the mouse events in wxPython.

As I have mentioned to you before, wxPython questions really ought to
be addressed to the wxPython users group, which you can join here:

http://wxpython.org/maillist.php

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


Re: how to get playtime ( playback time ) of movie files?

2008-01-02 Thread kyosohma
On Jan 2, 6:39 am, Geon. [EMAIL PROTECTED] wrote:
 hi.. i want get playtime of movie files ( avi , mpeg , wav , mov
 etc... )

 how to get ??

 please help me ..

Take a look at PyMedia: http://pymedia.org/

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


Re: Skill Resume Achievements, What Good Goes Here?

2008-01-02 Thread kyosohma
On Jan 2, 9:59 am, vbgunz [EMAIL PROTECTED] wrote:
 I spent some time working on a skill resume, the kind of resume
 college students put together and realized, I am not in college and
 everything I learned was self-taught. Of course I would like some real
 world achievements but don't consider throw-away code an achievement
 and am failing to really see any. I don't even wish to entertain the
 thought of lying about anything.

 What are some achievements an employer may be looking for in someone
 willing to start at ground level, entry level, intern, etc? What are
 some real world achievements every n00b will need under his/her belt
 in order to be taken seriously?

Internships are always a good thing to have. If you've contributed to
open source projects, I'd put that on there. If you're applying for
some kind of programming job, they'll probably want to see some of
your code, know what home-brewed projects you've done and how long
they took to complete, issues you ran into, etc.

That might get you started anyway.

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


Re: Impure Python modules

2007-12-28 Thread kyosohma
On Dec 27, 5:38 pm, Martin v. Löwis [EMAIL PROTECTED] wrote:
  Is there some way to get a list of impure Python modules/extensions
  from PyPI?

 Not easily. To create a full list, you will have to download all
 packages, and check their respective setup.py files for occurrences
 of Extension.


I figured as much. I thought about writing some kind of script based
on the way Easy Setup downloads modules and just doing that, but
there's upwards of 2000 extensions on there.


 A subset can probably be found by looking at all packages classified
 as Programming Language :: C

 http://pypi.python.org/pypi?:action=browsec=181

 or Programming Language :: C++

 http://pypi.python.org/pypi?:action=browseshow=allc=183

 Of course, some of those may only generate C, or deal with C in
 some other sense than being written in it.

 HTH,
 Martin

Thanks, Martin. Those links will be helpful. I'll start looking at
them this weekend.

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


Re: os.system question

2007-12-28 Thread kyosohma
On Dec 28, 12:57 pm, stanleyxu [EMAIL PROTECTED] wrote:
 To note this problem occurs when debugging script in IDLE editor.
 When I double click on my_script.py, all outputs will be printed in one
 console.

 --
 ___
oo  // \\
   (_,\/ \_/ \ Xu, Qian
 \ \_/_\_/  stanleyxu2005
 /_/   \_\


Why are you using os.system for these commands in the first place? You
should be using the os and shutil modules instead as they would be
more cross-platform friendly.

Something like this:

# untested
for new_folder, old_folder in folder_array:
   os.mkdir(new_folder)
   shutil.copytree(old_folder, new_folder)


Adjust the path as needed in the mkdir call.

See shutil's docs for more info:
http://docs.python.org/lib/module-shutil.html

And here's some folder manipulation docs:
http://effbot.org/librarybook/os.htm

By the by, the subprocess module is supposed to be used in place of
the os.system and os.popen* calls: 
http://docs.python.org/lib/module-subprocess.html

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


Re: os.system question

2007-12-28 Thread kyosohma
On Dec 28, 1:32 pm, stanleyxu [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  On Dec 28, 12:57 pm, stanleyxu [EMAIL PROTECTED] wrote:
  To note this problem occurs when debugging script in IDLE editor.
  When I double click on my_script.py, all outputs will be printed in one
  console.

  --
  ___
 oo  // \\
(_,\/ \_/ \ Xu, Qian
  \ \_/_\_/  stanleyxu2005
  /_/   \_\

  Why are you using os.system for these commands in the first place? You
  should be using the os and shutil modules instead as they would be
  more cross-platform friendly.

  Something like this:

  # untested
  for new_folder, old_folder in folder_array:
 os.mkdir(new_folder)
 shutil.copytree(old_folder, new_folder)

  Adjust the path as needed in the mkdir call.

  See shutil's docs for more info:
 http://docs.python.org/lib/module-shutil.html

  And here's some folder manipulation docs:
 http://effbot.org/librarybook/os.htm

  By the by, the subprocess module is supposed to be used in place of
  the os.system and os.popen* 
  calls:http://docs.python.org/lib/module-subprocess.html

  Mike

 Thanks Mike,

 you have provided another option.

 But my question has not been answered yet. The reason, why I use
 os.system(), is that I want to avoid accident file deletion by writing a
 script. My real script looks like:



Technically speaking, the shutil module's copytree function will not
delete ANYTHING if the destination already exists. It will just fail.
You could catch the failed copy with a try/except that prints an
appropriate message detailing the error.

 # 1. Funtion to execute a command in DOS-console
 def execCommand(cmd):
  if DEBUG_MODE:
  print 'DOS ' + cmd;
  else:
  os.system(cmd);

 # 2.1 Creates temp folder. Removes it first, if it exists.
 if os.path.exists(tmp_folder):
  execCommand('RD ' + tmp_folder + ' /S /Q');
 execCommand('MD ' + tmp_folder + '');

 # 2.2 Copies all files to the temp folder, that are going to be put in
 package.
 for source_folder, dest_folder in folders_array:
  if not os.path.exists(dest_folder):
  execCommand('MD ' + dest_folder + '');
  execCommand('XCOPY \' + source_folder + ' ' + dest_folder + ' /Y');

 The benefit is that, when I set DEBUG_MODE=True, I can see what will be
 executed. So that I can make sure that my script will not delete any
 other important files by accident.

 --
 ___
oo  // \\
   (_,\/ \_/ \ Xu, Qian
 \ \_/_\_/  stanleyxu2005
 /_/   \_\


Carl Banks mentioned the subprocess module too and he pointed out its
output redirection capabilities. I recommend checking those out too.
You may be able to do some redirection by changing where stdout and
stderr print to.

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


Re: i18n questions

2007-12-28 Thread kyosohma
On Dec 28, 12:01 pm, Donn Ingle [EMAIL PROTECTED] wrote:
 Hi,
  A soon-to-be happy new year to everyone!

 I'm 100% new to this i18n lark and my approach so far has been to create
 a .mo file per module in my app.
  My thinking was, why load one huge .mo file when a single module only needs
 a few strings? Since then, it seems, I have made the wrong decision.

 For example I have module A that imports module B. Each one does this:

 gettext.install( domain, localedir, unicode = True )
 lang = gettext.translation(domain, localedir, languages = [ loc ] )
 lang.install(unicode = True )

 (where doman is the name of the module, so A and B)

 The problem is that domain A loads and then import B happens and so
 the lang reference (I think) gets replaced by domain B -- the result is
 that module A can only translate strings that are in domain B.

 How does one 'merge' gettext.translations objects together? Or is that
 insane?

 What's the best way to handle a project with multiple domain.mo files?

 I hope someone can give me some advice.

 \d

I've never messed with .mo files, but a little googling turned up
this interesting module on PyPI: 
http://cheeseshop.python.org/pypi?%3Aaction=searchterm=polib

If you're messing with unicode in general, I've heard this is a good
article to read:
http://kevino.theolliviers.com/python-unicode.html

This article looks related, although the author is using .po instead
of .mo files:
http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/

Finally, I found a wxPython specific one that looks like it might be
general enough for you:
http://wiki.wxpython.org/Internationalization

I hope that gives you some ideas anyway.

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


Re: Python mouse EVT_COMMAND_LEFT_CLICK, EVT_LEFT_DOWN

2007-12-27 Thread kyosohma
On Dec 27, 10:59 am, SMALLp [EMAIL PROTECTED] wrote:
 Hy!
 I'm not able to tu bind mouse click event. Code:

 class MouseClass(wx.Panel):
 def __init__(self, parent, id):

 wx.Panel.__init__(self, parent, id, size=(500, 300))
 self.SetBackgroundColour(WHITE)

 sizer = wx.BoxSizer(wx.VERTICAL)

 testPanel.SetBackgroundColour(BLACK)
 self.Bind(wx.EVT_COMMAND_LEFT_CLICK, self.open, 
 id=testPanel.GetId())
 sizer.Add(testPanel, 0, wx.EXPAND)
 self.SetSizerAndFir(sizer)

 def open(self, event):
 print yea

 U  tried EVT_LEFT_DOWN as I found on goofle and couldnt get it to work.
 Please help.


It would help if you included working code, for one thing. Maybe I'm
blind, but I don't see a sub-panel getting instantiated with the name
testPanel.

SetSizerAndFir is not a valid wx command.

All you need can be found here: 
http://www.wxpython.org/docs/api/wx.MouseEvent-class.html

If you do the following, it works:

code

import wx

class MouseClass(wx.Panel):
def __init__(self, parent, id):

wx.Panel.__init__(self, parent, id, size=(500, 300))
self.SetBackgroundColour(WHITE)

self.Bind(wx.EVT_LEFT_DOWN, self.open, id=self.GetId())


def open(self, event):
print yea

if __name__ == '__main__':
app = wx.PySimpleApp()
frm = wx.Frame(None, wx.ID_ANY, 'Mouse-click test')
panel = MouseClass(frm, wx.ID_ANY)
frm.Show()
app.MainLoop()

/code

One other note: wxPython issues should be reported to the wxPython
user's group.

HTH

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


Re: Cheat sheet

2007-12-27 Thread kyosohma
On Dec 27, 11:38 am, Riccardo T. [EMAIL PROTECTED] wrote:
 I wrote a little cheat sheet for this wonderful language, but because of
 my still little experience with it, I would like to have a feedback
 Could you have a look at it and tell me what do you think about, please?

 http://greyfox.imente.org/index.php?id=73

 --
 GreyFox

Looks cool, but you might find these interesting too:

http://www.limsi.fr/Individu/pointal/python/pqrc/
http://mail.python.org/pipermail/python-list/2006-June/386662.html

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


Re: Cheat sheet

2007-12-27 Thread kyosohma
On Dec 27, 1:44 pm, Riccardo T. [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] ha scritto:

  Looks cool, but you might find these interesting too:

 http://www.limsi.fr/Individu/pointal/python/pqrc/
 http://mail.python.org/pipermail/python-list/2006-June/386662.html

  Mike

 Thanks :)
 I'll read them to improve my python knowledge, but I prefere to have a
 very small cheat sheet to keep near me.

 --
 GreyFox

Yeah...they can be handy. I like that Quick Reference card, but it is
a little unwieldy.

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


Impure Python modules

2007-12-27 Thread kyosohma
Hi,

Is there some way to get a list of impure Python modules/extensions
from PyPI?  I know the mySQL module is a good example, but I am
working on creating some decent instructions on how to create Windows
installers from impure modules and am having a hard time finding them.

Thanks!

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


Re: Python/Tkinter DLL conflicts on Windows

2007-12-26 Thread kyosohma
On Dec 26, 1:03 pm, Russell Blau [EMAIL PROTECTED] wrote:
 I have some Tkinter programs that I run on two different machines.  On
 Machine W, which runs Python 2.5.1 on Windows XP, these programs run fine.
 On Machine H, which runs Python 2.5.1 on Windows XP, however, the same
 programs crash regularly.  The crashes are not Python exceptions, but rather
 are reported by Windows as errors in pythonw.exe.  (Of course, the error
 messages themselves contain absolutely no useful information.)  This happens
 whether I run them from the command prompt or from IDLE (although IDLE
 itself never crashes).  Further, the crashes occur at unpredictable times;
 sometimes the program will crash almost immediately upon startup, while at
 other times it will run for a while and then crash.

 Also, I'm not sure whether this has anything to do with my problem, but
 Machine H also has Python 2.2 installed on it, while Machine W does not.

 I recall seeing a message at some point that suggested that conflicts in the
 MS VC runtime DLLs might cause this sort of problem, but I haven't been able
 to find that information through a search, so I'm not sure which particular
 DLLs to look for.  Any help in tracking down the source of this problem
 would be appreciated.

 Russ

Hi,

In the programs I write and package, I usually distribute msvcp71.dll
and MSVCR71.dll. I include them in the directory that the Python exe
I've created is running from. However, it sounds like you are running
pure code, not something packaged with py2exe.

You might run sfc and see if your dlls are ok. See 
http://support.microsoft.com/kb/310747

A friend of mine swears by this: http://wiki.djlizard.net/Dial-a-fix

Of course, it might be as simple as just uninstalling and reinstalling
Python.

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


Re: SWbemObjectEx not found

2007-12-25 Thread kyosohma
On Dec 24, 1:01 pm, jmgmail [EMAIL PROTECTED] wrote:
 I have a working VBScript and failed to convert it to Python. Can
 someone help?

 ==VBScript:==
 Set locator = CreateObject(WbemScripting.SWbemLocator)
 Set Services = locator.ConnectServer(smsroot1,root/SMS/site_A)
 Set instCollection =
 Services.Get(SMS_Collection.CollectionID='A000D9')

 'Create the direct rule.
 Set instDirectRule =
 Services.Get(SMS_CollectionRuleDirect).SpawnInstance_
 instDirectRule.ResourceClassName = SMS_R_System
 instDirectRule.ResourceID = 8566
 instDirectRule.RuleName = MyDirectRule

 'Add the direct rule to the collection.
 instCollection.AddMembershipRule instDirectRule
 ==END==

 ==Python==
 import sys,os,getopt
 import win32com.client

 locator = win32com.client.Dispatch(WbemScripting.SWbemLocator)
 locator.Security_.impersonationlevel = 3
 Services = locator.ConnectServer(smsroot1,root/SMS/site_A)
 instCollection = Services.Get(SMS_Collection.CollectionID='A000D9')

 instDirectRule =
 Services.Get(SMS_CollectionRuleDirect).SpawnInstance_()
 instDirectRule.ResourceClassName = SMS_R_System
 instDirectRule.ResourceID = 8566
 instDirectRule.RuleName = MyDirectRule

 instCollection.AddMembershipRule(instDirectRule)
 ==END==

 The error from Python is:
 Traceback (most recent call last):
   File C:\temp\pushpkg.py, line 19, in ?
 instCollection.AddMembershipRule(instDirectRule)
   File C:\Python24\lib\site-packages\win32com\client\dynamic.py,
 line 491, in
 __getattr__
 raise pythoncom.com_error, details
 pywintypes.com_error: (-2147352567, 'Exception occurred.', (0,
 'SWbemObjectEx',
 'Not found ', None, 0, -2147217406), None)
 ==END==

 Spend a whole day on this already and still have no clue.

 Thank you.

I'm not seeing the error either. You should post to the PyWin32
mailing list as they have more experience there:

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

Plus, Mark Hammond occasionally answers questions there too. He wrote
(or co-wrote) the module, FYI.

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


Re: How to detect when a user switches between windows (in WinXP)?

2007-12-25 Thread kyosohma
On Dec 25, 4:31 am, [EMAIL PROTECTED] wrote:
 Hi everyone,

 I'm a beginning-to-intermediate Python programmer with some experience
 in other languages. At the moment I am trying to write a Python
 program that will run in the background and execute a series of
 commands whenever I switch between windows (my OS is Windows XP). For
 example, I want my program to do something when I switch to my Firefox
 browser, and then do something else when I switch to a certain sub-
 window in Photoshop (which has a certain title, and a certain photo
 associated with it), then do yet another thing when I switch to
 another sub-window (with a different title and photo) within
 Photoshop.
 The particular actions will be based on the window's title. I've
 already figured out how to retrieve that, using
 GetWindowText(GetForegroundWindow()) from the win32gui module.
 My question is, how can I detect when the user switches between
 windows? I haven't been able to figure that part out yet.
 Searching the group didn't give me any answers.
 Your help is greatly appreciated. Thanks!

 Assaf.

What you most likely want to do is run the win32gui call inside an
infinite loop. Something along these lines:

# untested code
import time
while True:
   winTitle = GetWindowText(GetForegroundWindow())
   if winTitle == 'some string':
   # do something
   time.sleep(1) # nap for a second


This will check once a second to see what window you have up. You'll
probably want to set some kind of sentinel value when it does
something to the current window so it doesn't repeatedly do that
something each second. Thus, the if-then logic will need to be more
complex, but this should get you going.

HTH

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


Re: Pure Python GUI lib?

2007-12-22 Thread kyosohma
On Dec 22, 7:31 am, oyster [EMAIL PROTECTED] wrote:
 For the word Pure, I mean it is not a C/C++/Z++.. extension, so that
 we can use it under  pythons of different version. Is it possible?
 I don't like to update the module for different python and the module

 Currently, I am writing the interface to
 iup(http://www.tecgraf.puc-rio.br/iup) via ctypes, but find 2 too
 strange things which have let me feel blue for some days, and I don't
 know whether it can be successful or not. Can anyone give me some
 lights? Thank you. :)

 You can download the files 
 athttp://pyguiviactypes.googlepages.com/mini_bug.zip
 I am using python 2.5.1 on win2k with sp4


snip

While wxPython may not be pure (per se), it DOES offer some MDI
interfaces. And it works with 2.3 - 2.5. I would think that that would
be good enough for the purposes you mention in your post.

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


Re: Beginner question!

2007-12-21 Thread kyosohma
On Dec 21, 9:11 am, SMALLp [EMAIL PROTECTED] wrote:
 Hy! I have error something like this

 TypeError: unbound method insert() must be called with insertData
 instance as first argument (got str instance instead)

 CODE:

 File1.py
 sql.insertData.insert(files, data)

 sql.py

 class insertData:
 def insert(self, dataTable, data):
 conn = self.openConnection.openConnection()
 cursor = conn.cursor()
 sql =INSERT INTO +dataTable+ (user_name, file_name, 
 file_size,
 file_path_local, file_path_FTP, curent_location, FTP_valid_time,
 uploaded, last_modified, last_verified, file_type, file_category) VLAUES
 +data
 cursor.execute(sql)
 conn.Close()

 Help and advice neaded!

I think you need to post the real traceback or the real code since
your error message doesn't look like it has anything to do with the
code above. At least, I do not see a method named insert.

Which database module are you using?

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


Re: Beginner question!

2007-12-21 Thread kyosohma

 Traceback (most recent call last):
File /home/pofuk/MzMFIleShare/sharePanel.py, line 130, in share
  self.scanDirsAndFiles(dirPath)
File /home/pofuk/MzMFIleShare/sharePanel.py, line 158, in
 scanDirsAndFiles
  sql.insertData.insert(files, data)
 TypeError: unbound method insert() must be called with insertData
 instance as first argument (got str instance instead)

 share.py


snip


 def scanDirsAndFiles(self, dirPath):
 for item in os.listdir(dirPath):
 if os.path.isdir(os.path.join(dirPath, item)):
 scanDirsAndFiles(os.path.join(dirPath, item))
 if os.path.isfile(os.path.join(dirPath, item)):
 user_name = login.getUserName()
 fileName = item
 fileSize = 
 os.path.getsize(os.path.join(dirPath, item))
 filePathLocal = os.path.join(dirPath, item)
 filePathFTP = 
 currentLocation = Local
 FTP_valid_time = 7
 uploaded = 
 lastModified = NOW()
 lastVerified = NOW()
 fileType = file
 fileCategory = Ostalo

 data = [fileName, fileSize, filePathLocal, 
 filePathFTP,
 currentLocation, FTP_valid_time, uploaded, lastModified, lastVerified,
 fileType, fileCategory]

 sql.insertData.insert(files, data)



snip


 class insertData:
 def insert(self, dataTable, data):
 conn = self.openConnection.openConnection()
 cursor = conn.cursor()
 sql =INSERT INTO +dataTable+ (user_name, file_name, 
 file_size,
 file_path_local, file_path_FTP, curent_location, FTP_valid_time,
 uploaded, last_modified, last_verified, file_type, file_category) VLAUES
 +data
 cursor.execute(sql)
 conn.Close()

It doesn't look like you are instantiating the insertData class. You
would need to do something like:

# untested
foo = insertData()
foo.insert(files, data)


But I agree with Chris. You really do need to go through a tutorial on
using classes and following Python naming conventions. Dive Into
Python and some of the other online resources are very helpful.

This is something that I have trouble with myself since wxPython uses
CamelCase for classes and methods/functions and and most
recommendations for plain Python seem to only want CamelCase for
classes and something like myFunct or myMethod for the other objects.

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


Re: Understanding memory leak reports

2007-12-21 Thread kyosohma
On Dec 21, 12:44 pm, Giampaolo Rodola' [EMAIL PROTECTED] wrote:
 Hi,
 I'm in a big trouble since I don't know how to find some memory leaks
 I just discovered in a program of mine.
 By putting:

 import gc
 gc.set_debug(gc.DEBUG_LEAK)

 ..at the end of a script which imports a module I wrote it seems I
 have some memory leaks scattered around.
 The message printed on screen is the following:

 gc: collectable function 00C70E70
 gc: collectable type 00B41018
 gc: collectable dict 00C6DE40
 gc: collectable tuple 00C09900
 gc: collectable tuple 00BCD510
 gc: collectable function 00C70EB0
 gc: collectable function 00C70E30

 Since the main module is very big (more than 2800 lines of code) I do
 not understand which objects are not garbage collected.
 Is there a way to have a more detailed message to know which objects
 are not garbage collected?
 For example function foo, method MyClass.bar, dict my_dict...
 function 00C70E70 and tuple 00C09900 are too much generic messages
 which don't give me an idea about where the leak could be.

I've never done this before, but here's what I found while Googling:

Recipe that supposedly gives more info:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65333

Another thread on the same topic that looks quite detailed:
http://www.thescripts.com/forum/thread22097.html

An article or two on memory leaks in Python:
http://utcc.utoronto.ca/~cks/space/blog/python/DebuggingPythonMemoryLeaks
http://www.nightmare.com/medusa/memory-leaks.html

I hope they help.

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


Re: How to draw IE browser content in a window created with PythonWin

2007-12-21 Thread kyosohma
On Dec 21, 1:45 pm, [EMAIL PROTECTED] wrote:
 I'm pretty new to Python and I've been searching all over the place
 to
 find a solution for this.
 I have a html page with some javascript in it and I need to load this
 page in my own window (which I will create using PythonWin). The
 reason for this is to have capability to control the window
 properties
 and at the same time have access to click on the submit buttons in
 the webpage

 So basically, I will open a wepage as shown below -

 import win32com.client
 import win32api
 import win32gui

 ie = win32com.client.Dispatch( InternetExplorer.Application )
 ie.Visible = 1
 ie.Navigate(http://www.microsoft.com/;)

 And then I need to display it in a window that I will create as shown
 below -
 hwnd = CreateWindowEx(...)

 I will be so grateful if anyone can please give me some pointers on
 how to go
 about this.

 Thank you for reading

You might look into using PAMIE or the mechanize module:

http://pamie.sourceforge.net/
http://wwwsearch.sourceforge.net/mechanize/

Trying to control IE with PyWin32 / COM kind of sucks.

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


Re: Beginner question!

2007-12-21 Thread kyosohma
On Dec 21, 1:44 pm, SMALLp [EMAIL PROTECTED] wrote:
 Carsten Haese wrote:
  On Fri, 2007-12-21 at 18:06 +0100, SMALLp wrote:
  sql =INSERT INTO +dataTable+ (user_name, file_name, 
  file_size,
  file_path_local, file_path_FTP, curent_location, FTP_valid_time,
  uploaded, last_modified, last_verified, file_type, file_category) VLAUES
  +data
  cursor.execute(sql)

  Thanks! I solved the problem. And I thing i understand now.

  You may have solved your initial problem, but the above snippet raises
  two red flags:

  1) Why is the table name coming from a variable? This implies to me that
  you a working with a collection of tables with different names that all
  have the same column names. If that is the case, that smells of really
  bad database design. If at all possible, those tables should be merged
  into one table that has an additional column (or set of columns) for
  distinguishing which fragment each row is in.

  2) Sticking literal values into an SQL query string is a bad idea. You
  should learn about parametrized queries, e.g. here:
 http://informixdb.blogspot.com/2007/07/filling-in-blanks.html

  Hope this helps,

 Good question. I'm using only one tale and have no idea why i had table
 name from variable. But every new knowledge comes handy.

 One more question. How does my code looks like. I couldn't find any open
 source program written in python to learn from, so i read some tutorials
 and I'm not sure about how it looks.

You couldn't find any programs written in Python? What the!?

Here's a few:

http://cheeseshop.python.org/pypi/UliPad/3.6/
http://spambayes.sourceforge.net/
http://sourceforge.net/softwaremap/trove_list.php?form_cat=178

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


Re: Is there *any* real documentation to PyWin32?

2007-12-20 Thread kyosohma
On Dec 20, 9:57 am, [EMAIL PROTECTED] wrote:
 On Dec 20, 6:35 am, Benoit [EMAIL PROTECTED] wrote:

  I understand that the Win32 has been said to be itself poorly
  documented, so perhaps that the documentation that comes with the
  modules is of similar quality is no coincidence.  Maybe I'm still too
  young in my programming to grasp the good of that documentation, but
  for myself, it tells me next to nothing.  Could anyone point me to
  anything which may exist that does a better job of explaining the
  extensions' use?  I tried to take a look @ Microsoft's documentation,
  but it was confusing.

 There is Mark Hammond's book [1] about python-win32 though I haven't
 used it and don't know if it contains anything that would be helpful
 to you.
 It is rather old now but some claim that is not important. [2]

 Personally I consider Python-win32 to be docware -- software that is
 sufficiently difficult to use with the included free documentation
 that many people will just buy the $$$ documentation.  Numpy is
 another prominent example of docware.  A misappropriation of the good-
 will value of legitimate open source software.

 [1]http://www.amazon.com/Python-Programming-Win32-Windows-Programmers/
 dp/1565926218/ref=sr_1_1?ie=UTF8s=booksqid=1198165983sr=1-1
 [2]http://groups.google.com/group/comp.lang.python/browse_thread/thread/...

The book of which you speak is still relevant since the Microsoft's
API hasn't changed much. Everything I've tried of their examples has
worked. Unfortunately, it is kind of expensive.

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


Re: Connecting to SQL database

2007-12-20 Thread kyosohma
On Dec 14, 8:24 pm, bill ramsay [EMAIL PROTECTED] wrote:
 Hi

 I have successfully connected to SQL2000 and MSDEE databases in the
 past,  however I have to move to SQL2005 and SQLEXPRESS databases now.

 I've tried the following but with no luck [this is what i used in the
 earlier incarnation except the Provider resource was SQLOLEDB.1]

 Conn = Dispatch('ADODB.Connection')
 Conn.ConnectionString = Provider=SQLNCLI;Server=10.1.1.2;
 Database=csrctest;Uid=bill;Pwd=bill
 print Conn.ConnectionString

 try:
 print 'trying to open'
 Conn.Open()

 etc.

 All I ever get to is the trying to openline,  then it times out.

 I have tried all of the following combinations too:

 Provider=SQLNCLI;Server=localhost;Database=csrctest;Uid=bill;Pwd=bill;

 Provider=SQLNCLI;Server=localhost\SQLEXPRESS;Database=csrctest;Uid=bill;Pwd=bill;

 The SQLEXPRESS database for testing purposes is on my home PC
 [10.1.1.2]

 Any clues s to where I am going wrong?

 Look forward to hearing from someone,  anyone!!

 Kind regards

 Bill

What Python module are you using? At first I thought you were using
the adodb module for Python, but your syntax doesn't look right for
that one.

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


Re: Connecting to SQL database

2007-12-20 Thread kyosohma
On Dec 14, 8:24 pm, bill ramsay [EMAIL PROTECTED] wrote:
 Hi

 I have successfully connected to SQL2000 and MSDEE databases in the
 past,  however I have to move to SQL2005 and SQLEXPRESS databases now.

 I've tried the following but with no luck [this is what i used in the
 earlier incarnation except the Provider resource was SQLOLEDB.1]

 Conn = Dispatch('ADODB.Connection')
 Conn.ConnectionString = Provider=SQLNCLI;Server=10.1.1.2;
 Database=csrctest;Uid=bill;Pwd=bill
 print Conn.ConnectionString

 try:
 print 'trying to open'
 Conn.Open()

 etc.

 All I ever get to is the trying to openline,  then it times out.

 I have tried all of the following combinations too:

 Provider=SQLNCLI;Server=localhost;Database=csrctest;Uid=bill;Pwd=bill;

 Provider=SQLNCLI;Server=localhost\SQLEXPRESS;Database=csrctest;Uid=bill;Pwd=bill;

 The SQLEXPRESS database for testing purposes is on my home PC
 [10.1.1.2]

 Any clues s to where I am going wrong?

 Look forward to hearing from someone,  anyone!!

 Kind regards

 Bill

You might try pymssql:

http://pymssql.sourceforge.net/

I've only used it with MSSQL2000, but according to the website, it
should work with 2005 too.

If you wrapped your database interface with SQLObject or SQLAlchemy,
then (as I understand it) the sql connector module can be swapped out
with little to no work. I hope to move to one of those sooner or
later:

http://www.sqlobject.org/
http://www.sqlalchemy.org/

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


Re: error with wxPython2.8-win32-unicode-2.8.7.1-py25.exe

2007-12-19 Thread kyosohma
On Dec 19, 5:26 am, Emmanuel [EMAIL PROTECTED] wrote:
 I recently upgraded wxpython (and python) on XP using wxPython2.8-
 win32-unicode-2.8.7.1-py25.exe

 Now when I run

 from wxPython.wx import *

 It crashes :

 - import _wx
  ...

 from _misc import *

 ...

 -- 456 wxDateTime_GetNumberOfDaysinYear =
 wx._misc.DateTime_GetNumberOfDaysinYear

 ...

 AtributeError: 'module' object has no atribute
 'DateTime_GetNumberOfDaysinYear'

 Is it a known problem or is there something wrong only on my side?

The newer versions of wx are not supposed to be imported in this way:

from wx import *

The current correct way is to just import wx. I am not sure when this
was started, but it was more than a year ago.

Most of the time, from package import * is NOT recommended as it can
unintended consequences, such as poisoning the namespace. For example,
if you did this with a package that contained an object called foo
and you did this:

foo = 2

Then you just reassigned the foo that was imported.

HTH

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


Re: help displaying pdf thru client/server

2007-12-19 Thread kyosohma
On Dec 19, 1:41 pm, PaulS [EMAIL PROTECTED] wrote:
 Connecting to a Linux server from XP pc using a telnet program, I run a
 report and convert it to a pdf document(using Reportlab) which I need to
 display.  The pdf is on the Linux server. Ideas how to display to the pc
 would be appreciated. thanks, paul

Some ideas, none tested:

1) Use Python to download the document and from the Windows box, do an
os.startfile(path)
2) Use a Python web framework (such as Turbogears, Pylons or Django)
to display the pdf in the browser if acrobat is installed
3) If the pdf is only accessible from a machine on your local network,
than you can do #1 without downloading it if you have samba running.
I've opened PDFs on our Debian boxes like this:
os.startfile(r'\\server\path\to\pdf')

HTH

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


Re: Passing arguments to exe

2007-12-18 Thread kyosohma
On Dec 15, 6:46 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Fri, 14 Dec 2007 16:38:28 -0800 (PST), [EMAIL PROTECTED] declaimed
 the following in comp.lang.python:

  The executable runs, but no argument appears to get passed into it. Of
  course, I don't really know that for sure as the executable doesn't
  redirect stdout/stderr. I tried doing something like this in the above
  reg entry:

  cmd /C c:\program files\myProg.exe %1
  c:\program files\myProg.exe %1
  c:\program files\myProg.exe

 What happens if you put the %1 OUTSIDE the quotes...

 cmd /c c:\program files\myProg.exe %1

 After all, if the quotes are being used to keep the command line seeing
 program files as a single term in the path, then your quotes are also
 treating myProg.exe %1 as a single term.
 --
 WulfraedDennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff:   [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/

This works:

c:\program files\myProg.exe %1

Thanks for the tip.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Allingn controls wxPython

2007-12-16 Thread kyosohma
On Dec 15, 2:14 pm, SMALLp [EMAIL PROTECTED] wrote:
 Hy. I need help. I'm using BoxSizer and i put TextCtrl and StaticText
 next to each other and they gor alligned by top of TextCtrl and it looks
 terrible. How can i make thm to be alligned by center of each controll.

 Thnaks!

A shortcut flag is to just use wx.CENTER. You might find this wiki
entry useful:

http://wiki.wxpython.org/UsingSizers

This article may be fruitful as well:

http://www.devshed.com/c/a/Python/A-Close-Look-at-wxPython-Controls/

I personally use the wxPython in Action book by Dunn quite a bit. It's
got lots of information, although it's not well organized.

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


Re: Passing arguments to exe

2007-12-15 Thread kyosohma
On Dec 14, 8:06 pm, John Machin [EMAIL PROTECTED] wrote:

snipped


  The executable runs,

 how do you know it runs?


because the program's GUI appears on-screen.


  but no argument appears to get passed into it.

 appears??



Since the TO field doesn't get populated with the email address, it
doesn't appear to receive it as an argument. Whereas if I run it as a
script, it does receive the email address.

Mike

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


Passing arguments to exe

2007-12-14 Thread kyosohma
I have created what amounts to a simple GUI email sending program
using Python + wxPython. I have modified the mailto registration in
the Windows Registry so that it launches the script when someone
clicks on someone's email link in a web page.

While this works great if I create a convoluted path command as the
registry entry and pass in the email argument to the script, it
doesn't work at all if I turn my python file into an exe using py2exe.

How does one get a python file to accept arguments when said script
has been turned into an executable?

I'm sure I'm just missing something obvious. I am using Python 2.4 on
Window XP SP2.

Thanks,

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


Re: Python import search path!

2007-12-14 Thread kyosohma
On Dec 14, 3:44 pm, SMALLp [EMAIL PROTECTED] wrote:
 Hy!
 I'm new in Linux, and i feel little less newer in python.

 I need advice and help. I'm making an application witch purpose is
 irrelevant. It has a lot of code for now and I've only made interface.
 So I've tried to split code into separate files and in windows as I
 remember worked file when i wrote  eg. import myFile but now in Ubuntu
 it says Module not found. (I'm using Ubuntu and I've installed python
 2.5 and wxPython 2.8.4, and I'm using GedIt as my favorite text editor).
 The question is how to make this work (files are in the same folder)


Not sure what is going on here from this description. You may need to
use the sys module and add the path to your module temporarily.

import sys
sys.path.append(//path/to/myFile)


 Second question is about import wx. When i separate code into files i
 have to write import wx into every file because all of them contains
 some part of the interface. Does that make my program bigger than
 putting everything into one file and use only one import.

 Thanks in advance.

No, importing wx in multiple files does not make it bigger. In fact,
as I understand it, Python will only import a module if it's not
already in the namespace. So if you import wx in your main module and
then import it again in some sub-module of yours, Python won't
actually import wx the second time, but will just use the one that's
in the namespace already.

See this thread for a more coherent explanation:

http://mail.python.org/pipermail/python-list/2004-November/293861.html

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


Re: Can't get compiled jython to work...

2007-12-14 Thread kyosohma
On Dec 14, 3:51 pm, kramer31 [EMAIL PROTECTED] wrote:
 Hi.  First, I'm not sure if this is the correct group, but becuase I
 couldn't find a jython newsgroup, I'll post here.


If you go to the main jython site at www.jython.com, you will notice a
link on the left under the Community header that is titled Mailing
Lists.

I've never used Jython, so hopefully they can help you...or maybe one
of the Jython moguls here will lend you some advice.

Mike



 I'm new to jython and am just trying to get it to work.  Interpreted
 jython works just fine, but I still can't get my compiled jython to
 work.

 When I do this:

 jythonc fac.py (where fac.py is a jython program), it creates a
 jpywork directory with three files fac.java, fac.class, and fac
 $_PyInner.class

 But if I cd to that directory and do this:

 java -classpath $JYTHON_HOME/jython.jar fac

 I get this error:

 Exception in thread main java.lang.NoClassDefFoundError: fac

 My fac.py looks like this:

 def fac(x):
 if x = 1: return 1
 return long(x) * fac(x-1)

 if __name__ == __main__:
 print 1 + 2
 print Hello + Goodbye
 print fac(3): 
 print fac(3)
 print fac(100): 
 print fac(100)

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


Re: Passing arguments to exe

2007-12-14 Thread kyosohma
On Dec 14, 4:51 pm, John Machin [EMAIL PROTECTED] wrote:
 On Dec 15, 9:01 am, [EMAIL PROTECTED] wrote:

  I have created what amounts to a simple GUI email sending program
  using Python + wxPython. I have modified the mailto registration in
  the Windows Registry so that it launches the script when someone
  clicks on someone's email link in a web page.

  While this works great if I create a convoluted path command as the
  registry entry and pass in the email argument to the script,

 It would help if you would give an actual code example of what you
 mean by convoluted path command and pass in the email argument to
 the script.

Ok, I modify HKEY_CLASSES_ROOT\mailto\shell\open\command to do this:

cmd /C SET PYTHONHOME=\\servername\NETLOGON\Python24\\servername
\netlogon\python24\python.exe \\path\to\my\script\wxsendmail.py %1



  it
  doesn't work at all if I turn my python file into an exe using py2exe.

 it doesn't work is user-speak.

I've written posts where I've been quite technical and gotten very
little to no response...admittedly, this was pretty vague though...


 What does it do? Does it execute the
 executable at all? If not, check your convoluted path. If so, what
 arguments are received?


The executable runs, but no argument appears to get passed into it. Of
course, I don't really know that for sure as the executable doesn't
redirect stdout/stderr. I tried doing something like this in the above
reg entry:

cmd /C c:\program files\myProg.exe %1
c:\program files\myProg.exe %1
c:\program files\myProg.exe

None of those worked.



  How does one get a python file to accept arguments when said script
  has been turned into an executable?

 If the script is expecting its arguments in sys.argv, I would expect
 that to work with an executable also. My guess is that you are falling
 foul of some argument-quoting problem. I also guess that you have not
 tried something like the following at the start of your script:

 print  your_log_file, sys.argv:, repr(sys.argv)

 and run it both as a script and an executable.


I do have my script set up to find its arguments in sys.argv. And no,
I don't have that print screen. As mentioned above, I don't have a
console window open when the exe runs, so I won't see any output from
it. I'll have to modify it to do that when I'm back at my work PC.


 Have you tried running the executable stand-alone e.g. Start | Run,
 type in
 your_exe_file [EMAIL PROTECTED]
 or whatever the argument(s) are?

No, but that's a good idea. Why didn't I think of that!? (don't answer
that)


 HTH,
 John

Thanks for the suggestions.

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


Re: sqlite weirdness

2007-12-13 Thread kyosohma
On Dec 13, 12:12 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
 On Wed, 12 Dec 2007 16:02:35 -0800 (PST), [EMAIL PROTECTED] declaimed
 the following in comp.lang.python:



  Thanks Duncan and John! That makes sense. But why does the official
  Python docs show an example that seems to imply that there is a date
  type? See link below:

 http://docs.python.org/lib/node349.html

 You missed two items... The open specified options to use either the
 type /name/ declared in the CREATE TABLE or a type name attached to the
 field names in a select -- and those are used to /call/ a data converter
 function that has to be registered. Key phrases:

 
 There are default adapters for the date and datetime types in the
 datetime module. They will be sent as ISO dates/ISO timestamps to
 SQLite.

 The default converters are registered under the name date for
 datetime.date and under the name timestamp for datetime.datetime.
 

 
 con = sqlite3.connect(:memory:,
 detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
 
 Note the detect_types specification. Also take care, if your
 database was populated by some other application that used that
 mm/dd/ format, you may have problems as the converters above specity
 /sending/ ISO format to the database from Python datetime objects, and
 probably expecting to convert them back on input.
 --
 WulfraedDennis Lee Bieber   KD6MOG
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 HTTP://wlfraed.home.netcom.com/
 (Bestiaria Support Staff:   [EMAIL PROTECTED])
 HTTP://www.bestiaria.com/

Well, that makes sense. I read the parts you mentioned earlier, but I
guess I just wasn't getting my head around the concepts.

Thanks for clearing that up.

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


Re: sqlite weirdness

2007-12-13 Thread kyosohma
On Dec 13, 1:54 am, Tim Roberts [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:


snipped

 I'll have to refactor my code somewhat to force it to use the '-MM-
 DD' format.

 Another possible solution is to use a real database.

I am using a real database: MS SQL Server 2000. Unfortunately, my
program will also need to run in an offsite location that cannot
connect to that server right now. Thus the need to use sqlite or some
flat-file format.

Thanks for the advice.

Mike


 --
 Tim Roberts, [EMAIL PROTECTED]
 Providenza  Boekelheide, Inc.

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


Re: looking for gui for python code

2007-12-13 Thread kyosohma
On Dec 13, 11:46 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 hi
 i have written some python scripts which take command line arguments
 and do some job. i would like to make it into a .exe using py2exe and
 distribute it with innosetup.. befor that i would like to add some GUI
 support..i mean select some values using a folder explorer etc..which
 would be a good gui builder for this? i have heard about  guibuilder
 fromhttp://spectcl.sourceforge.net/ or is it better to use tkinter
 (i have little experience with gui designing)

 can someone  give a suggestion?
 TIA
 dn

Check out Boa Constructor, SPE or PythonCard. I think they do that
sort of thing.

http://pythoncard.sourceforge.net/
http://boa-constructor.sourceforge.net/
http://pythonide.blogspot.com/

You might be able to use the Python plugin for Eclipse too.

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


Re: Loading an exe icon into a pixmap/bitmap

2007-12-12 Thread kyosohma
On Dec 12, 12:09 am, [EMAIL PROTECTED] wrote:
 I've been searching for a way to load an icon from an executable into
 something that I can eventually display either through pygame or
 pygtk. I've tried the stuff found 
 athttp://groups.google.com/group/comp.lang.python/browse_thread/thread/...
 but the tests just output all black (not surprising, as that guy
 couldn't get it to work either). I've mucked around with taht code and
 the ExtractIcon stuff from pywin32, but still am stuck. I've seen some
 reference to a wxpython ways to do it, but I'm trying to not have to
 convert over to that. Any help is appreciated. Thanks

wxPython uses an included tool called img2py. The source looks pretty
straight-forward. You may be able to modify it or re-create it using
your GUI toolkit of choice.

If you install wxPython, you'll find it (approx.) here:

C:\Python24\Lib\site-packages\wx-2.8-msw-unicode\wx\tools

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


Re: GetPath to variable

2007-12-12 Thread kyosohma
On Dec 11, 5:42 am, Connolly [EMAIL PROTECTED] wrote:
 Hey there, new Python user here.

 Currently, I'm working on a project in Python for my college work, I chose
 to use Python since I heard of its great advantages, now for designing GUI's
 I'm using the wxPython package.
 What I'm trying to do at the moment is the following;
 A file directory browser is created using self.dialong.ShowModal, when the
 user chooses the folder they want to use for this program, then
 self.dialong.GetPath is created, after this it (would) goes into a variable
 and is stored in a config file I'm creating using the ConfigObj module.
 My problem here is GetPath does not want to be stored in some kind of
 variable, is there a specific method to put this string into a variable to
 store in the config file.

 Thanks,

 - Connolly

Gabriel is correct. It needs the () at the end. Download the wxPython
demo as it shows the basic usage of most of the widgets, including the
FileDialog.

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


sqlite weirdness

2007-12-12 Thread kyosohma
Hi,

I am trying to use sqlite to create a local database for an
application I am writing and I am getting some screwy results from it.
Basically, I have a set of values in the database and I am trying to
select a date range and sum those values.

My problem is that it only sums up every other date range and ignores
the in between ranges.

Here's the table structure:

sql = '''CREATE TABLE tbl_TimeEntries (dateworked DATE,
  empid INTEGER,
  reg REAL,
  ot REAL,
  ce REAL,
  hol REAL,
  sklv REAL,
  vac REAL,
  ct REAL,
  conv REAL,
  misc REAL,
  comments TEXT,
  PRIMARY KEY (dateworked, empid))

'''

I have data in it from 12/18/2006 - 01/26/2007.

I use the following bits of sql:

SELECT SUM(reg), SUM(ot), SUM(ce), SUM(hol), SUM(sklv), SUM(vac),
SUM(ct), SUM(conv), SUM(misc) FROM tbl_TimeEntries WHERE dateworked =
'12/17/2006' AND dateworked = '12/30/2006' AND empid = 281

SELECT SUM(reg), SUM(ot), SUM(ce), SUM(hol), SUM(sklv), SUM(vac),
SUM(ct), SUM(conv), SUM(misc) FROM tbl_TimeEntries WHERE dateworked =
'12/31/2006' AND dateworked = '01/13/2007' AND empid = 281

SELECT SUM(reg), SUM(ot), SUM(ce), SUM(hol), SUM(sklv), SUM(vac),
SUM(ct), SUM(conv), SUM(misc) FROM tbl_TimeEntries WHERE dateworked =
'01/14/2007' AND dateworked = '01/27/2007' AND empid = 281

The first and third return the correct sums. The middle one returns a
list of null values.

If I select everything in the database for that user, I get this:

[(u'12/18/2006', 281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'',
u''), (u'12/19/2006', 281, 8.0, u'', u'', u'', u'', u'', u'', u'',
u'', u''), (u'12/20/2006', 281, 8.0, u'', u'', u'', u'', u'', u'',
u'', u'', u''), (u'12/21/2006', 281, 8.0, u'', u'', u'', u'', u'',
u'', u'', u'', u''), (u'12/22/2006', 281, 8.0, u'', u'', u'', u'',
u'', u'', u'', u'', u''), (u'12/25/2006', 281, 8.0, u'', u'', u'',
u'', u'', u'', u'', u'', u''), (u'12/26/2006', 281, 8.0, u'', u'',
u'', u'', u'', u'', u'', u'', u''), (u'12/27/2006', 281, 8.0, u'',
u'', u'', u'', u'', u'', u'', u'', u''), (u'12/28/2006', 281, 8.0,
u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'12/29/2006', 281,
8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'01/01/2007',
281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''),
(u'01/02/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'',
u''), (u'01/03/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'',
u'', u''), (u'01/04/2007', 281, 8.0, u'', u'', u'', u'', u'', u'',
u'', u'', u''), (u'01/05/2007', 281, 8.0, u'', u'', u'', u'', u'',
u'', u'', u'', u''), (u'01/08/2007', 281, 8.0, u'', u'', u'', u'',
u'', u'', u'', u'', u''), (u'01/09/2007', 281, 8.0, u'', u'', u'',
u'', u'', u'', u'', u'', u''), (u'01/10/2007', 281, 8.0, u'', u'',
u'', u'', u'', u'', u'', u'', u''), (u'01/11/2007', 281, 8.0, u'',
u'', u'', u'', u'', u'', u'', u'', u''), (u'01/12/2007', 281, 8.0,
u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'01/15/2007', 281,
8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'01/16/2007',
281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''),
(u'01/17/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'',
u''), (u'01/18/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'',
u'', u''), (u'01/19/2007', 281, 8.0, u'', u'', u'', u'', u'', u'',
u'', u'', u''), (u'01/22/2007', 281, 8.0, u'', u'', u'', u'', u'',
u'', u'', u'', u''), (u'01/23/2007', 281, 8.0, u'', u'', u'', u'',
u'', u'', u'', u'', u''), (u'01/24/2007', 281, 8.0, u'', u'', u'',
u'', u'', u'', u'', u'', u''), (u'01/25/2007', 281, 8.0, u'', u'',
u'', u'', u'', u'', u'', u'', u''), (u'01/26/2007', 281, 8.0, u'',
u'', u'', u'', u'', u'', u'', u'', u'')]
[(80.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]

So the data us there, but the sql only works part of the time. My SQL
works if my database is in SQL Server, but not sqlite. Is my SQL
malformed? Is it something about dates in sqlite? Or is it something
else?

Thanks a lot. I apologize in advance for the long post.

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


Re: sqlite weirdness

2007-12-12 Thread kyosohma
On Dec 12, 2:53 pm, John Machin [EMAIL PROTECTED] wrote:
 On Dec 13, 7:22 am, [EMAIL PROTECTED] wrote:



  Hi,

  I am trying to use sqlite to create a local database for an
  application I am writing and I am getting some screwy results from it.
  Basically, I have a set of values in the database and I am trying to
  select a date range and sum those values.

  My problem is that it only sums up every other date range and ignores
  the in between ranges.

  Here's the table structure:

  sql = '''CREATE TABLE tbl_TimeEntries (dateworked DATE,
empid INTEGER,
reg REAL,
ot REAL,
ce REAL,
hol REAL,
sklv REAL,
vac REAL,
ct REAL,
conv REAL,
misc REAL,
comments TEXT,
PRIMARY KEY (dateworked, empid))

  '''

  I have data in it from 12/18/2006 - 01/26/2007.

  I use the following bits of sql:

  SELECT SUM(reg), SUM(ot), SUM(ce), SUM(hol), SUM(sklv), SUM(vac),
  SUM(ct), SUM(conv), SUM(misc) FROM tbl_TimeEntries WHERE dateworked =
  '12/17/2006' AND dateworked = '12/30/2006' AND empid = 281

  SELECT SUM(reg), SUM(ot), SUM(ce), SUM(hol), SUM(sklv), SUM(vac),
  SUM(ct), SUM(conv), SUM(misc) FROM tbl_TimeEntries WHERE dateworked =
  '12/31/2006' AND dateworked = '01/13/2007' AND empid = 281

  SELECT SUM(reg), SUM(ot), SUM(ce), SUM(hol), SUM(sklv), SUM(vac),
  SUM(ct), SUM(conv), SUM(misc) FROM tbl_TimeEntries WHERE dateworked =
  '01/14/2007' AND dateworked = '01/27/2007' AND empid = 281

  The first and third return the correct sums. The middle one returns a
  list of null values.

  If I select everything in the database for that user, I get this:

  [(u'12/18/2006', 281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'',
  u''), (u'12/19/2006', 281, 8.0, u'', u'', u'', u'', u'', u'', u'',
  u'', u''), (u'12/20/2006', 281, 8.0, u'', u'', u'', u'', u'', u'',
  u'', u'', u''), (u'12/21/2006', 281, 8.0, u'', u'', u'', u'', u'',
  u'', u'', u'', u''), (u'12/22/2006', 281, 8.0, u'', u'', u'', u'',
  u'', u'', u'', u'', u''), (u'12/25/2006', 281, 8.0, u'', u'', u'',
  u'', u'', u'', u'', u'', u''), (u'12/26/2006', 281, 8.0, u'', u'',
  u'', u'', u'', u'', u'', u'', u''), (u'12/27/2006', 281, 8.0, u'',
  u'', u'', u'', u'', u'', u'', u'', u''), (u'12/28/2006', 281, 8.0,
  u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'12/29/2006', 281,
  8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'01/01/2007',
  281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''),
  (u'01/02/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'',
  u''), (u'01/03/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'',
  u'', u''), (u'01/04/2007', 281, 8.0, u'', u'', u'', u'', u'', u'',
  u'', u'', u''), (u'01/05/2007', 281, 8.0, u'', u'', u'', u'', u'',
  u'', u'', u'', u''), (u'01/08/2007', 281, 8.0, u'', u'', u'', u'',
  u'', u'', u'', u'', u''), (u'01/09/2007', 281, 8.0, u'', u'', u'',
  u'', u'', u'', u'', u'', u''), (u'01/10/2007', 281, 8.0, u'', u'',
  u'', u'', u'', u'', u'', u'', u''), (u'01/11/2007', 281, 8.0, u'',
  u'', u'', u'', u'', u'', u'', u'', u''), (u'01/12/2007', 281, 8.0,
  u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'01/15/2007', 281,
  8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''), (u'01/16/2007',
  281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'', u''),
  (u'01/17/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'', u'',
  u''), (u'01/18/2007', 281, 8.0, u'', u'', u'', u'', u'', u'', u'',
  u'', u''), (u'01/19/2007', 281, 8.0, u'', u'', u'', u'', u'', u'',
  u'', u'', u''), (u'01/22/2007', 281, 8.0, u'', u'', u'', u'', u'',
  u'', u'', u'', u''), (u'01/23/2007', 281, 8.0, u'', u'', u'', u'',
  u'', u'', u'', u'', u''), (u'01/24/2007', 281, 8.0, u'', u'', u'',
  u'', u'', u'', u'', u'', u''), (u'01/25/2007', 281, 8.0, u'', u'',
  u'', u'', u'', u'', u'', u'', u''), (u'01/26/2007', 281, 8.0, u'',
  u'', u'', u'', u'', u'', u'', u'', u'')]
  [(80.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)]

  So the data us there, but the sql only works part of the time. My SQL
  works if my database is in SQL Server, but not sqlite. Is my SQL
  malformed? Is it something about dates in sqlite? Or is it something
  else?

  Thanks a lot. I apologize in advance for the long post.

 Try this:
 select * from tbl_TimeEntries where empid = 281 order by
 dateworked
 and see what you get.

 Very short story: sqlite doesn't have a native date type (look at the
 results it's returning (e.g. u'12/18/2006')), and is doing a *string*
 comparison. SQL Server has a native date type and knows your locale.
 If you always work with dates in '-MM-DD' format, you should have
 less bother across locales and across 

Re: python sounds-like module

2007-12-12 Thread kyosohma
On Dec 12, 6:39 pm, Astan Chee [EMAIL PROTECTED] wrote:
 Hi,
 Thanks for all the help from the previous problem. Turns out I didnt
 have to use wxSizers, just change the size of my wxWidgets everytime a
 EVT_SIZE is called.
 Anyway, Im trying to find a python module (im not sure if it exists)
 that takes two words and compares if they sound the same. So 'right' and
 'write' sounds the same or 'u' and 'you' . Also I know this takes into
 account the use of language and accent but is there any out there before
 I start making my own?
 Thanks
 Astan

I don't think this exists. It would require some kind of fuzzy logic
to do, I think. You'll probably want to look into speech recognition
as it sounds the closest to what you want/need.

Here a couple links I found with Google:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/93025
http://speechwiki.org/
http://www.synapseadaptive.com/joel/natlink_m.htm

Otherwise, I think you'd need to write some kind of hash table with
all the variations for each word, then you'd apply some artificial
intelligence or that fuzzy logic I mentioned previously to get what
you want.

And no, I've never done this sort of thing. This is just me rambling
on...

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


Re: python sounds-like module

2007-12-12 Thread kyosohma
On Dec 12, 6:39 pm, Astan Chee [EMAIL PROTECTED] wrote:
 Hi,
 Thanks for all the help from the previous problem. Turns out I didnt
 have to use wxSizers, just change the size of my wxWidgets everytime a
 EVT_SIZE is called.
 Anyway, Im trying to find a python module (im not sure if it exists)
 that takes two words and compares if they sound the same. So 'right' and
 'write' sounds the same or 'u' and 'you' . Also I know this takes into
 account the use of language and accent but is there any out there before
 I start making my own?
 Thanks
 Astan

Oh, and sizers are a good thing in wxPython as they keep the GUI
consistent cross-platform and cross-resolution. You just need to call
Layout(), Fit() or maybe GetBestSize() (or a combination thereof) when
changing the size of the window through deleting or adding widgets
dynamically.

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


Re: how to maximize a Tkinter Window in python TK???

2007-12-12 Thread kyosohma
On Dec 12, 5:11 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 hello @ all,

 subj?

Here's a way to do it in Windows that I found with a quick Google
search:

http://mail.python.org/pipermail/python-list/2003-May/203675.html

You might also cross-post to the Tkinter user group:

http://mail.python.org/mailman/listinfo/tkinter-discuss

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


Re: Ruby's Template Engine for Python

2007-12-10 Thread kyosohma
On Dec 8, 3:24 pm, Samuel [EMAIL PROTECTED] wrote:
 On Sat, 08 Dec 2007 13:06:15 -0800, Steve Howell wrote:
  This is what I came up with:

 http://pylonshq.com/pastetags/form_remote_tag

 I see that Pylons uses a standard templating systems with all the JS
 renderers hooked into it as standard template function calls. That's
 great, now I just have to find the piece of code that provides those
 callbacks.

 Ah, here it is:

 http://pylonshq.com/WebHelpers/module-webhelpers.html

 And there I go, easily adding the same functionality to any template
 system of my choice. That was easier than I expected.

 Thanks for your help ;-)!

 -Samuel

I think TurboGears does something similar using the Kid template
system. You might find those useful as well:

http://www.kid-templating.org/language.html
http://turbogears.org/

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


Re: Best way to protect my new commercial software.

2007-12-10 Thread kyosohma
On Dec 10, 6:17 am, Tim Chase [EMAIL PROTECTED] wrote:
  So, are there any ways to make it harder to reverse engineer a
  program?

 In addition to the standby of

 -Don't distribute your program (SaaS)

 I'll add to the list:

 -Only distribute your program to people too non-technical to
 consider reverse-engineering

 -Don't document your program (or even better, *mis*document your
 program)

 -Write Lovecraftian code (import goto comes to mind) designed
 to make reverse-engineers go insane trying to figure out what you
 were thinking

 -In your Python, drop to in-line assembly language for
 business-logic optimization.  Only targeting specific models of
 obscure processor architectures helps minimize your audience.

 -Write software that does nothing of interest/value/use

 Just a couple ideas to get an enterprising young coder off on the
 right track ;)

 -tkc

Don't forget pyobfuscate:

http://www.lysator.liu.se/~astrand/projects/pyobfuscate/
http://bitboost.com/

Fun to play with...although not necessarily much more secure.

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


Re: eclipse pywintypes.com_error

2007-12-07 Thread kyosohma
On Dec 7, 9:10 am, Tim Golden [EMAIL PROTECTED] wrote:
 Spindle wrote:
  I checked the key,and it was found under HKEY_CLASSES_ROOT.And as i
  mentioned before,
  the problem happens only with eclipse and pydev,on the same machine i
  can run the script from command line or with IDLE without any errors.

 Well, that's bizarre then. Hopefully someone else can chime in
 with an idea.

 TJG

This is just a theory, but since Vista is supposed to be more secure,
maybe Eclipse doesn't have the rights to access that particular
registry entry. I recall reading that Norton and McAfee had a lot of
trouble getting access to Vista's internals...

I'm not sure why Python would though. I've also heard that if such-and-
such a program isn't installed in the correct place, it doesn't always
function correctly, so that might be the issue too.

Then again, maybe I'm just blowing smoke.

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


Re: Gnu/Linux dialogue boxes in python

2007-12-07 Thread kyosohma
On Nov 30, 7:55 am, Donn Ingle [EMAIL PROTECTED] wrote:
 Hi,
  Okay, so I am in the mood to try this: Inform the user about what modules
 the app requires in a graphical dialogue that can vary depending on what
 the system already has installed. (It will fail-to output on cli)

 I am running Kubuntu and I seem to have 'kdialog' installed by default (not
 sure if it came as stock.)

 What other 'stock' systems are there out there in the wild? Ubuntu? Suse?
 Fedora? Others?

 I would take a stab at wrapping them in python so that I can use the first
 dialogue system found to popup messages for the user.

 (Hoping, natch, that this has already been done ... ? )

 \d

If you built a GUI with wxPython, it would just use the OS's native
dialogs unless it didn't have one and then it would use a generic
dialog. I would think creating a installer with wxPython and threads
would be fairly trivial.

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


Re: Distutils help for sub-packages

2007-12-06 Thread kyosohma
On Dec 6, 2:37 pm, Rick Muller [EMAIL PROTECTED] wrote:
 On Dec 5, 7:20 am, [EMAIL PROTECTED] wrote:



  I recommend asking the distutils guys at their list:

 http://mail.python.org/mailman/listinfo/distutils-sig

  Mike

 I did, and no one replied there either. Probably because everyone,
 there and here, were too polite to say that I was nutso. Which, it
 turns out, I was. After not hearing from two normally helpful forums
 (fora?) I went back a little more carefully and found the bug. Sorry
 for the false alarm.

Sorry to hear that...they are both pretty helpful in most cases.
C.l.py doesn't usually mind telling OP's that they're nutso either. I
personally didn't think you were, but I didn't know how to answer your
question either.

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


Re: Converting LF/FF delimited logs to XML w/ Python?

2007-12-05 Thread kyosohma
On Dec 5, 3:19 pm, Kadin2048 [EMAIL PROTECTED] wrote:
 This is a very noob-ish question so I apologize in advance, but I'm
 hoping to get some input and advice before I get too over my head.

 I'm trying to convert some log files from a formfeed- and
 linefeed-delimited form into XML.  I'd been thinking of using Python to
 do this, but I'll be honest and say that I'm very inexperienced with
 Python, so before I dive in I wanted to see whether some more
 experienced minds thought I was choosing the right tool.

 Basically, what I want to do is convert from instant messaging logs
 produced by CenterIM, which look like this (Where ^L represents ASCII
 12, the formfeed character):

 ^L
 IN
 MSG
 1190126325
 1190126325
 hi
 ^L
 OUT
 MSG
 1190126383
 1190126383
 hello

 To an XML-based format* like this:

 chat account=joeblow service=AIM version=0.4
   message sender=janedoe time=1190126325hi/message
   message sender=joeblow time=1190126383hello/message
 /chat

 Obviously there's information in the bottom example not present in the
 top (account names, protocol), but I'll grab those from the file name or
 prompt the user.

 Given that I'd be learning as I go along, is Python a good tool for
 doing this? (Am I totally insane to be trying this as a beginner?) And
 if so, where should I start?  I'd like to avoid massive
 wheel-reinvention if at all possible.

 I'm not afraid to RTFM but there's a lot of information around on Python
 and I'm not sure what's most relevant.  Suggestions on what to read,
 books to buy, etc., are all welcomed.

 Thanks in advance,
 Kadin.

 * For the curious, this is sort of poor attempt at the Universal Log
 Format as used by Adium on OS X.

 --http://kadin.sdf-us.org/

I've used lxml and DOM/minidom. Both took my a while to figure out and
I still don't always understand them. Anyway, lxml is similar to the
method Chris mentioned.

http://docs.python.org/lib/module-xml.dom.html
http://www.oreilly.com/catalog/pythonxml/chapter/ch01.html
http://pyxml.sourceforge.net/topics/

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


Re: Timeout test hangs IDLE

2007-12-05 Thread kyosohma
On Dec 5, 6:00 am, Andreas Tawn [EMAIL PROTECTED] wrote:
 I'm trying to integrate the timeout function from 
 herehttp://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/473878into a
 long running automation script and the following code causes IDLE after
 20 or 30 iterations in countTest.

 This is in 2.5, XP and there's no traceback.

 Could someone point me at the user error?

 Thanks in advance.

 def countTest():
 for i in xrange(1000):
 print i
 return True

 def timeout(func, args=(), kwargs={}, timeout_duration=1, default=None):
 import threading
 class InterruptableThread(threading.Thread):
 def __init__(self):
 threading.Thread.__init__(self)
 self.result = None

 def run(self):
 try:
 self.result = func(*args, **kwargs)
 except:
 self.result = default

 it = InterruptableThread()
 it.start()
 it.join(timeout_duration)
 if it.isAlive():
 return default
 else:
 return it.result

 def runTest():
 timeout(countTest, timeout_duration=5)

 if __name__ == __main__:
 runTest()

I'm confused. What does it cause IDLE to do? I tried running the
script and it ran fine. I killed it 17346 since I have no intention of
letting it tie up my work for your extraordinary large iteration
number.

I'm using Python 2.4 on Windows XP.

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


Re: Timeout test hangs IDLE

2007-12-05 Thread kyosohma
On Dec 5, 10:37 am, Andreas Tawn [EMAIL PROTECTED] wrote:
   On Dec 5, 6:00 am, Andreas Tawn [EMAIL PROTECTED] wrote:
I'm trying to integrate the timeout function from
   herehttp://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/47
   3878into a
long running automation script and the following code
   causes IDLE after
20 or 30 iterations in countTest.

This is in 2.5, XP and there's no traceback.

Could someone point me at the user error?

Thanks in advance.

def countTest():
for i in xrange(1000):
print i
return True

def timeout(func, args=(), kwargs={}, timeout_duration=1,
   default=None):
import threading
class InterruptableThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.result = None

def run(self):
try:
self.result = func(*args, **kwargs)
except:
self.result = default

it = InterruptableThread()
it.start()
it.join(timeout_duration)
if it.isAlive():
return default
else:
return it.result

def runTest():
timeout(countTest, timeout_duration=5)

if __name__ == __main__:
runTest()

   I'm confused. What does it cause IDLE to do? I tried running the
   script and it ran fine. I killed it 17346 since I have no
  intention of
   letting it tie up my work for your extraordinary large iteration
   number.

   I'm using Python 2.4 on Windows XP.

   Mike

  Sorry, I need a better proof-reader.

  When I run that code, the output gets to ~26 and then IDLE (or the
  shell, I'm not sure which) hangs and there's  zero CPU activity in the
  pythonw.exe process.

 Also, I should say that the the idea is that the huge iteration should
 timeout after 5 seconds. I only gave it a 1000 range because I
 didn't know how fast it would get through the loop. Perhaps you stopped
 it before the timeout triggered?

 Cheers,

 Drea

No...I ran it for at least 30-60 seconds. Making a thread stop on
command is a pain though.

This link taught me one way to do it, but I cannot vouch how will it
works as I've never aborted any of my threads:

http://wiki.wxpython.org/LongRunningTasks

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


Re: PyObjC and Webkits

2007-12-05 Thread kyosohma
On Dec 4, 1:01 pm, Tommy Grav [EMAIL PROTECTED] wrote:
 I am trying to install PyObjC 1.4 on my Mac OS X 10.4.11.

 I run:

 [EMAIL PROTECTED] Temporary/pyobjc-1.4 -- python setup.py bdist_mpkg --
 open
 ** using pyobjc source-deps py2app for building
 running bdist_mpkg
 installing to build/bdist.macosx-10.3-fat/mpkg
 running build
 running build_py
 running build_ext
 Performing task: Generating wrappers  stubs
 /Library/Frameworks/Python.framework/Versions/2.5/Resources/
 Python.app/Contents/MacOS/Python Scripts/CodeGenerators/
 cocoa_generator.py
 building 'WebKit._WebKit' extension
 gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -
 fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -
 fPIC -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -
 I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -
 c Modules/WebKit/_WebKit.m -o build/temp.macosx-10.3-fat-2.5/Modules/
 WebKit/_WebKit.o -IModules/objc -DMACOSX -DAPPLE_RUNTIME -no-cpp-
 precomp -Wno-long-double -g -Wall -Wstrict-prototypes -Wmissing-
 prototypes -Wformat=2 -W -Wshadow -Wpointer-arith -Wmissing-
 declarations -Wnested-externs -Wno-long-long -Wno-import -Ibuild/
 codegen/
 In file included from Modules/WebKit/_WebKit.m:23:
 build/codegen/_WebKit_Enum.inc:3:35: error: WebKit/DOMAbstractView.h:
 No such file or directory

 Followed by numerous errors.

 The problem seems to be that the WebKit Framework is not found by the
 install
 script. It is present and located in /System/Library/Frameworks/
 WebKit.framework/
 How can I get the code to find this framework?

 Cheers
TG

I've never done this, but I think you need to learn how to create a
custom manifest file:

http://docs.python.org/dist/manifest.html

Hope that helps!

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


Re: Distutils help for sub-packages

2007-12-05 Thread kyosohma
On Dec 3, 9:44 am, Rick Muller [EMAIL PROTECTED] wrote:
 I need some distutils help. I currently run a python library
 (PyQuante) that, until recently, had all of its modules in a single
 directory, called PyQuante. The setup command in my setup.py module
 had a single packages line:

   packages = ['PyQuante'],

 I moved some of the routines into Basis and IO subdirectories of
 PyQuante, and amended the packages line to be:

   packages = ['PyQuante','PyQuante.Basis','PyQuante.IO'],

 Everything works find if I'm installing from SVN. However, when I
 build a tarball via setup.py sdist, the Basis and IO subdirectories
 are not included. How can I get the distutils to include this?

 Thanks in advance,

 Rick

I recommend asking the distutils guys at their list:

http://mail.python.org/mailman/listinfo/distutils-sig

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


Re: Yet another database question, please

2007-11-30 Thread kyosohma
On Nov 30, 7:23 am, nmp [EMAIL PROTECTED] wrote:
 Hello to all. I am only just learning both Python and PyGTK (with Glade).
 I also need to learn how to use databases in my programs. My preliminary
 research leads me in the direction of SQLAlchemy, which seems to be what
 everybody else is using.

 So, does anyone have a good example that shows how to tie these things
 toegether? I would like to have the GUI dialogs and treeviews directly
 interacting with the underlying tables and/or views.

 [cough]Like Borland Delphi 1.0, in the nineties...[/cough]

 Another question: I found that in Ubuntu, I was able to install the Glade
 widgets for libgnomedb (libgnomedb3-glade3). Would these be usable with
 Python/PyGTK, too? As is too common, the documentation provided is
 somewhat scarce.

 Any sort of pointers or suggestions welcome, of course.

You should try Dabo. It sounds like what you want to do and what Dabo
does dovetails nicely.

http://dabodev.com/

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


Re: Tkinter, wxPython, PyGtk, or PyQt...

2007-11-29 Thread kyosohma
On Nov 28, 7:34 pm, John Jameson [EMAIL PROTECTED] wrote:
 hi carl,

 I'm totally new with graphics for python. I'm using windows, but you
 make it sound like I need to know how to program with MFC to use them?
 Is this true? Can't you just stay in python?
 best,
 John

 I would like like to start doing some GUI-programming in Python, but don't
 know which library to choose.

 Tkinter seems a bit old. Correct me if I am wrong! The layout doesn't look
 as nice as for the others.

I've seen some powerful stuff done in Tkinter. While I prefer
wxPython, it's still a valid choice. If you browse the list, you'll
notice that Tk is going to be (or just has been) upgraded, so Tkinter
should start looking better soon.



 wxPython seems to be the first-hand choice for people doing W32-programming
 (with MFC-experience).


This one changes too often to be included in the official Python
distro. But the changes are also beneficial. If you have a C++
background, then this one should be extremely easy to pick up. I use
it in all my GUI apps now.

From what I've read and seen, wxPython uses the native widgets on
whatever platform it is deployed on, so it should have the native
look and feel most of the time.



 PyGtk seems to be a modern, very clean and nice approach, but with poor
 W32-support. Is PyGtk a mature library with respect to version stability
 and documentation.

 PyQt is a huge library (thanks to Qt), but not free on W32, or?

 Is there any possibility that any of the above-mentioned libraries will be
 included as a standard library in any of the near-future Python
 distributions?

Tkinter is already included with Python and has been for quite some
time.



 I myself program on W32 at work, but use Linux at home. So, which one should
 I start with in order to reduce the effort of learning something new and to
 be productive in the shortest time possible?

 By the way, how do I most easily include plotting capabilities to my
 Python-apps?


The people on the wxPython user's group usually mention matplot for
this sort of thing. I think they combine it with wxPython's drawing/
blitting capabilities, but since I don't do that myself, I am not
completely sure of the implementation.


 Carl

Hope that helps some!

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


Re: wxPython and Tkinter

2007-11-29 Thread kyosohma
On Nov 29, 7:14 am, imbunche [EMAIL PROTECTED] wrote:
 On Nov 29, 7:56 am, whatazor [EMAIL PROTECTED] wrote:

  On 29 Nov, 11:50, whatazor [EMAIL PROTECTED] wrote:

   Hi all,
   I migrate some code from tkinter to wxpython. I need the equivalent
   Tkinter method Tkinter.Tk.after
   in wxPython, but I'm not able to find it. It exist or there are other
   trick to emulate it?

   thank you
   w

  after in Tk method allows to all a function every X milliseconds.

 I think you need to setup an wx.Timer object.
   self.timer = wx.Timer(self)
   self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)

 where the self.OnTimer is the method you want to call.
 You need to start the timer:
  self.timer.Start()

 That's it, I think.

That should definitely work. For documentation, see the following
links:

http://wiki.wxpython.org/Timer
http://www.wxpython.org/docs/api/wx.Timer-class.html
http://www.onlamp.com/pub/a/python/excerpts/chpt20/wxpython.html?page=3

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


Re: Lib for audio?

2007-11-29 Thread kyosohma
On Nov 29, 6:04 am, Dave [EMAIL PROTECTED] wrote:
 I need to read microphone input and determine frequency. Is there a lib
 for that?

 Thanks,
 Dave

You might take a look at the ossaudiodev module (note: it's #nix
only):

http://docs.python.org/lib/module-ossaudiodev.html
http://docs.python.org/lib/mixer-device-objects.html

If you're on Windows, looking at the source for the above module still
might be enlightening.

I also found the following which may or may not be helpful:

http://py.vaults.ca/parnassus/apyllo.py/63131194

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


Re: string conversion latin2 to ascii

2007-11-28 Thread kyosohma
On Nov 27, 5:08 pm, John Machin [EMAIL PROTECTED] wrote:
 On Nov 28, 8:45 am, [EMAIL PROTECTED] wrote:







  On Nov 27, 3:35 pm, Martin Landa [EMAIL PROTECTED] wrote:

   Hi all,

   sorry for a newbie question. I have unicode string (or better say
   latin2 encoding) containing non-ascii characters, e.g.

   s = Ukázka_možnosti_využití_programu_OpenJUMP_v_SOA

   I would like to convert this string to plain ascii (using some lookup
   table for latin2)

   to get

   - Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA

   Thanks for any hits! Regards, Martin Landa

  With a little googling, I found this:

 http://www.peterbe.com/plog/unicode-to-ascii

 and if the OP has the patience to read *ALL* the comments on that blog
 entry, he will find that comment[-2] points to

 http://effbot.python-hosting.com/file/stuff/sandbox/text/unaccent.py

 and comment[-1] (from the blog owner) is Brilliant! Thank you.

 The bottom line is that there is no universal easy solution; you need
 to handcraft a translation table suited to your particular purpose
 (e.g. do you want u-with-umlaut to become u or ue?). The
 unicodedata.normalize function is useful for off-line preparation of a
 set of candidate mappings for that table; it should not be applied
 either on-line or blindly.

 Cheers,
 John

Sorry...I didn't know about translation tables or I would have
mentioned that instead. My bad.

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


Re: WindowsError: [Error 5] Access is denied With _winreg.enum

2007-11-28 Thread kyosohma
On Nov 28, 10:04 am, black_13 [EMAIL PROTECTED] wrote:
 I have included a small script the reproduces the error I am having in
 larger script.
 The line 'hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)'
 seems
 to be causing the error but im not sure why.
 - script 

 import _winreg
 import string

 def reproduce_error():

 for index in
 xrange(_winreg.QueryInfoKey(_winreg.HKEY_LOCAL_MACHINE)[0]):
#get names
name =
 _winreg.EnumKey(_winreg.HKEY_LOCAL_MACHINE,index)
hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
print name

 hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE')
 print hkey
 hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SAM')
 print hkey

 if __name__ == '__main__':
 reproduce_error()
 --- end script
 -
 HARDWARE
 SAM
 Traceback (most recent call last):
   File winreg_error.py, line 19, in module
 reproduce_error()
   File winreg_error.py, line 10, in reproduce_error
 hkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,name)
 WindowsError: [Error 5] Access is denied

If you move the print name line up one line, you'll notice that it's
choking on the Security key. Go to Start -- Run  and type regedit. Go
to that key and right-click it and check its permissions.

On my PC the only user that has complete control is the SYSTEM. So
you'll probably just want to put an exception block in your function
that records the keys that you can't open and continues to run.

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


Re: wxPython problem

2007-11-28 Thread kyosohma
On Nov 28, 1:06 pm, SMALLp [EMAIL PROTECTED] wrote:
 Hy. I'm new in linux (Ubuntu 7.10) as well as in python. I installed
 IDLE, and i installed package python-wxgtkX. I start IDLE and when i
 want co compile my aplication all windows close. Also when i vrite
 smoethin lik thile in IDLE:

 import wx
 app = wx.App()
 wx.Frmae(none, -1)

 same thing, Please help! Thanks!

I'm not sure, but I don't think you downloaded the package correctly.
Go here for complete instructions:

http://wxpython.org/download.php

I think you need to replace the X in python-wxgtkX with the
release number. Something like python-wxgtk2.8 or some such.

Then try to import wx and see if that works.

If none of that works, post to the wxPython user's group which can be
found at the link above.

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


Re: win32serviceutil won't start

2007-11-28 Thread kyosohma
On Nov 28, 1:59 pm, Nikola Skoric [EMAIL PROTECTED] wrote:
 Dana Mon, 26 Nov 2007 08:50:23 -0800 (PST),
 [EMAIL PROTECTED] [EMAIL PROTECTED] kaze:

  Sorry I didn't reply sooner. If you're creating a service based on a
  Python file, check out the following links in addition to the book
  Wolfgang mentioned:

 http://agiletesting.blogspot.com/2005/09/running-python-script-as-win...
 http://www.thescripts.com/forum/thread595660.html
 http://essiene.blogspot.com/2005/04/python-windows-services.html

  That should get you started. Hope it helps!

 Huh. Thank you guys a lot. I took a glance (albeit a rather long one)
 and decided that my users will have to install cygwin if they want to
 use my script. Service handling is just a bit to complicated (after
 creating UNIX daemon with 2 consecutive forks), and I'm not going to
 be paid for this :-D

 --
 Now the storm has passed over me
 I'm left to drift on a dead calm sea
 And watch her forever through the cracks in the beams
 Nailed across the doorways of the bedrooms of my dreams

Yeah...a lot of things on Windows is just too complicated for its own
good. Every now and again you'll stumble across something that's
pretty elegant though.

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


Re: Books on Python

2007-11-28 Thread kyosohma
On Nov 27, 9:05 pm, barcaroller [EMAIL PROTECTED] wrote:
 Can someone kindly recommend some good books on the following:

 Python for beginners
 Python for advanced users

 Is there a bible like Larry Wall's Programming Perl or Bjarne Stroustrup's
 The C++ Programming Language?

For good techniques and advanced knowledge, it's hard to beat Lutz's
tome: Programming Python 3rd Ed. or Chun's Core Python
Programming. Both are huge. Lutz's is a little bit more approachable
and had more extensive code examples, but I learned a lot about
Python's insides from Chun.

The cookbooks are handy too, but if you troll ActiveState already, you
may not need those.

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


Re: Different kinds of Import Errors

2007-11-27 Thread kyosohma
On Nov 27, 7:35 am, Thomas Guettler [EMAIL PROTECTED] wrote:
 If you look at this code, you see there are two kind of ImportErrors:

 1. app_name has no attribute or file managment.py: That's OK.
 2. managment.py exists, but raises an ImportError: That's not OK: reraise

 # Import the 'management' module within each installed app, to 
 register
 # dispatcher events.
 for app_name in settings.INSTALLED_APPS:
 try:
 __import__(app_name + '.management', {}, {}, [''])
 except ImportError, exc:
 if exc.args[0]!='No module named management':
 raise

 I am searching a better solution, since in a future version of python
 the string 'No module namend management' might be changed.

 Any better solution?

I would assume that in the future versions of Python, it would still
mention the word management. In that case, you could do something
like this in the except clause:

# untested
args = exc.args[0]
if args.find('management') != -1:
raise


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


Re: string conversion latin2 to ascii

2007-11-27 Thread kyosohma
On Nov 27, 3:35 pm, Martin Landa [EMAIL PROTECTED] wrote:
 Hi all,

 sorry for a newbie question. I have unicode string (or better say
 latin2 encoding) containing non-ascii characters, e.g.

 s = Ukázka_možnosti_využití_programu_OpenJUMP_v_SOA

 I would like to convert this string to plain ascii (using some lookup
 table for latin2)

 to get

 - Ukazka_moznosti_vyuziti_programu_OpenJUMP_v_SOA

 Thanks for any hits! Regards, Martin Landa

With a little googling, I found this:

http://www.peterbe.com/plog/unicode-to-ascii

You might also find this article useful:

http://www.reportlab.com/i18n/python_unicode_tutorial.html

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


Re: Different kinds of Import Errors

2007-11-27 Thread kyosohma
On Nov 27, 3:50 pm, [EMAIL PROTECTED] (Aahz) wrote:
 In article [EMAIL PROTECTED],

  [EMAIL PROTECTED] wrote:

 # untested
 args = exc.args[0]
 if args.find('management') != -1:
 raise

 YM

 if 'management' in args:
 raise

 HTH, HAND  ;-)
 --
 Aahz ([EMAIL PROTECTED])   *http://www.pythoncraft.com/

 Typing is cheap.  Thinking is expensive.  --Roy Smith

Oops...I've used this method myself. Your method is definitely nicer
and likelier more Pythonic than mine. Live and learn.

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


Re: Handling Menubars in WXGlade

2007-11-26 Thread kyosohma
On Nov 23, 7:57 am, jatin patni [EMAIL PROTECTED] wrote:
 Hi, I recently started working on WXGlade...

 I found some amount of documentation online

 I am having problems integrating event handlers with MenubarsI
 want each menu item to open a new window with custom made
 controls...but I can't find it anywhere.Writing event handler is
 secondary actually...How can I attach each menu item with a custom
 dialog or another window


Actually, using the handler would be primary, not secondary. Here's
how I would do it. I would bind each menu item to a separate handler
and within the handler I would call instantiate the window or dialog.
For example, below I bind my Save menu item to a handler called
onSave.

self.Bind(wx.EVT_MENU, self.onSave, save_menu_item)

In the handler, I can save the programs input in many different ways.
I could open a Save dialog to allow the user to choose where it gets
saved, for example.



 Sorry for the newbie slangI am new to programming...
 Thanks

 --
 [EMAIL PROTECTED]
 Ph: 91-9953411751http://jatinpatni.co.nr

I would also recommend that you post to the wxPython user's group as
they'll be much better suited to answering wx questions. Here's where
you'd need to go: http://wxpython.org/maillist.php

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


Re: win32serviceutil won't start

2007-11-26 Thread kyosohma
On Nov 25, 5:11 pm, Nikola Skoric [EMAIL PROTECTED] wrote:
 Dana Sun, 25 Nov 2007 13:52:35 -0800 (PST),
 [EMAIL PROTECTED] [EMAIL PROTECTED] kaze:

  Looks like Microsoft thinks you mis-spelled it.

 http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w...

  I would check and see if that service is installed on your PC. You can
  go to Start -- Run and type services.msc

  Scroll through there and see if your service is listed. You might
  check to see if you can enable/disable it via that console as well.

 Seems like I misunderstood Windows services (I'm porting UNIX daemon
 to Windows so I'm thinking in UNIX terms). I didn't know I have to
 _install_ a service before I _start_ it. How do I install a service?

 --
 Now the storm has passed over me
 I'm left to drift on a dead calm sea
 And watch her forever through the cracks in the beams
 Nailed across the doorways of the bedrooms of my dreams

Sorry I didn't reply sooner. If you're creating a service based on a
Python file, check out the following links in addition to the book
Wolfgang mentioned:

http://agiletesting.blogspot.com/2005/09/running-python-script-as-windows.html
http://www.thescripts.com/forum/thread595660.html
http://essiene.blogspot.com/2005/04/python-windows-services.html

That should get you started. Hope it helps!

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


Re: spawning a process with subprocess

2007-11-26 Thread kyosohma
On Nov 26, 10:54 am, bhunter [EMAIL PROTECTED] wrote:
 Hi,

 I've used subprocess with 2.4 several times to execute a process, wait
 for it to finish, and then look at its output.  Now I want to spawn
 the process separately, later check to see if it's finished, and if it
 is look at its output.  I may want to send a signal at some point to
 kill the process.  This seems straightforward, but it doesn't seem to
 be working.

 Here's my test case:

 import subprocess, time

 cmd = cat somefile
 thread = subprocess.Popen(args=cmd.split(), shell=True,
 stdout=subprocess.PIPE, stdin=subprocess.PIPE,
 stderr=subprocess.STDOUT, close_fds=True)

 while(1):
   time.sleep(1)
   if(thread.returncode):
  break
   else:
  print thread.returncode

 print returncode = , thread.returncode
 for line in thread.stdout:
print stdout:\t,line

 This will just print the returncode of None forever until I Ctrl-C it.

 Of course, the program works fine if I call thread.communicate(), but
 since this waits for the process to finish, that's not what I want.

 Any help would be appreciated.

I've read that this sort of thing can be a pain. I'm sure someone will
post and have other views though. I have had some success using
Python's threading module though. There's a pretty good walkthrough
here (it uses wxPython in its example):

http://wiki.wxpython.org/LongRunningTasks

Other places of interest include:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/491281
http://uucode.com/texts/pylongopgui/pyguiapp.html
http://sayspy.blogspot.com/2007/11/idea-for-process-concurrency.html

If I were doing something like this, I would have the process write
it's output to a file and periodically check to see if the file has
data.

Hopefully someone with more knowledge will come along soon.

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


Re: spawning a process with subprocess

2007-11-26 Thread kyosohma
On Nov 26, 12:27 pm, bhunter [EMAIL PROTECTED] wrote:
  I've read that this sort of thing can be a pain. I'm sure someone will
  post and have other views though. I have had some success using
  Python's threading module though. There's a pretty good walkthrough
  here (it uses wxPython in its example):

 http://wiki.wxpython.org/LongRunningTasks

  Other places of interest include:

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

  If I were doing something like this, I would have the process write
  it's output to a file and periodically check to see if the file has
  data.

  Hopefully someone with more knowledge will come along soon.

  Mike

 Darn.  Is threading the only way to do it?  I was hoping not to have
 to avoid that.  Would have thought that there might be a way for
 subprocess to handle this automatically.

 Thanks for your help,
 Brian

This is just the way I do it...as I said, there are probably some
other people in the group who will have other opinions. By the way,
your statement I was hoping not to have to avoid that means that you
hoped to use threading...which I think is contradictory to what you
meant.

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


Re: gnosis XML objectify

2007-11-26 Thread kyosohma
On Nov 26, 1:46 pm, Wang, Harry [EMAIL PROTECTED] wrote:
 The gnosis xml libs should not be version specific, but when I try to use 
 Python 2.5, I am getting not well formed (invalid token) errors.

 Harry

When does this happen? When you import the module? When you pass it
some xml? Do you have a full traceback?

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


Re: gnosis XML objectify

2007-11-26 Thread kyosohma
On Nov 26, 2:33 pm, Wang, Harry [EMAIL PROTECTED] wrote:
 Full Traceback enclosed:

 Test Suite Started @ 2007-11-26 11:34:46.617000
 Traceback (most recent call last):
   File C:\UDR2\UDRxmlGateway.py, line 370, in module
 ParseAll()
   File C:\UDR2\UDRxmlGateway.py, line 286, in ParseAll
 py_obj = gnosis.xml.objectify.XML_Objectify(InputFile).make_instance()
   File C:\python25\Lib\site-packages\gnosis\xml\objectify\_objectify.py, 
 line 160, in make_instance
 o = self.ParseFile(self._fh)
   File C:\python25\Lib\site-packages\gnosis\xml\objectify\_objectify.py, 
 line 190, in ParseFile
 self._myparser.ParseFile(file)
 xml.parsers.expat.ExpatError: not well-formed (invalid token): line 68, 
 column 0

 Harry C. Wang
 Sr. Test Engineer (Automation)
 AOL Mobile
 Phone 206 - 268 - 7502
 temporary e-mail: [EMAIL PROTECTED]
 Personal e-mail: [EMAIL PROTECTED]

 

 From: [EMAIL PROTECTED] on behalf of [EMAIL PROTECTED]
 Sent: Mon 11/26/2007 12:19 PM
 To: [EMAIL PROTECTED]
 Subject: Re: gnosis XML objectify

 On Nov 26, 1:46 pm, Wang, Harry [EMAIL PROTECTED] wrote:

  The gnosis xml libs should not be version specific, but when I try to use 
  Python 2.5, I am getting not well formed (invalid token) errors.

  Harry

 When does this happen? When you import the module? When you pass it
 some xml? Do you have a full traceback?

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

Googling the error seems to indicate that the problem may be an
encoding issue. Check the following threads:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg00787.html
http://article.gmane.org/gmane.comp.python.devel/90093
http://mail.python.org/pipermail/python-list/2007-July/450288.html

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


Re: win32serviceutil won't start

2007-11-25 Thread kyosohma
On Nov 25, 2:40 pm, Nikola Skoric [EMAIL PROTECTED] wrote:
 I have a very simple win32serviceutil script:
 import win32serviceutil, time

 win32serviceutil.StartService(burek, localhost)

 time.sleep(10)

 exit()

 It successfuly imports win32serviceutil, and chokes on StartService:
 Traceback (most recent call last):
   File foobar.py, line 3, in ?
 win32serviceutil.StartService(burek, localhost)
   File C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py, line
 399, in StartService
 hs = SmartOpenService(hscm, serviceName, win32service.SERVICE_ALL_ACCESS)
   File C:\Python24\Lib\site-packages\win32\lib\win32serviceutil.py, line
 76, in SmartOpenService
 return win32service.OpenService(hscm, name, access)
 pywintypes.error: (1060, 'OpenService', 'The specified service does not
 exist as an installed service.')

 What does that mean?

 --
 Now the storm has passed over me
 I'm left to drift on a dead calm sea
 And watch her forever through the cracks in the beams
 Nailed across the doorways of the bedrooms of my dreams

Looks like Microsoft thinks you mis-spelled it.

http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2000Msgs/3310.mspx?mfr=true

I would check and see if that service is installed on your PC. You can
go to Start -- Run and type services.msc

Scroll through there and see if your service is listed. You might
check to see if you can enable/disable it via that console as well.

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


Re: Disk Space Script

2007-11-24 Thread kyosohma
On Nov 24, 11:46 am, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
 Hello all,

 I would like to write a script in Python to email me when disk space
 gets below a certain value.

 My first question (I'm sure of many) is how do get this output into a
 dictionary or list to index the values?

 import os
 os.system(df -x cifs -x iso9660 | grep -E ^/dev | awk '{ print
 $1,$4 }')

 [What the output looks like]

 /dev/sda3 15866012
 /dev/sda4 26126712

 I would like to write code that compares /dev/sda* to a number (ex.
 200 - 2GB) and sends an alert if the indexed value is below it.

 I'm a noob so keep it simple.

 Thanks in advance.

I don't know the Unix command for this, but I would just redirect the
output to a file on your system. See the following for more info:

http://www.faqs.org/docs/diveintopython/kgp_stdio.html

You could send the output to a variable and create a file-like stream
too. Either way, read the file (or stream) and then for each line,
split it on the space.

Then you can do the compare and use the email module to email you the
result should it go over your specified amount.

By the by, if you're using Python 2.4 or above, you should switch to
using the subprocess module rather than using os.system since the
latter is being deprecated.

For more on file objects, see the docs:

http://docs.python.org/lib/bltin-file-objects.html

or there's this good article:

http://www.devshed.com/c/a/Python/File-Management-in-Python/

And the email module is explained quite well in the docs too:

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

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


Re: Refreshing GridBagSizer

2007-11-24 Thread kyosohma
On Nov 23, 12:48 pm, Steve S [EMAIL PROTECTED] wrote:
 Hey guys,

 I'm stuck with using a GridBagSizer (wxPython) in a GUI Dialog and am having
 a frustrating time with refreshing it properly.

 Essentially, I've got to refresh the contents of the GridBagSizer on
 occasion with new values.  The way I'm doing it works 4 times out of 5 but
 on the 5th, *all* of the grid objects that are set to various positions in
 the GBS are set to (0,0) :|

 So, the way I refresh it is that I keep a record of all grid objects
 inserted into the GridBagSizer and on refresh, I first iterate through that
 list and destroy everything in it.  I then call Clear() and then Layout()
 and start adding new grid objects.
 i.e. I do this:
 for obj in self.gridObjects:
 obj.Destroy()
 self.gridObjects = []
 self.gbs.Clear()
 self.gbs.Layout
 // Add all new gridObjects, recording them in self.gridObjects

 Again, this works most all the time *except* that sometimes all newly added
 grid objects will end up at (0,0) in the GBS :|

 Am I refreshing it correctly?  Has anybody experienced a similar issue?

 I appreciate any help :)
 Steve
 --
 View this message in 
 context:http://www.nabble.com/Refreshing-GridBagSizer-tf4863314.html#a13917194
 Sent from the Python - python-list mailing list archive at Nabble.com.

You'll probably do better if you email the wxPython user's group for
these kinds of things. But I'll take a shot at it anyway.

Looking at the GridBagSizer's docs, I found it has the following
method: CheckForIntersection. You could use that to make sure there
are no intersections and then handle it when they occur.

See the docs for more info:

http://www.wxpython.org/docs/api/wx.GridBagSizer-class.html

The mailing list is here:

http://wxpython.org/maillist.php

Without knowing what your layout scheme is or how you add the widgets
to the sizer, it's difficult to give a more specific answer. Since you
say it's a dialog, you might want to consider using a simpler sizer or
a group of simpler sizers nested in one another. There's an entry on
the wiki that might be helpful to you as well.

http://wiki.wxpython.org/UsingSizers

Hope that helps.

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


Re: Disk Space Script

2007-11-24 Thread kyosohma
On Nov 24, 2:20 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 On Nov 24, 2:11 pm, [EMAIL PROTECTED] wrote:



  On Nov 24, 11:46 am, [EMAIL PROTECTED] [EMAIL PROTECTED]
  wrote:

   Hello all,

   I would like to write a script in Python to email me when disk space
   gets below a certain value.

   My first question (I'm sure of many) is how do get this output into a
   dictionary or list to index the values?

   import os
   os.system(df -x cifs -x iso9660 | grep -E ^/dev | awk '{ print
   $1,$4 }')

   [What the output looks like]

   /dev/sda3 15866012
   /dev/sda4 26126712

   I would like to write code that compares /dev/sda* to a number (ex.
   200 - 2GB) and sends an alert if the indexed value is below it.

   I'm a noob so keep it simple.

   Thanks in advance.

  I don't know the Unix command for this, but I would just redirect the
  output to a file on your system. See the following for more info:

 http://www.faqs.org/docs/diveintopython/kgp_stdio.html

  You could send the output to a variable and create a file-like stream
  too. Either way, read the file (or stream) and then for each line,
  split it on the space.

  Then you can do the compare and use the email module to email you the
  result should it go over your specified amount.

  By the by, if you're using Python 2.4 or above, you should switch to
  using the subprocess module rather than using os.system since the
  latter is being deprecated.

  For more on file objects, see the docs:

 http://docs.python.org/lib/bltin-file-objects.html

  or there's this good article:

 http://www.devshed.com/c/a/Python/File-Management-in-Python/

  And the email module is explained quite well in the docs too:

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

  Mike

 Thanks for the info... I will do some reading...

If you need some more help, just let us know.

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


Re: Looking to learn python willing to clean up code

2007-11-23 Thread kyosohma
On Nov 22, 7:36 pm, Nathan McSween [EMAIL PROTECTED] wrote:
 Hi I would like to learn python I have background in php, pawn, bash. I was
 wondering if anyone would like to show me the ropes or even just throw me
 some code that needs work and seeing what I come up with. Twisted python
 seems to have very bright people behind it using newer programming ideas
 which would tie in nicely with what I want to know. I have read programming
 python: novice to professional.

There's also the Python Challenge:

http://www.pythonchallenge.com/

You might also check out the Summer of Code project ideas found here:

http://wiki.python.org/moin/SummerOfCode

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


Re: /usr/local/lib/python25.zip

2007-11-23 Thread kyosohma
On Nov 23, 12:05 am, ebzzry [EMAIL PROTECTED] wrote:
 I'm trying to run an application and I got this:

 % meld
 Traceback (most recent call last):
   File /usr/local/bin/meld, line 73, in module
 pygtk.require(2.0)
   File /usr/local/lib/python2.5/site-packages/pygtk.py, line 47, in
 require
 versions = _get_available_versions()
   File /usr/local/lib/python2.5/site-packages/pygtk.py, line 34, in
 _get_available_versions
 for filename in os.listdir(dir):
 OSError: [Errno 2] No such file or directory: '/usr/local/lib/
 python25.zip'

 What went wrong? How can I fix this?

 Thanks in advance.

 P.S. By the way, how can I make my name appear instead of ebzzry at
 the top?

It sounds like you it's looking for Python in the wrong place or you
need to upgrade your pygtk package.

Alas...I don't know how to make my name appear either. I have a
feeling it requires using a real newsgroup reader rather than Google
Groups though.

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


Re: Writing Error in program

2007-11-20 Thread kyosohma
On Nov 20, 3:02 pm, [EMAIL PROTECTED] wrote:
 I have a code that writes to 2 seperate files.  I keep getting a list
 index out of range error.  The strange part is that when checking the
 files that I'm writing too, the script has already iterated through
 and finished writing, yet the error stated implies that it hasn't?  So
 how can it be, that my script has written to the files, yet the error
 is stating that it hasn't made it through the script?  I'll have 15
 files that I have written to and the script will bog out at number
 10?  Is python doing something I'm not seeing?  I printed everything
 that was written on the shell and it shows that it went through the
 script, so how can it still say there are a few files left to iterate
 through?

Could you post some of the code and the traceback? It would be
especially good to see your list and make sure you're iterating
through it correctly. Do you open the file in the loop, write to it
and close it?

How can it write to 15 files and then quit at number 10? That
statement seems to contradict itself.

More details for the group would be great. Thanks!

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


Re: simple question on persisting variable values in a list

2007-11-20 Thread kyosohma
On Nov 20, 3:25 pm, [EMAIL PROTECTED] wrote:
 Hi,

 I am an unabashed noob.

 I am trying to build a list to store values that are generated through
 a loop.  However, every time I append the variable to the list, I'd
 like to reset the variable, but have the value persist in the loop.  I
 understand why this doesn't work because it's a reference not a
 literal value but have been unsuccessful at using copy.copy() or
 anything else to accomplish this:

 for char in splitlines[r]:

 if char == \n:
 temp = copy.deepcopy(templine)
 individline.append(temp)
 templine = 
 else:
 templine += char

 results.append(individline)

 This just gives me the last element in splitlines[r] - what i want is
 to persist each line that is parsed from splitlines[] into the results
 list.

 Appreciate any help,,,

Not sure if this is what you want, but here's what I did:

IDLE session

 x = 'blah\nblah\n'
 lst = []
 templine = ''
 for char in x:
if char == '\n':
temp = templine
lst.append(temp)
templine = ''
else:
templine += char


 lst
['blah', 'blah']

/IDLE session

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


Re: Python too complex ?!?!?!

2007-11-19 Thread kyosohma
On Nov 17, 7:46 am, Brian [EMAIL PROTECTED] wrote:
 Had a unsettling conversation with a CS instructor that
 teaches at local high schools and the community
 college. This person is a long-term Linux/C/Python
 programmer, but he claims that the install, config, and
 library models for C# have proved to be less
 problematic than Python. So both his courses (intro,
 data structs, algorithms) are taught in C#.

 I am a low-end (3-year) journeyman Pythonista, and I
 was attracted to the language because of its
 simplicity. And I have come to enjoy the richness of
 available libraries.

 Many of the good people of this NG may be 'too close'
 to answer, but has Python, as a general devel platform,
 lost its simplicity ? Is library install too complex
 and unreliable ? Will my dog go to heaven ?

If this professor was only using Windows for his environment, then I
might be able to understand his argument better. There are many more
external modules for Python that don't have Windows installers than
there are with binaries. And I've had more than my fair share of
broken setup.py files.

On the other hand, if all that is needed are the standard libraries,
than it's a breeze to install Python since they're all included.

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


Re: Book: Python Power!: The Comprehensive Guide

2007-11-19 Thread kyosohma
On Nov 18, 12:17 am, John Salerno [EMAIL PROTECTED] wrote:
 Anyone know anything about this book? I've read a few intro Python books
 already, but I'm always interested in reading more to reinforce the
 language. No reviews on Amazon yet so I'm not sure if it's good or not.

 Thanks.

It's a mostly good book. I found the author to be slightly arrogant as
he would dismiss certain features of Python on occasion and there were
a couple of huh!? moments where he contradicted what seems (to me)
to be common Python idioms.

But there's a lot to like too. There's a real app or two at the end
and it covers using cgi in Python better than any of the other Python
books I've read.

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


Re: Python too complex ?!?!?!

2007-11-19 Thread kyosohma
On Nov 19, 9:57 am, Chris Mellon [EMAIL PROTECTED] wrote:
 On Nov 19, 2007 8:52 AM,  [EMAIL PROTECTED] wrote:





  On Nov 17, 7:46 am, Brian [EMAIL PROTECTED] wrote:
   Had a unsettling conversation with a CS instructor that
   teaches at local high schools and the community
   college. This person is a long-term Linux/C/Python
   programmer, but he claims that the install, config, and
   library models for C# have proved to be less
   problematic than Python. So both his courses (intro,
   data structs, algorithms) are taught in C#.

   I am a low-end (3-year) journeyman Pythonista, and I
   was attracted to the language because of its
   simplicity. And I have come to enjoy the richness of
   available libraries.

   Many of the good people of this NG may be 'too close'
   to answer, but has Python, as a general devel platform,
   lost its simplicity ? Is library install too complex
   and unreliable ? Will my dog go to heaven ?

  If this professor was only using Windows for his environment, then I
  might be able to understand his argument better. There are many more
  external modules for Python that don't have Windows installers than
  there are with binaries. And I've had more than my fair share of
  broken setup.py files.

  On the other hand, if all that is needed are the standard libraries,
  than it's a breeze to install Python since they're all included.

  Mike

 These modules exist, but aren't that common. Certainly anything you're
 likely to be using in an introductory compsci course is well packaged.
 And even if it's not, it's really not that hard to create packages or
 installers - a days work of course prep would take care of the
 potential problem.

I stand corrected. Thanks for the clarification.

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


Re: Tkinter Problem?

2007-11-19 Thread kyosohma
On Nov 19, 8:13 pm, Davy [EMAIL PROTECTED] wrote:
 Hi all,

 I have written a simple Tkinter program, that is draw a rectangle in a
 canvas, when I press Up key, the rectangle move up. But the program
 seems work not properly? My environment is Python2.5+PythonWin.

 ##--
 from Tkinter import *

 class MyApp:
 def __init__(self,parent):
 self.myContainer1 = Frame(parent)
 self.myContainer1.pack()
 self.canv = Canvas(relief=SUNKEN)
 self.canv.config(width = 300,height=300)
 self.canv.pack()
 self.canv.create_rectangle(100,100,150,150,tags=rect)
 self.canv.bind('Up',self._onUpKey)
 self.canv.bind('Return', self._onReturnKey)
 def _onUpKey(self,event):
 self.canv.move(tagOrId,xAmount=0,yAmount=10)
 def _onReturnKey(self,event):
 print 'Hello world'

 root = Tk()
 myapp = MyApp(root)
 root.mainloop()

 ##--

 Best regards,
 Davy

I'm not sure, but I don't think you can bind the a key to a
canvas...you'd want to bind to the rectangle itself somehow.

Some articles on binding:

http://effbot.org/pyfaq/i-can-t-get-key-bindings-to-work-in-tkinter-why.htm
http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm
http://docs.huihoo.com/tkinter/an-introduction-to-tkinter-1997/intro06.htm

Info on the Canvas object:

# this one talks about setting the focus on an item within the canvas
so that it has key bindings...maybe that will work.
http://effbot.org/tkinterbook/canvas.htm
http://www.pythonware.com/library/tkinter/introduction/canvas.htm

I am not a Tkinter expert. I am much better with wxPython, but I am
only starting to be able to answer questions on that topic.

Hopefully someone with more knowledge will show up shortly.

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


Re: PDF library

2007-11-16 Thread kyosohma
On Nov 15, 7:17 pm, james_027 [EMAIL PROTECTED] wrote:
 hi,

 I am looking for a python PDF library that starts with 'Q' ... I just
 found them somewhere in the internet but I can't find them now that I
 need it. Does someone knows this?

 Thanks

I'm not sure what you're referring to. The best known one is
ReportLabs for generating PDFs in Python code. There's also pyPdf for
merging PDFs and/or extracting information from them, among other
things.

http://pybrary.net/pyPdf/
www.reportlab.org

Maybe if one of these was listed on a foreign site, it was spelled
with a 'Q'?

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


  1   2   3   4   5   6   7   8   >