Re: cx_Freeze.freezer.ConfigError: no initscript named Console

2009-10-09 Thread ici
On Oct 1, 2:19 pm, John j...@nospam.net wrote:
 cx_freeze v4.01
 Python 2.6
 Ubuntu Jaunty

 Following the example of 'cx-freeze hello.py', I'm getting the error
 message below. I put all of the error keywords into google and found no
 hits.

 Some people in various posts have said to use Python 2.5 but a lot of my
 code is using Python 2.6 features.

 Can you telling what I'm doing wrong?

 ./cxfreeze hello.py
 Traceback (most recent call last):
 File ./cxfreeze, line 5, in module
 main()
 File /root/cx_Freeze-4.1/cx_Freeze/main.py, line 178, in main
 silent = options.silent)
 File /root/cx_Freeze-4.1/cx_Freeze/freezer.py, line 85, in __init__
 self._VerifyConfiguration()
 File /root/cx_Freeze-4.1/cx_Freeze/freezer.py, line 325, in
 _VerifyConfiguration
 self._GetInitScriptFileName()
 File /root/cx_Freeze-4.1/cx_Freeze/freezer.py, line 246, in
 _GetInitScriptFileName
 raise ConfigError(no initscript named %s, name)
 cx_Freeze.freezer.ConfigError: no initscript named Console

Hi, I found the same problem when used to install cx_freeze via
easy_install. Download the cx_freeze sorce, than:

sudo setup.py install

Now all is fine.
Ubuntu 9.04, Python 2.6
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-Qt problem with pyuic4

2009-09-23 Thread ici
On Sep 24, 4:45 am, Xavier Lapointe xl.mailingl...@gmail.com wrote:
 Hello,

 Let's suppose you're on Windows.

 If pyuic4 can't be found, you can specified the direct path:
 C:\Python26\pyuic4.bat -o Drive:\your\Path\ui_myGUI.py -x
 Drive:\your\Path\myGUI.ui
 You might need to replace the Python26 with your own version if it
 differs...

 Cheers

Part of one of my projects: build_ui.cmd
[code]
SET PYUIC4=c:\Python25\Lib\site-packages\PyQt4\pyuic4.bat
SET PYRCC4=c:\Python25\Lib\site-packages\PyQt4\pyrcc4.exe

C:
CD C:\Projects\python\PyQT\MmicLogs\gui

CALL %PYUIC4% -x -d -o main_ui.py ui\main.ui
CALL %PYUIC4% -x -d -o document_ui.py ui\document.ui
CALL %PYUIC4% -x -d -o pnadata_ui.py ui\pnadata.ui

%PYRCC4% -o main_rc.py ui\main.qrc

@PAUSE
[/code]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SQLite or files?

2009-09-17 Thread ici
I like shelve for saving small amounts of data, user preferences,
recent files etc.
http://docs.python.org/library/shelve.html

For Qt use QtCore.QCoreApplication.setOrganizationName,
QtCore.QCoreApplication.setApplicationName than setValue, value from
QtCore.QSettings.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a pure Python chart drawing module

2009-09-15 Thread ici
On Sep 15, 8:25 pm, John Nagle na...@animats.com wrote:
 I'm looking for something that can draw simple bar and pie charts
 in Python.  I'm trying to find a Python package, not a wrapper for
 some C library, as this has to run on both Windows and Linux
 and version clashes are a problem.

 Here's the list from the Python wiki at
 http://wiki.python.org/moin/NumericAndScientific/Plotting;.
 Almost all the options are really wrappers for some other
 package in C/C++.

 * Matplotlib -- wrapper for Antigrain, written in C/C++
 * Veusz -- requires PyQt fromhttp://www.riverbankcomputing.co.uk/pyqt, which
 is in C/C++    
 * Chaco -- requires binaries for Enthought Tool Suite
 * ScientificPython - uses mix of C, C++, and FORTRAN.
 * Gnuplot module -- wrapper for GNUPLOT
 * plot_wrap - wrapper for GNU plotutils
 * BLT - tcltk.com link goes to a domain squatter site.
 * PyQT - wrapper for Qwt C++ library
 * DISLIN - interface to C++ DISLIN system
 * Mayavi - interface to Mayavai2, standalone program
 * gdmodule GD - python wrapper for the GD library.
 * Gist - wrapper for gist graphics library
 * pgplot - Wrapper for pgplot.
 * Py-OpenDX - wrapper for IBM Data Explorer
 * VTK - wrapper for VTK in C++
 * RPy - wrapper for R programming lnaguage
 * PyX - wrapper for Tex.
 * Biggles - wrapper for C++ module
 * Pychart - 100% Python, but last updated 21-Dec-2005.
 * PyNGL - uses PyNIO, which is in C
 * pygooglechart - Python interface to the Google Chart LookinAPI, only works 
 in
 browser

 So, for pure Python, Pychart is it.  I'll have to try it and see if it still
 works.

                                 John Nagle

My choice is PyQWT but few monts before I started pure python tkinter
cartesian plot control:
screenshot: http://www.iltchev.com/tkplot/tkplot.png
source: http://www.iltchev.com/tkplot/tkplot.py.txt

This class is in a very early stage, but I think it is good start. :)

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


Re: Application-global switches?

2009-09-04 Thread ici
On Sep 4, 9:29 pm, kj no.em...@please.post wrote:
 I'm looking for the best-practice way to define application-global
 read-only switches, settable from the command line.  The best
 example I can think of of such global switch is the built-in variable
 __debug__.  This variable is visible everywhere in a program, and
 broadly affects its operation.

 The situation that prompts this question is the task of implementing
 a certain application that is supposed to run for several days
 (typically 2-3 weeks).  It is important to be able to re-start this
 application where it left off in case that, for some reason (e.g.
 internet connection failure), it terminates prematurely.  When this
 application is restarted its behavior is somewhat different from
 when it is started from scratch.  (For example, when it is re-started,
 it does not clear certain directories.)

 Hence, I'd like to be able to have a variable, e.g. CONTINUATION_MODE,
 visible everywhere in the code, that tells the application to behave
 in continuation mode, so that I can write stuff like

     if not CONTINUATION_MODE:
         clean_the_slate()

 The only solution I can come up with is to define a dummy module,
 say _config.py, which contains only upper-case variables representing
 these global switches, and is imported by all the other modules in
 the application with the line from _config import *.  During the
 early stages of the run, the script inspects the command-line flags,
 and if it finds a --continuing flag, it sets the variable
 _config.CONTINUATION_MODE to True.  (The last point implies that
 these variables are not strictly speaking read-only, since they
 most be set at the beginning of the run.  But after this initial
 setting, they should remain read-only.)

 I'm sure this would work OK, but I wonder if there is a more Pythonic
 way to do this sort of thing.  Is there a best practice for setting
 such application-global switches?

 TIA!

 kynn

while 1:
  try:
run_main_code()
cleanup()
  except:
while conn_fail():
   time.sleep(5.0)
  finally:
cleanup_all()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python equivalent to PHP's SPL __autoload() ??

2008-04-27 Thread ici
On Apr 27, 10:34 pm, Ixiaus [EMAIL PROTECTED] wrote:
 I was curious (and have spent an enormous amount of time on Google
 trying to answer it for myself) if Python has anything remotely
 similar to PHP's SPL __autoload() for loading classes on the fly??

 After digging through docs I feel doubtful there is such a language
 feature, but, it is possible I missed something or maybe someone has
 written an extension?!?

 Thanks in advance!

from module_name include *
Can do the magic. You can't learn Python from helps or internet, got a
book. Learning Python: http://www.oreilly.com/catalog/lpython/ is a
very good start :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Floating Number format problem

2007-06-12 Thread ici
On Jun 12, 10:10 am, [EMAIL PROTECTED] wrote:
 How could I format the float number like this: (keep 2 digit
 precision)
 1.002 = 1
 1.12  = 1.12
 1.00  = 1
 1.567 = 1.57
 2324.012 = 2324.01

 I can not find any Formatting Operations is able to meet my
 requirement.
 Any suggestion will be appreciated.

 print %.02f % (2324.012)
2324.01


http://docs.python.org/tut/node9.html#SECTION00910

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


Re: Bootstrapping

2007-05-24 Thread ici
On May 24, 5:53 pm, Mauler [EMAIL PROTECTED] wrote:
 I need some help with adding bootstrap code to the core of python, the
 idea is to leave a super base core inside a zip file (python25.zip
 works right out of the box) and leave the rest in separate zip
 modules. Making it more friendly with pendrives and more practical as
 a standalone runtime (ie, without install) and fully modular. The
 thing is that i need to modify the base importer to add this special
 site-packages .
 Any hints?
 thanks in advance (and a lot!)

 Martin Rene Vilugron
 Patagonia Argentina

http://pyinstaller.python-hosting.com/ ?

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


Re: Compiling Python code within a module

2007-05-18 Thread ici
On May 19, 12:52 am, Mitko Haralanov [EMAIL PROTECTED] wrote:
 For various reason, what I need to do is be able to send some Python
 code (mostly entire functions in the form of a string) to a remote
 server (written in Python), have that server compile the code and
 insert it in the local namespace so it is available to be called at a
 later time.

 I have gotten the sending and receiving part already written and that
 works. However, I can't get the compiling part! I have looked at the
 compile module and while it is able to compile the code I am not
 entirely sure what to do with the returned code object so it get's
 inserted as a local function.

 I would appreciate any help that you guys might be able to offer?

 Thanks

 --
 Mitko Haralanov  [EMAIL PROTECTED]
 Senior Software Engineer 650.934.8064
 System Interconnect Group  http://www.qlogic.com

 ==
 The cutting edge is getting rather dull.
 -- Andy Purshottam

exec it :)

--- Example---
exec(compile(
def test():
import os
for i in os.listdir('.'):
print i
,'string', 'exec'))

test()
--- End example---
Now you have test() function available in namespace where executed
example

Po-zdravi

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


Re: c macros in python.

2007-05-06 Thread ici
On May 7, 12:01 am, [EMAIL PROTECTED] wrote:
 Hey,

 I'm writing a script to generate code. I'm a bit tired of typing
 outfile.write(). Does python have a way to c-like macros? Every
 instance of o(...) in the code will be replaced by outfile.write(...)?
All in Python is pointer to object, and functions too, so

o = outfile.write
o(Some Text)

You can redirect print to file also:

print  outfile, Text, var1, var2[2:]
or
o = outfile
print  o, Text, var1, var2[2:]
:)


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


Re: exporting a record from a database to a MS Word document.

2007-05-06 Thread ici

Levi Campbell wrote:
 Is there a way to export a record from a database kept with bsddb to
 MS Word, possibly with some type of formatting data?

import win32com.client

try: import psyco; psyco.full()
except ImportError: pass

app = win32com.client.Dispatch(Word.Application)
app.Visible = True
doc = app.Documents.Add()
para = doc.Paragraphs.Add()
para.Range.Text = DB Record
para.Range.Bold = True
#...
doc.Close(True)
app.Quit()

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


Re: exporting a record from a database to a MS Word document.

2007-05-06 Thread ici

Levi Campbell wrote:
 Is there a way to export a record from a database kept with bsddb to
 MS Word, possibly with some type of formatting data?

import win32com.client

try: import psyco; psyco.full()
except ImportError: pass

app = win32com.client.Dispatch(Word.Application)
app.Visible = True
doc = app.Documents.Add()
para = doc.Paragraphs.Add()
para.Range.Text = DB Record
para.Range.Bold = True
#...
doc.Close(True)
app.Quit()

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


Re: Did you read about that?

2007-05-06 Thread ici
On May 6, 8:55 pm, gene tani [EMAIL PROTECTED] wrote:
 On May 6, 6:26 am, Martin P. Hellwig [EMAIL PROTECTED] wrote:



  Dustan wrote:
   On May 6, 8:20 am, Steven D'Aprano
   [EMAIL PROTECTED] wrote:
   On Sun, 06 May 2007 04:53:23 -0700, Dustan wrote:
   SPAM!
   SPAM!
   SPAM!
   SPAM!
   SPAM!
   SPAM!
   SPAM!
   SPAM!
   Gosh, you think so? I'm glad we had you around to tell us, otherwise we
   might have thought it was about Python programming.

   Actually, many of us wouldn't even have seen it in the first place,
   because our ISPs do a good job of filtering out obvious spam before we
   even see it. And then people like you come along, and reply to it, and we
   see the reply -- complete with the original spam.

   Well, sorry. I didn't realize I'd get whacked around for making a
   joke.

   --
   Steven.

  Aren't jokes supposed to be funny?
  Sorry can't resist/

  --
  mph

 http://martinphellwig.blogspot.com/

 What you can do:

 complain to Google adsense about the site's advertising
 complain to Google groups about the post

 it would be #complete unethical# for me to suggest that OP posted an
 apparently unrelated topic because he wanted the site's performance
 ab tested, like, y'know

 ab -n 10 -kc 200http://yourspamsitehere.com

No way :( I did many times, ... RE: Google is not moderator bla, bla,
shits...

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


Re: adding methods at runtime and lambda

2007-05-03 Thread ici
On May 3, 10:52 pm, Mike [EMAIL PROTECTED] wrote:
 I was messing around with adding methods to a class instance at
 runtime and saw the usual code one finds online for this. All the
 examples I saw say, of course, to make sure that for your method that
 you have 'self' as the first parameter. I got to thinking and thought
 I have a lot of arbitrary methods in several utility files that I
 might like to add to things. How would I do that? And this is what I
 came up with:

 def AddMethod(currObject, method, name = None):
 if name is None: name = method.func_name
 class newclass(currObject.__class__):pass
 setattr(newclass, name, method)
 return newclass()

 And lets say I have a utility function that can check if a drive
 exists on my windows box called HasDrive. I can add that like this:

 superdict = addm(dict(), lambda self, d: myUtils.HasDrive(d),
 hasdrive)

 and then I can call

 superdict.HasDrive('c')

 lambda makes it possible to add any random function because you can
 use it to set self as the first parameter. I've found several real
 uses for this already. My big question is, will something like this be
 possible in python 3000 if lambda really does go away? I've not heard
 much about lambda, reduce, etc. lately but I know Guido wanted them
 out of the language.

 Is there a better way to do this today than to use lambda? It seemed
 the simplest way to do this that I could find.

from win32com.client import Dispatch as CreateObject

class HDDs(list):
def __init__(self):
fso = CreateObject('Scripting.FileSystemObject')
for d in fso.Drives:
if d.DriveType == 2: # Fixed
list.append(self, d.DriveLetter)

if __name__ == __main__:
drv_list = HDDs()
for d in drv_list:
print d

try:
# Found
print drv_list.index('P')
except ValueError:
# Not Found
print P: Not Exists!

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


Re: win32com.client Excel Color Porblem

2007-05-02 Thread ici
On May 3, 1:37 am, Ray [EMAIL PROTECTED] wrote:
 Hi,

 I need to use cell's background color.

 when I record a macro from excel, it shows:

 Rows(7:7).Select
  With Selection.Interior
  .ColorIndex = 8
  .Pattern = xlSolid

 how do I run it from python win32com ?
 xlApp.ActiveSheet.Rows(7:7).ColorIndex won't work.

 Thanks for any Help.

 Ray

 PS: where or how to find a win32com reference?

My Excel Template :) + Rows

# -*- encoding:utf-8 -*-
import win32com.client

try: import psyco; psyco.full()
except ImportError: pass

try:
app = win32com.client.Dispatch(Excel.Application.11) # Excel
2003
except com_error:
try:
app = win32com.client.Dispatch(Excel.Application.10) # Excel
XP
except com_error:
try:
app = win32com.client.Dispatch(Excel.Application.9) #
Excel 2000
except com_error:
try:
app = win32com.client.Dispatch(Excel.Application.8)
# Excel 97
except com_error:
app = win32com.client.Dispatch(Excel.Application) #
Excel 5.0?
# Or raise No Office ...

app.Visible = True
wbk = app.Workbooks.Add()
app.DisplayAlerts = False
while wbk.Worksheets.Count  1:
wbk.Worksheets[0].Delete()
wbk.Worksheets[0].Name = SHIT
sht = wbk.Worksheets[0] # Containers starts with 0!
sht.Name += $

# Rows
rng = sht.Rows(7)
rng.Interior.ColorIndex = 6
sht.Rows(8).Interior.ColorIndex = 8
# Rows End

app.DisplayAlerts = True
wbk.SaveAs(rc:\temp\test.xls)
app.Quit()

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


Re: newbie: HTTPS screen scraping

2007-04-21 Thread ici
On Apr 21, 11:38 am, [EMAIL PROTECTED] wrote:
 Hi,
 Can anyone help me out here. I would like to authenticate myself to
 a website which uses HTTPS and then after authentication, I would like
 to get the contents of the webpage. How can this be done using python.
 I have tried urllib and urllib2 but it has not solved my problem.

 TIA
 /varun

http://pycurl.sourceforge.net/

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


Re: moving multiple directories

2007-04-16 Thread ici
On Apr 16, 9:36 pm, Larry Bates [EMAIL PROTECTED] wrote:
 DataSmash wrote:
  Hi,
  I need to organize thousands of directories full of files.
  I want to move these directories into other subdirectories.
  For example, all the directories that start with 01, move to
  a directory named one, all directories that start with 02, move
  to a directory name two, and so on

  I can't seem to find any easy way to do this.
  Looks like shutil.move only lets you move if the subdirectory DOES
  NOT exist, so after the first directory moves, the script blows up on
  the second move.
  I guess you could use shutil.copy or shutil.copytree but then you have
  to
  delete as well.  Much longer process when you have hundreds of
  gigabytes of data.

  Thanks for your help!
  R.D.

 Use win32.moveFile method instead.  This links directly to the Windows
 MoveFile method that just moves the directory entries around.

 From Win32 Documentation:

 win32api.MoveFile
 MoveFile(srcName, destName)

 Renames a file, or a directory (including its children).

 Parameters

 srcName : string

 The name of the source file.

 destName : string

 The name of the destination file.

 Comments
 This method can not move files across volumes.

 -Larry

Instead win32api, use native shutil module

import shutil
shutil.move(src,dest)

Recursively move a file or directory to another location.

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


Re: Python Feature Request: Allow changing base of member indices to 1

2007-04-14 Thread ici
On Apr 14, 1:27 pm, [EMAIL PROTECTED] wrote:
...
 This would mean:
 foo = foo
 = foo[1] == 'f'


class Str1(str):
def __getitem__(self,i):
return str.__getitem__(self,i-1)

s1 = Str1(foo)
print s1[1]

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


Re: a better solution for GUI in python

2007-03-11 Thread ici
On Mar 11, 1:03 pm, ce [EMAIL PROTECTED] wrote:
 Hi,

 My company is using python currently for our website. We need to
 develop a GUI front-end for our ERP that would be portable (Windows
 and Linux).

 My question is which solution would be better for the GUI (and easier
 to implement)? I knew there are something like wxidgets, QT and pyGTK?
 actually we will need some complicated stuff in the GUI and yet I
 don't know much about GUI programming.

 Any recommendation guys?

http://pythoncard.sourceforge.net/ - Debugger, visual editor(resource
editor) , one place event handlers like on_Object_Command, uses
wxPython but easy than VB.

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


Re: Creating a DLL file from Python Code

2007-03-09 Thread ici
On Mar 9, 2:08 pm, [EMAIL PROTECTED] wrote:
 Hi,

 I would like to request your attention for this very specific issue:

 I have several classes in Python, and now I want simply re-use it, in
 other language.

 The closest to solution I think I came was with this 
 site:http://www.py2exe.org/index.cgi/Py2exeAndCtypesComDllServer
 but I not able to solve questions related with TLB files and
 __init__.py files.

 So, could anyone give a tip about how to creat a dll file from Python?
 It is possible under any conditions?

 thank in advance

 macedo

Best way: http://www.python.org/doc/ext/embedding.html , than use your
modules as py files or string constants.

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