Having trouble with Mock and exception side effects

2020-08-21 Thread Joshua J. Kugler
Hello!  I am using Mock to raise an exception in an function as a side effect. 
However, Mock is completely redefining the exception itself turning it in to a 
MagickMock object, which generates the Python exception

TypeError: catching classes that do not inherit from BaseException is not 
allowed

This is my minimal reproducible test case.

# test_case.py
#!/usr/bin/python3

from unittest.mock import patch

import package.module

print('Before patcher start:', package.module.MyException)

patcher = patch('package.module')
mock_hvac = patcher.start()

print('After patcher start:', package.module.MyException)

try:
print('Right before raise:', package.module.MyException)
raise package.module.MyException

except package.module.MyException:
print('Got the exception')

package/__init__.py
# Empty

package/module.py
class MyException(BaseException):
pass

Output:
$ python3.6 --version
Python 3.6.9
$ python3.6 test_case.py
Before patcher start: 
After patcher start: 
Right before raise: 
Traceback (most recent call last):
  File "test_case.py", line 21, in 
raise package.module.MyException
TypeError: exceptions must derive from BaseException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_case.py", line 23, in 
except package.module.MyException:
TypeError: catching classes that do not inherit from BaseException is not 
allowed

This is also causing problems for Mock side effects. In this line of code in 
mock.py (line 997 for me):

if effect is not None:
if _is_exception(effect):
raise effect

The _is_exception() function checks for an exception via:

return (
isinstance(obj, BaseExceptions) or
isinstance(obj, type) and issubclass(obj, BaseExceptions)
)

Which of course is false, because it's been replaced by a MagicMock object, so 
exception side effects aren't properly raised.

According to https://docs.python.org/3.6/library/unittest.mock.html#calling 
calling a function after setting the side_effect should raise the Exception, 
not a MagicMock object.

https://docs.python.org/3.6/library/unittest.mock.html#unittest.mock.Mock also 
says "Alternatively side_effect can be an exception class or instance. In this 
case the exception will be raised when the mock is called."

So, this seems to be not behaving as design, or at least not as documented. 
This is creating some really serious problems for testing our code, as we want 
a function to have a side effect of an Exception, and catch that exception, but 
we can do neither when it has been replaced by a MagicMock object.

Thanks for any tips, pointers, or "You're doing it wrong!" education. :)

j


-- 
Joshua J. Kugler - Fairbanks, Alaska - jos...@azariah.com
Azariah Enterprises - Programming and Website Design
PGP Key: http://pgp.mit.edu/  ID 0x68108cbb73b13b6a


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


Re: compile error building building Python-3.8.5 on Debian 8.11 (yes, old!)

2020-09-04 Thread Joshua J. Kugler
On Thursday, September 3, 2020 8:59:09 PM AKDT Cameron Simpson wrote:
> I've built 3.8.5 on a few other machines happily recently.
> 
> Building Python 3.8.5, running make and gcc (Debian 4.9.2-10+deb8u2)
> 4.9.2 I get this:

I am going to assume the version of C required is past what is in that old of 
a version of Debian. I don't see anything that calls out the C version 
required in the Python docs, but I doubt they have Debian 8 in their build 
farm any more.

j

-- 
Joshua J. Kugler - Fairbanks, Alaska - jos...@azariah.com
Azariah Enterprises - Programming and Website Design
PGP Key: http://pgp.mit.edu/  ID 0x68108cbb73b13b6a


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


Doing date/time + TZ math in python

2007-01-05 Thread Joshua J. Kugler
I've read docs (datetime, time, pytz, mx.DateTime), googled, and
experimented.  I still don't know how to accomplish what I want to
accomplish.

I'm loading up a bunch of date/time data that I then need to do math on to
compare it to the current date/time.  I can get the current time easily
enough:

currentTime = datetime.datetime.now(pytz.timezone('America/Anchorage'))

Then, I want to import data/time pairs that are in "%Y-%m-%d %H:%M:%S"
format.

So, I do:

For each loop, extract time data, blah, blah, then:
readingTime = datetime.datetime(rYr, rMo, rDay, rHr, rMin, rSec,
tzinfo=pytz.timezone('America/Anchorage'))

The problem is, how do I create a datetime object and tell it that it's
America/Anchorage *daylight savings time* instead of whatever the system is
currently set at?  pytz only has America/Anchorage, and I saw no way to
tell it explicitly that the timezone is in Daylight instead of Standard
time (e.g. using AKST vs. AKDT for the time zone).

I'm sure there is a way to do it, and I'm sure it's quite simple, but it
hasn't jumped out at me yet.  Is there a module that I haven't seen that
would be better suited for this?

Thanks!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Python plain-text database or library that supports joins?

2007-06-26 Thread Joshua J. Kugler
On Friday 22 June 2007 09:18, felciano wrote:

> Hello --
> 
> Is there a convention, library or Pythonic idiom for performing
> lightweight relational operations on flatfiles? I frequently find
> myself writing code to do simple SQL-like operations between flat
> files, such as appending columns from one file to another, linked
> through a common id. For example, take a list of addresses and append
> a 'district' field by looking up a congressional district from a
> second file that maps zip codes to districts.

Two pointers, but maybe not a complete solution:

http://search.cpan.org/dist/DBD-Sprite/
Perl library that uses CSV files and supports simple joins.  Maybe a port of
this?

http://www.biostat.wisc.edu/~annis/creations/pseudb.html
Functional interface for CSV files inspired by Sprite, but does not support
joins.  Possibly could be extended?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Dedicated CPU core for Python?

2007-04-26 Thread Joshua J. Kugler
On Thursday 26 April 2007 09:16, Louise Hoffman wrote:

> Dear readers,
> 
> I was wondering, if Python in the foerseeable future will allocate one
> CPU core just for the interpreter, so heavy Python operations does
> slow down the OS?
> 
> It seams to me like a perfect use for a CPU core =)

Are you talking about CPU affinity
(http://en.wikipedia.org/wiki/Processor_affinity) or an actual CPU that can
directory execute Python byte code?  If the former, CPython only uses one
CPU core right now because it's threads are all internal, and do not spawn
system threads (IIRC).  If the latter, I don't think that would work very
well because then, e.g., C extensions wouldn't work very well as they could
not be executed by a Python Byte-code CPU.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Dedicated CPU core for Python?

2007-04-27 Thread Joshua J. Kugler
On Thursday 26 April 2007 14:07, Gabriel Genellina wrote:

> En Thu, 26 Apr 2007 15:54:38 -0300, Joshua J. Kugler
> <[EMAIL PROTECTED]> escribió:
> 
>> Are you talking about CPU affinity
>> (http://en.wikipedia.org/wiki/Processor_affinity) or an actual CPU that
>> can directory execute Python byte code?  If the former, CPython only
>> uses one
>> CPU core right now because it's threads are all internal, and do not
>> spawn system threads (IIRC).
> 
> Python threads are OS threads:
> http://docs.python.org/lib/module-thread.html
> "[The thread module] is supported on Windows, Linux, SGI IRIX, Solaris
> 2.x, as well as on systems that have a POSIX thread (a.k.a. ``pthread'')
> implementation."

Yes, that may be, but they are not true system threads, or at least do not
appear to be.  Threads on linux each show up as a separate process.  I can
have several threads in my Python program, but no additional processes show
up in ps -A.  I don't see how Python threads can be system threads with the
GIL.  But, I've been wrong before, and threads are something I have very
light knowledge of.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Interop between C# and Python

2007-04-30 Thread Joshua J. Kugler
On Friday 27 April 2007 17:09, urielka wrote:

> i need a easy way to write a Python Service(be it SOAP or JSONRPC or
> whatever) but i need to easily access it from C#,i created a web
> service in ZSI(which is really easy) like this:

You might want to take a look at Thrift too:
http://developers.facebook.com/thrift/

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: I wish that [].append(x) returned [x]

2007-05-02 Thread Joshua J. Kugler
On Wednesday 02 May 2007 12:05, Tobiah wrote:

> 
>> In addition to the above good advice, in case you are submitting a query
>> to a DB-API compliant SQL database, you should use query parameters
>> instead of building the query with string substitution.
> 
> I tried that a long time ago, but I guess I found it to be
> more awkward.  I imagine that it is quite a bit faster that way?
> I'm using MySQLdb.

The issue is not speed, it's security.  Query parameters are automatically
escaped to prevent SQL injection attacks.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: 32 OS on 64-bit machine

2007-05-03 Thread Joshua J. Kugler
On Thursday 03 May 2007 01:10, SamG wrote:

> If anyone has a x86_64 machine and is running a 32bit OS on top of
> that could you tell me what output would you get for the following
> program
> 
> #==
> import platform
> print platform.processor()
> print platform.architecture()
> #==
> 
> Thanks in advance
> : )~

>>> import platform
>>> print platform.processor()

>>> print platform.architecture()
('32bit', '')
>>>

$ cat /proc/cpuinfo
processor   : 0
vendor_id   : AuthenticAMD
cpu family  : 15
model   : 44
model name  : AMD Sempron(tm) Processor 3100+


$ uname -a
Linux djibouti 2.6.15-28-k7 #1 SMP PREEMPT Thu Feb 1 16:36:09 UTC 2007 i686
GNU/Linux



-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Replacement for HTMLGen?

2007-05-03 Thread Joshua J. Kugler
I realize that in today's MVC-everything world, the mere mention of
generating HTML in the script is near heresy, but for now, it's what I ened
to do. :)

That said, can someone recommend a good replacement for HTMLGen?  I've found
good words about it (http://www.linuxjournal.com/article/2986), but every
reference to it I find points to a non-existant page
(http://starship.python.net/lib.html is 404,
http://www.python2.net/lib.html is not responding,
http://starship.python.net/crew/friedrich/HTMLgen/html/main.html is 404)
Found http://www.python.org/ftp/python/contrib-09-Dec-1999/Network/, but
that seems a bit old.

I found http://dustman.net/andy/python/HyperText, but it's not listed in
Cheeseshop, and its latest release is over seven years ago.  Granted, I
know HTML doesn't change (much) but it's at least nice to know something
you're going to be using is maintained.

Any suggestions or pointers?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

ANN: vuLookup.py, a TCP lookup server for Postfix

2007-05-08 Thread Joshua J. Kugler
We needed it, so we wrote it.

Announcing vuLookup.py 1.0

vuLookup.py is a TCP lookup table server for Postfix, written in Python. It 
reads an ini file and uses the values therein to answer requests for virtual 
users, as well as virtual domains.

You can download it here: http://www.eeinternet.com/opensource.html

No warranties are made, but this code has been in production for several
weeks 
now, so is known to perform its assigned duties.

Comments, questions, critiques welcome!

From a comment on a mailing list:

> I think you should explain the value if this. the basic thing is the
> value compared to a hash map. but depending on how it works, comparison
> with mysql/ldap may be good too.

The main motivation for this was less overhead vs. a database or ldap
solution.  The INI file is very simple, and it is easy for even
non-technical users to understand.  Changes made to the ini file are seen
at the reload interval, no postmap (as root) command required if the ini
file is in a group that has edit permissions.  We are a small shop (about
10 clients, maybe 80 e-mail accounts) and a database or ldap solution would
have been too much work, especially if we went and made an interface for
editing the aliases.

Also, since we are using dspam, we wanted to "resolve" all the aliases
before the messages were sent to dspam (we're using postfix -> dspam ->
postfix) and since the virtualusertable didn't take file arguments for
expansion, it wasn't going to work to put all the entries directly in the
virtualusertable map.  I this system, we've moved pretty much everything
(even stuff that used to be in the "aliases" file) into the
virtualusertable.ini file.

Hope that answers some questions.  If you have any more, feel free to ask!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

ANN: A login wrapper for DSPAM

2007-05-08 Thread Joshua J. Kugler
I wanted it: 

http://www.mail-archive.com/dspam-users%40lists.nuclearelephant.com/msg00264.html

So I wrote it.

Annoucning DspamFrontend 1.0

DSPAM Frontend is a script written in Python designed to provide login
facilities for DSPAM when HTTP basic auth is either undesireable or
unavailable. dspamFrontend.py, along with some helper suid scripts, handles
the authentication of the user (using an IMAP server), along with the
invocation of the dspam scripts

You can download it here: http://www.eeinternet.com/opensource.html

No warranties are made, but this code has been in production for several
weeks now, so is known to perform its assigned duties.

Comments, questions, critiques welcome!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: How to do basic CRUD apps with Python

2007-05-16 Thread Joshua J. Kugler
On Sunday 13 May 2007 15:20, walterbyrd wrote:

> With PHP, libraries, apps, etc. to do basic CRUD are everywhere. Ajax
> and non-Ajax solutions abound.
> 
> With Python, finding such library, or apps. seems to be much more
> difficult to find.
> 
> I thought django might be a good way, but I can not seem to get an
> answer on that board.
> 
> I would like to put together a CRUD grid with editable/deletable/
> addable fields, click on the headers to sort. Something that would
> sort-of looks like an online  spreadsheet. It would be nice if the
> fields could be edited in-line, but it's not entirely necessary.
> 
> Are there any Python libraries to do that sort of thing? Can it be
> done with django or cherrypy?
> 
> Please, don't advertise your PHP/Ajax apps.

Turbogears has catwalk, which is already an interface to a database, but
there is a CRUD template for TG:
http://docs.turbogears.org/1.0/CRUDTemplate

Might be what you're looking for.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: How to do basic CRUD apps with Python

2007-05-16 Thread Joshua J. Kugler
On Monday 14 May 2007 18:46, James T. Dennis wrote:
>  I'm thinking of some sort of class/module that would generate
>  various sorts of HTML forms by default, but also allow one to
>  sub-class each of the form/query types to customize the contents.

Turbogears has catwalk, which is already an interface to a database, but
there is a CRUD template for TG:
http://docs.turbogears.org/1.0/CRUDTemplate

Might be what you're looking for.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: How to do basic CRUD apps with Python

2007-05-16 Thread Joshua J. Kugler
Sorry about the duplicate post!  My news reader never showed my first reply!

j

-- 
Posted via a free Usenet account from http://www.teranews.com

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


Re: pyhdf

2007-05-18 Thread Joshua J. Kugler
On Wednesday 16 May 2007 09:36, [EMAIL PROTECTED] wrote:

> Has anyone had success installing the pyhdf library with python 2.4
> under linux 2.6.18 (debian)? I have installed the HDF library and
> development package from apt and have downloaded the pyhdf
> installation files.

I've had success with PyTables, which is a wrapper for HDF5.  Or are we not
talking about the same HDF? :)

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: model browser

2007-05-21 Thread Joshua J. Kugler
On Sunday 20 May 2007 10:55, Daniel Nogradi wrote:
> Are there other options I overlooked?
> 
> Daniel

There is a CRUD template for TG:
http://docs.turbogears.org/1.0/CRUDTemplate

Might be what you're looking for.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Module imports fine from interactive, not from script

2007-05-24 Thread Joshua J. Kugler
Yes, I've read this:
http://mail.python.org/pipermail/python-list/2006-August/395943.html
That's not my problem.

I installed PlanetPlanet  via the
package's "setup.py install" command (as root).  planet.py will not run,
however, giving me this error:

Traceback (most recent call last):
  File "/usr/local/bin/planet.py", line 167, in ?
main()
  File "/usr/local/bin/planet.py", line 124, in main
planet.logging.basicConfig()
AttributeError: 'module' object has no attribute 'logging'

But, from interactive session:

[EMAIL PROTECTED]:~/www$ ls -l # to show that the modules are not in the
current dir
total 20
-rw-r--r-- 1 jkugler jkugler 2247 2007-05-22 15:26 atom.xml.tmpl
-rw-r--r-- 1 jkugler jkugler 2089 2007-05-22 15:25 index.html.tmpl
-rw-r--r-- 1 jkugler jkugler  564 2007-05-22 15:43 planet.ini
-rw-r--r-- 1 jkugler jkugler 1128 2007-05-22 15:26 rss10.xml.tmpl
-rw-r--r-- 1 jkugler jkugler  838 2007-05-22 15:26 rss20.xml.tmpl
[EMAIL PROTECTED]:~/www$ python
Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import planet
>>> planet.logging

>>> planet.logging.basicConfig()
>>>

The contents of /usr/local/lib/python2.4/site-packages/planet
[EMAIL PROTECTED]:~/www$ ls -la /usr/local/lib/python2.4/site-packages/planet/
total 270
drwxr-sr-x 4 root staff   1024 2007-05-22 16:59 .
drwxrwsr-x 4 root staff   1024 2007-05-22 15:18 ..
-rw-r--r-- 1 root staff   4315 2006-07-26 15:53 atomstyler.py
-rw-r--r-- 1 root staff   8887 2006-07-26 15:53 cache.py
-rw-r--r-- 1 root staff 126446 2006-07-26 15:53 feedparser.py
-rw-r--r-- 1 root staff  58705 2006-07-26 15:53 htmltmpl.py
-rw-r--r-- 1 root staff  38145 2006-07-26 15:53 __init__.py
drwxr-xr-x 2 root staff   1024 2007-05-22 16:59 logging
-rw-r--r-- 1 root staff  13904 2006-07-26 15:53 sanitize.py
drwxr-xr-x 2 root staff   1024 2007-05-22 16:59 tests
-rw-r--r-- 1 root staff  12681 2006-07-26 15:53 timeoutsocket.py

planet.py is simply executing:

import planet
.
.
.
# Activate logging
planet.logging.basicConfig()


I've checked permissions, I've checked import statements, everything I know
to check.  Is there something terribly simple I'm missing?

Thanks!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Module imports fine from interactive, not from script

2007-05-24 Thread Joshua J. Kugler
On Thursday 24 May 2007 08:32, Steve Holden wrote:
> The directory containing the script you are executing is also added to
> sys.path. Since you are executing a script called planet ...

Ah!  That's it. That had never occurred to me, as I was under the impression
that your current *working* directory was added to sys.path, not the
directory of the script.

Thanks!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Reading a Directory of Emails - Problems

2007-07-24 Thread Joshua J. Kugler
On Tuesday 24 July 2007 09:38, Ryan Rosario wrote:

> Hi,
> 
> I have a directory that contains a bunch of email messages and I would
> like to parse them using the email and mailbox packages. The emails were
> exported from Apple Mail. From what I gather, I need to use MHMailbox, but
> I can't get it to do anything useful and I cannot find any examples of how
> to use this particular mailbox type.
> 
> mbox =
> mailbox.MHMailbox('stat_inbox.mbox/Messages',email.message_from_file) for
> msg in mbox:
> print msg.keys()  #just to see if anything is happening
> 
> I get an error. AttributeError: MHMailbox instance has no attribute
> 'keys'. Yet this works when using PortableUnixMailbox (on an mbox file,
> not a directory of emails).

I fought with this a while back.  It seems it is nested one level lower. 
You might have to get at the message by doing something like

real_message = msg[0]

Instead of print msg.keys(), just do a 'print msg' and see what data
structure is returned.  That will tell you a lot.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-01 Thread Joshua J. Kugler
On Wednesday 01 August 2007 13:28, John K Masters wrote:

> On 15:34 Tue 31 Jul , Wingware wrote:
>> Hi,
>> 
>> I'm happy to announce the first beta release of Wing IDE 3.0.  It is
>> available from http://wingware.com/wingide/beta
> If their support for paid customers is anything like their support for
> prospective customers then I would leave well alone.

I've had excellent support from them.  I'm sorry to hear your experiences
have not been stellar.  Questions submitted to the bug or comment list
usually get a response in one day or less.  And there are frequently
respones by WingWare people to just about every question asked on the
WingWare mailing list.

> I have been trying wing for a few days but have noticed that
> auto-completion does not work on all modules. I submitted this to wing
> and was told that probably my PYTHONPATH was wrong.

It may also not work if the IDE isn't sure what kind of object you are
dealing with.  You can "clarify" this as documented with an
assert(isinstance()) statement.

> I subsequently submitted a question about the licensing, i.e. whether I
> could use wing on a home setup using Debian Etch, where I develop my
> apps, and a work setup, using Debian Etch, with no net access.

From http://www.wingware.com/wingide/license:

"Each Wing IDE user may run Wing on as many machines as needed for their own
work, for all the operating systems which they have licensed. In order to
reduce casual license sharing, which is a unfortunately a problem for small
businesses like Wingware, licenses must be activated after installation on
each machine."

"We've worked hard to make this flexible and forgiving for valid customers.
For example, reinstalling an OS and/or altering hardware usually should not
break your activation. Also, activation can be done directly from Wing IDE
and off-line activation is available if your machine does not have TCP port
80 (http) access to wingware.com. Each license is allowed three activations
by default and more can be obtained on request from identifiable
customers."

> So far I have had no response

I tend to let questions slide when they are answered in the documentation or
on the web site.  Maybe the Wing developers/support personnel are the same
way.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Bug in Time module, or in my understanding?

2007-08-01 Thread Joshua J. Kugler
I am getting results like these with the time module:

>>> import time
>>> int(time.mktime(time.strptime('2007-03-11 02:00:00', '%Y-%m-%d %H:%M
%S')))
1173610800
>>> int(time.mktime(time.strptime('2007-03-11 03:00:00', '%Y-%m-%d %H:%M
%S')))
1173610800
>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173610800))
'2007-03-11 03:00:00'

I know it probably has something to do with daylight savings, but how can I
get back out that which I put in?  The times concerned are all standard
time, so how can I keep the time module from asserting its belief that I
want to convert to daylight savings?

Incidentally, it only happens with times on 2007-03-11  from 02:00:00 to
02:59:59, and not with time data from past years.

Thanks for any pointers!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-01 Thread Joshua J. Kugler
On Wednesday 01 August 2007 13:53, Robert Dailey wrote:
> He's secretly an employee of Wing IDE in disguise!!!

Sorry to destroy your conspiracy theories, but no, I've never been employed
by Wing IDE in any fashion, nor have I ever received any monetary
compensation from them in any form.  Just a satisfied user.  That's all.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Wing IDE for Python v. 3.0 beta1 released

2007-08-01 Thread Joshua J. Kugler
On Wednesday 01 August 2007 14:15, John K Masters wrote:
>> > I have been trying wing for a few days but have noticed that
>> > auto-completion does not work on all modules. I submitted this to wing
>> > and was told that probably my PYTHONPATH was wrong.
>> It may also not work if the IDE isn't sure what kind of object you are
>> dealing with.  You can "clarify" this as documented with an
>> assert(isinstance()) statement.
> But as I pointed out to the wingware people the autocompletion was
> recognising some methods but not others from the same module,

I just remembered: I've been around the block with them on this one too.  It
was with PyTables.  There are some modules (PyTables includes) that use
certain names that are valid when called, but are no where defined in the
module.  Yes, it happens, and yes, it sounds quite tweaky.  I can dig up
details if you want me to.  But, since the names are defined, basically, at
run time, there is no way Wing can find them for autocompletion.

>> > I subsequently submitted a question about the licensing, i.e. whether I
>> > could use wing on a home setup using Debian Etch, where I develop my
>> > apps, and a work setup, using Debian Etch, with no net access.
>> 
>> From http://www.wingware.com/wingide/license:
>> 
>> "Each Wing IDE user may run Wing on as many machines as needed for their
>> own work, for all the operating systems which they have licensed. In
>> order to reduce casual license sharing, which is a unfortunately a
>> problem for small businesses like Wingware, licenses must be activated
>> after installation on each machine."
>> 
>> "We've worked hard to make this flexible and forgiving for valid
>> customers. For example, reinstalling an OS and/or altering hardware
>> usually should not break your activation. Also, activation can be done
>> directly from Wing IDE and off-line activation is available if your
>> machine does not have TCP port 80 (http) access to wingware.com. Each
>> license is allowed three activations by default and more can be obtained
>> on request from identifiable customers."
>> 
> 
> But this requires activation via a web connection.

It does? "off-line activation is available if your machine does not have TCP
port 80 (http) access to wingware.com."  What part still requires web
access?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Bug in Time module, or in my understanding?

2007-08-01 Thread Joshua J. Kugler
On Wednesday 01 August 2007 14:49, Jay Loden wrote:
> Hope some of this helps

It did, thanks!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Is shelve/dbm supposed to be this inefficient?

2007-08-01 Thread Joshua J. Kugler
I am using shelve to store some data since it is probably the best solution
to my "data formats, number of columns, etc can change at any time"
problem.  However, I seem to be dealing with bloat.

My original data is 33MB.  When each row is converted to python lists, and
inserted into a shelve DB, it balloons to 69MB.  Now, there is some
additional data in there namely a list of all the keys containing data (vs.
the keys that contain version/file/config information), BUT if I copy all
the data over to a dict and dump the dict to a file using cPickle, that
file is only 49MB.  I'm using pickle protocol 2 in both cases.

Is this expected? Is there really that much overhead to using shelve and dbm
files?  Are there any similar solutions that are more space efficient?  I'd
use straight pickle.dump, but loading requires pulling the entire thing
into memory, and I don't want to have to do that every time.

[Note, for those that might suggest a standard DB.  Yes, I'd like to use a
regular DB, but I have a domain where the number of data points in a sample
may change at any time, so a timestamp-keyed dict is arguably the best
solution, thus my use of shelve.]

Thanks for any pointers.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Bug in Time module, or in my understanding?

2007-08-01 Thread Joshua J. Kugler
On Wednesday 01 August 2007 14:45, Paul Boddie wrote:
> Well, I think that if you inspect the result of strptime, you'll see
> that the last element of the time "tuple" - in fact, the tm_isdst
> member of a time "structure" - is set to -1:
> 
 time.strptime('2007-03-11 02:00:00', '%Y-%m-%d %H:%M:%S')
> (2007, 3, 11, 2, 0, 0, 6, 70, -1)
 time.strptime('2007-03-11 03:00:00', '%Y-%m-%d %H:%M:%S')
> (2007, 3, 11, 3, 0, 0, 6, 70, -1)
> 
> What is likely to happen when such results are passed to mktime is
> that the underlying library function will use its discretion in
> determining whether daylight savings time is in operation or not.

That sounds about right.

> By asserting tm_isdst as being 0, the usual apparent interval between
> the times is preserved.

I'll do that.  This isn't so much about DST vs. non-DST (as I may be putting
values in here that were recorded during DST), but in this case it was just
trying to get the same value out that I had put in.

Thanks for the pointers!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Is shelve/dbm supposed to be this inefficient?

2007-08-01 Thread Joshua J. Kugler
On Wednesday 01 August 2007 16:08, Thomas Jollans wrote:
> Have you considered a directory full of pickle files ? (In effect,
> replacing the dbm with the file system) i.e. something like (untested)
> 
> class DirShelf(dict):


A very interesting idea.  I'll have to see how that plays out
performance-wise.  Thanks for the idea, and the roughed-out code!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Bug in time, part 2

2007-08-02 Thread Joshua J. Kugler
Or could I entitle this, "A Wrinkle in time.py," with apologies to Madeleine
L'Engle.  Either I've found a bug (or rather room for improvement) in
time.py, or I *really* need a time module that doesn't assume so much.

After the suggestions to try setting the dst flag to zero, I did some more
experimentation, and here is what I came up with:

>>> import os
>>> import time
>>> os.environ['TZ'] = 'GMT'
>>> time.tzset()
>>> time.tzname
('GMT', 'GMT')
>>> time.mktime((2007, 3, 11, 2, 30, 0, 6, 70, 0))
1173580200.0
>>> time.mktime((2007, 3, 11, 3, 30, 0, 6, 70, 0))
1173583800.0

OK, so far I'm seeing a one hour difference.

>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173580200.0))
'2007-03-11 02:30:00'
>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173583800.0))
'2007-03-11 03:30:00'

Yay! it works!  But, let's do this:

>>> import time
>>> time.tzname
('AKST', 'AKDT')
>>> int(time.mktime(time.strptime('2007-03-11 2:30:00','%Y-%m-%d %H:%M:%S'
[0:8] + (0,)))
1173612600
>>> int(time.mktime(time.strptime('2007-03-11 3:30:00','%Y-%m-%d %H:%M:%S'
[0:8] + (0,)))
1173616200
>>>

OK, that looks good, a one hour difference, and I told it not to figure in
dst (the last 0). BUT:

>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173612600)[0:8] +
(0,))
'2007-03-11 03:30:00'
>>> time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1173616200)[0:8] +
(0,))
'2007-03-11 04:30:00'

So, apparently localtime assumes DST (since we're in DST right now) and
there is no way to tell it the unixtime given to it was calculated under
the assumption of no daylight savings.  And would this particular test case
work if I told it to use DST?  Yes, but then I'd have several hundred other
test cases failing.  I think localtime needs to have a parameter to tell it
not to assume DST, even if DST would normally be active in that date range.

So, at any rate, my fix/workaround is to manually set time.py to use UTC to
convert to and from, and then deal with the times I have from there.  All I
wanted to do was convert an 18 or 19 byte character string (ISO date/time)
to a four byte character string (key in a dict, can't use ints in a shelve
db), and I end up spending HOURS trying to figure out 1) why I was getting
duplicate keys, then 2) why mktime was generating duplicate unix times, and
finally 3) why localtime wasn't converting back correctly.  Sigh.  Some
days I hate DST. :)

Thanks to all for the pointers and help.

In other news, setting time.tzname = ('GMT', 'GMT') does nothing.  You have
to set the environment variable, then call tzset.  Is there a rational for
this?  Seems odd.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: (no) fast boolean evaluation ?

2007-08-02 Thread Joshua J. Kugler
On Thursday 02 August 2007 15:19, Evan Klitzke wrote:
>> I discovered that boolean evaluation in Python is done "fast"
>> (as soon as the condition is ok, the rest of the expression is ignored).
> 
> This is standard behavior in every language I've ever encountered.

Then you've never programmed in VB (at least 6, don't know if .net still
does this).  Nested IF statements. CK!  Thankfully, I
program mostly in Python these days.  Haven't touched VB in years.  Maybe
you should have said:

"This is standard behavior in every real programming language."

There, that should start a flame war. :)

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Why does SocketServer default allow_reuse_address = false?

2007-03-07 Thread Joshua J. Kugler
Greg Copeland wrote:
>> Is there some history to this of which I'm not aware?  Is there a good
>> reason for it to default to false?

> Long story short, it is not a bug.  It is a feature.  The proper
> default is that of the OS, which is to ensure SO_REUSEADDR is disabled
> unless you absoluetely understand what you're buying by enabling it.

Thanks for your reply.  Those are all point of which I had not been aware.

My problem (and the reason I set reuse to True) is this: if I have
connections active when I restart my service, upon restart, the socket will
fail to bind because there is still a connection in a WAIT state.  And
until that old connection goes away (30 seconds or so?) I cannot restart
the service.  So, the only option would be to sit there in a loop calling
serve_forever until it doesn't throw a "can't bind to socket" exception.

Or is there something I'm *really* missing about the way SocketServer is
supposed to work?  Am I supposed to notify my connection threads to shut
down and disconnect "properly?"  Which gets even more fun since they are
sitting there waiting for input on the connection and not in a position to
respond to other events...gets back to the fun of "killing" threads that
are blocking.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: thread and portability Unix/Linux

2007-03-07 Thread Joshua J. Kugler
awalter1 wrote:

> Hi,
> I have a Python application that runs under HPUX 11.11 (then unix). It
> uses threads :
> from threading import Thread
> # Class Main
> class RunComponent(Thread):
> 
> My application should run under Linux (red hat 3 ou 4) and I read that
> differences exist between the implementation of threads : on HPUX
> 11.11 there is CMA (ou DCE) threads and on Linux POSIX thread. Do you
> think that my Python application should be modified or may be such
> differences are hidden by the python interpreter ?
> In other terms, do I get some risks on this particular aspect by
> porting my application ?
> Thanks a lot
> 
> PS: If you are aware of other risk of porting, I am interested too.

The Python threading model abstracts from the underlying OS threading, so
there should be no need to change anything (AFAIK).

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Why does SocketServer default allow_reuse_address = false?

2007-03-07 Thread Joshua J. Kugler
Chris Mellon wrote:
>> My problem (and the reason I set reuse to True) is this: if I have
>> connections active when I restart my service, upon restart, the socket
>> will
>> fail to bind because there is still a connection in a WAIT state.
> 
> This is just the way sockets work on your platform. How exactly
> sockets shut down, and the exact effect that SO_REUSEADDR varies from
> platform to platform. In your case, using it is probably reasonable.

Thank you.  Glad to know I've chosen the best solution for my situation.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: python QT or python-GTK

2007-03-21 Thread Joshua J. Kugler
Dennis Lee Bieber wrote:

> On Sun, 18 Mar 2007 11:55:47 -1000, "Jon Van DeVries"
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
> 
>> ** All the posts found in google are old.  I'm assuming new improvements
>> have been made to both IDEs. **
>> 
>> Please correct me if I'm wrong, I'm a newbie.
>> 
>> 1. Which one of them requires fewer lines to accomplish the same thing?
>> from what I understand QT it's just like Borland J-Builder. Meaning, you
>> want a button, you draw it, then you double-click on it, a window opens
>> up and you type events and behavior. And with GTK, you just type
>> everything.
>>
> For the most part, none of the GUI TOOLKITS (not IDEs) includes a
> drag&drop GUI BUILDER. Toolkits are libraries defining an API (in the
> case of Python to an underlying toolkit... wxPython is the Python
> front-end to wxWidgets). For all the toolkits, the basic operation is
> "just type everything" -- an intermediate mode is where one manipulates
> a configuration file that gets loaded at run-time, and which one
> registers handlers against (my largest GUI application was 15 years ago,
> emulating a Ramtek graphics engine using DECWindows -- it had
> multi-thousand lines of config file in xt; the config file was nearly as
> long as the C code that used it).

I'm not sure if you're referring to something else, or aren't aware of Qt
Designer.  You can design your GUI's in the designer, run py-uic (comes
with PyQt) and you have python code for your GUI.  You then load that up,
and do your custom slot connections at run time.  You can also take the XML
files generated by Qt Designer and load and render them at runtime too.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Finding a module's sub modules at runtime

2007-03-28 Thread Joshua J. Kugler
[If this is documented somewhere, please just point me there.  I googled on
the terms that made sense to me, and didn't find anything.]

So, I have:

ModTest
__init__.py
AModule.py
BModule.py
CModule.py

All works fine.  However, when I import ModTest, I would like it to discover
and store the names of the modules beneath it, and construct a list, say
mod_list, that I can access later to find the names of the sub-modules in
this module.  Kind of setting __all__ at run time, I guess (yes, I'm aware
of the case caveats).

I figured __init__.py coudl take its own __path__ and walk the directory to
find all .py files other than __init__.py, but that seemed hackish.  Is
there an "official" way to do this?  Or a better way?

To give "context:" all the modules will have classes that have the same
name, same methods etc.  One of the modules will be picked depending on
which implementation is needed.

Thanks!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Finding a module's sub modules at runtime

2007-03-28 Thread Joshua J. Kugler
On Wednesday 28 March 2007 12:04, [EMAIL PROTECTED] wrote:
>> All works fine.  However, when I import ModTest, I would like it to
>> discover and store the names of the modules beneath it, and construct a
>> list, say mod_list, that I can access later to find the names of the
>> sub-modules in
>> this module.  Kind of setting __all__ at run time, I guess (yes, I'm
>> aware of the case caveats).
>>
>> I figured __init__.py coudl take its own __path__ and walk the directory
>> to
>> find all .py files other than __init__.py, but that seemed hackish.  Is
>> there an "official" way to do this?  Or a better way?
>>
>> To give "context:" all the modules will have classes that have the same
>> name, same methods etc.  One of the modules will be picked depending on
>> which implementation is needed.
> 
> I think you need to research how to create documentation. When I
> import a module/package, I can then type help(moduleName) and it'll
> give me the module or package's contents.
> 
> http://mail.python.org/pipermail/python-list/2003-February/192069.html
> 
> You may be able to figure out how to do this just be studying the
> "help" module itself.
> 
> Mike

Well, it seems the "help" module is a built in, and has no .py file
anywhere.  The epydoc package uses the imports.file_modules(dirname)
function, which just walks the directory tree.  Thanks for the
pointer...just confirmed that I have to do something I wanted to avoid. 
But I guess if I use Python's os module and the __path__ string, it should
still be nicely portable.  It just seems that since Python is gathering
that information anyway, it should make it available without me having to
walk the directory tree.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Finding a module's sub modules at runtime

2007-03-29 Thread Joshua J. Kugler
On Thursday 29 March 2007 07:33, Alex Martelli wrote:

> Joshua J. Kugler <[EMAIL PROTECTED]> wrote:
> 
>> still be nicely portable.  It just seems that since Python is gathering
>> that information anyway, it should make it available without me having to
>> walk the directory tree.
> 
> Sorry, where is Python "gathering that information anyway"?  Unless I'm
> mistaken, Python by default does not walk directory trees of subpackages
> -- what makes you think it does?

Hmm...right: dynamic language, runtime binding.  It would go out and find
whether or not Module1.Module2 existed only when import was called.  Sorry,
my bad.  I am assuming, however, that the help function walks the directory
tree, or else I would not get output like this:

>>> import ModTest
>>> help(ModTest)
Help on package ModTest:

NAME
ModTest

FILE
/usr/local/lib/python2.4/site-packages/ModTest/__init__.py

PACKAGE CONTENTS
AModule
BModule
CModule

Thanks for the clarification.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Object Oriented Database with interface for Pyhton

2007-03-30 Thread Joshua J. Kugler
On Friday 30 March 2007 01:04, [EMAIL PROTECTED] wrote:

> Hello all
> 
> I am looking for an object oriented database with interffaces for
> python. Either open source or commercial.
> 
> I am looking for a Database not a object persistence system. I would
> like to be able to execute queries outside from the aplication. If
> posible wih OQL ( object query language )
> 
> The only candidate I have now is Cache from Intersystem
> 
> Thanks in advance

I've not used it, but http://schevo.org/ certainly looks interesting.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Finding a module's sub modules at runtime

2007-04-02 Thread Joshua J. Kugler
On Thursday 29 March 2007 17:58, Alex Martelli wrote:
> Sure, pydoc (which help calls under the code) does that, with a nice mix
> of inspect, os, and pkgutil.iter_modules calls.  pkgutil.iter_modules
> may in fact be most of what you need:
> 
 help(pkgutil.iter_modules)
> Help on function iter_modules in module pkgutil:
> 
> iter_modules(path=None, prefix='')
> Yields (module_loader, name, ispkg) for all submodules on path,
> or, if path is None, all top-level modules on sys.path.
> 
> 'path' should be either None or a list of paths to look for
> modules in.
> 
> 'prefix' is a string to output on the front of every module name
> on output.

OK, that looks nice...but what version of Python is that? 
http://docs.python.org/lib/module-pkgutil.html only shows one function (and
that's 2.5) and my python 2.4 installation is similarly lacking an
iter_modules() function for the pkgutil module.  Is this a 2.6 thing?

Suppose I could just copy the code from here:
http://mail.python.org/pipermail/python-checkins/2006-April/051452.html and
add it to my module. :)

Thanks for the pointer!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Finding a module's sub modules at runtime

2007-04-03 Thread Joshua J. Kugler
On Monday 02 April 2007 16:33, Robert Kern wrote:
>> help(pkgutil.iter_modules)
>>> Help on function iter_modules in module pkgutil:
>>>
>>> iter_modules(path=None, prefix='')
>>> Yields (module_loader, name, ispkg) for all submodules on path,
>>> or, if path is None, all top-level modules on sys.path.
>>> 
>>> 'path' should be either None or a list of paths to look for
>>> modules in.
>>> 
>>> 'prefix' is a string to output on the front of every module name
>>> on output.
>> 
>> OK, that looks nice...but what version of Python is that?
>> http://docs.python.org/lib/module-pkgutil.html only shows one function
>> (and that's 2.5) and my python 2.4 installation is similarly lacking an
>> iter_modules() function for the pkgutil module.  Is this a 2.6 thing?
> 
> No, 2.5. The documentation is not up to date. Read the source.
> 

Gotcha.  Thanks...well, since we're using 2.4, that will have to wait.  For
the archives, here is what I've come up with.

Contents of the __init__.py for a module.

import os
_myDir = __path__[0]

def mod_list():
"""
A quick hack that retrieves all the sub modules in a directory that has
an  __init__.py file.  I could use pkgutil.iter_modules, but that is
Python 2.5 only, and this should work with several versions of Python.
"""
modList = []
modHash = {}
isModule = False
for ii in os.walk(_myDir):
if ii[0] == _myDir:
for f in ii[2]:
# If there is no __init__ file, then the directory
# upon which mod_list() is operating is not a module
if f[0:8] == '__init__':
isModule = True
elif f[-3:] == '.py':
modHash[f[:-3]] = True
elif f[-4:] == '.pyc' or f[-4:] == '.pyo':
modHash[f[:-4]] = True
if isModule:
modList = modHash.keys()
modList.sort()
return(modList)
else:
return(None)

Hope that helps someone!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: SUMMON - Rapid prototyping of 2D visualizations

2007-04-05 Thread Joshua J. Kugler
On Thursday 05 April 2007 10:12, [EMAIL PROTECTED] wrote:

> I have been using python for the last two years to create various
> visualizations for my research in computational biology.  Over the
> years, I found that I often needed the same kinds of features for many
> of my visualizations (OpenGL graphics with basic scrolling and
> zooming).  I have implemented these features in an extension module
> for python called SUMMON which I have made freely available on my
> website for anyone who is interested  rasmus/summon/index.shtml>.

It does sound interesting.  Please add it to the cheese shop to facilitate
easier discovery and wider exposure.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: installing pyqt4 on ubuntu 6.06

2007-04-10 Thread Joshua J. Kugler
On Tuesday 10 April 2007 07:35, Pradnyesh Sawant wrote:

> Any pointers regarding what packages should i install to get the
> system into working condition would be very helpful

It's next to impossible, due to conflicts with SIP, and other dependencies. 
See these two threads (both started by me) for more information:

http://ubuntuforums.org/showthread.php?t=243936
http://ubuntuforums.org/showthread.php?t=244612

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: About Trolltech QT OpenSource license.

2007-04-11 Thread Joshua J. Kugler
On Tuesday 10 April 2007 12:52, Kevin Walzer wrote:
> Yes. Nothing in the GPL prevents you from developing and marketing an
> application for as high a price as you can get from it.
> 
> HOWEVER:
> 
> you will have to distribute the source code to your application to
> anyone who purchases a binary from you.
> 
> AND:
> 
> they will be permitted under the GPL to redistribute your application,
> source code and all. The GPL would allow them to buy your application
> from you and then redistribute it at no cost to others.

To add to the train of thought: While anyone who buys your GPL program (and
acquires the source) will be able to distribute copies of the source code
to MyGreatProgram, you can via *trademark law* (COMPLETELY different area
than copyright law) prevent them from calling it MyGreatProgram, or even
from saying publically "This program is just like MyGreatProgram."  A name
can be owned (proprietary, if you will), even if the software itself is
under the GPL.  Alfresco and MySQL are under the GPL, but if you made
massive (or any?) modifications to the source code, or wrote your own
versions from the ground up, and then tried to distribute them as Alfresco
or MySQL, I think you would hear from their lawyers. :)

I hope that doesn't add to the confusion, but provides further
clarification.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Python editor/IDE on Linux?

2007-04-16 Thread Joshua J. Kugler
On Friday 13 April 2007 10:20, Jack wrote:

> I wonder what everybody uses for Python editor/IDE on Linux?
> I use PyScripter on Windows, which is very good.

I'm using  WingWare's WingIDE.  Visual debugger, python-scriptable,
projects, code-completion that is second-to-none (I LOVE it.).  And a very
responsive support team.  Yes, it's commercial, but it's cheaper than
Komodo, and works a lot better for Python.

Plus, it's written in Python, so the developers eat their own dog food. 
During the development cycle for 3.0 (it's at Alpha 1 right now*), all they
used to development was the active code base.

*I'm using 3.0a1 right now for my development work, and have not had a
single crash or glitch.  It's good stuff.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Wanted: Email Client with GUI

2007-04-18 Thread Joshua J. Kugler
On Wednesday 18 April 2007 05:07, Franz Steinhaeusler wrote:

> Hi, although I have googled, I didn't find a Python
> email client program fitting to my needs.
> 
> What I want is a program (it doesn't have to be so sophisticated
> as thunderbird) written totally in python and using a gui
> toolkit like pyqt, pygtk, wxpyhton or tkinter.
> 
> Who knows such a program? ;)

Why not give Chandlar a try?  It's mostly python, with some parts written in
C (for speed, I assume).

http://chandler.osafoundation.org/

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: why does Configparser change names to lowercase ?

2007-09-17 Thread Joshua J. Kugler
On Friday 14 September 2007 12:21, stef mientki wrote:
> Why does  Configparser change names to lowercase ?
> 
> As Python is case sensitive (which btw I don't like at all ;-)
> but now when really need the casesensitivity,
> because it handles about names which should be recognized by human,
> it changes everything to lowercase 
> 
> thanks,
> Stef Mientki

According to the ConfigParser docs:

"All option names used in interpolation will be passed through the
optionxform() method just like any other option name reference. For
example, using the default implementation of optionxform() (which converts
option names to lower case), the values "foo %(bar)s" and "foo %(BAR)s" are
equivalent."

So, it seems it would be trivial so sublcass ConfigParser, and reimplement
optionxform()

Hope that helps.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

A struct for 2.4 that supports float's inf and nan?

2007-09-19 Thread Joshua J. Kugler
I'm trying to put some values into a struct.  Some of these values are NaN
and Inf due to the nature of the data.  As you well may know, struct (and 
other things) in Python <= 2.4 doesn't support inf and nan float values. 
You get the dreaded "SystemError: frexp() result out of range" error.

Before I go and write my own little wrapper, has anyone out there written
an "extended" struct that supports the inf and nan values?  I know this is
fixed in 2.5, but using that isn't an option at this point, as users will
be running older versions of python.

I suppose I could get the relevant source from the 2.5 source and compile it
as a custom package, but that wouldn't be very transparent for my users,
and would probably be getting in way over my head. :)

Ideas?  Suggestions?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: A struct for 2.4 that supports float's inf and nan?

2007-09-20 Thread Joshua J. Kugler
On Thursday 20 September 2007 11:19, Paul Hankin wrote:

>> I suppose I could get the relevant source from the 2.5 source and compile
>> it as a custom package, but that wouldn't be very transparent for my
>> users, and would probably be getting in way over my head. :)
>>
>> Ideas?  Suggestions?
> 
> Here's a wrapped pack:
> 
> import struct
> 
> pack_double_workaround = {
>   'inf': struct.pack('Q', 0x7ff0L),
>   '-inf': struct.pack('Q', 0xfff0L),
>   'nan': struct.pack('Q', 0x7ff8L)
> }
> 
> def pack_one_safe(f, a):
>   if f == 'd' and str(f) in pack_double_workaround:
>   return pack_double_workaround[str(f)]
>   return struct.pack(f, a)
> 
> def pack(fmt, *args):
>   return ''.join(pack_one_safe(f, a) for f, a in zip(fmt, args))
> 
> Unpacking is similar: unpack doubles with 'Q' and test the
> long for equality with +-inf, and find nan's by checking bits
> 52 to 62. If the number's ok, unpack again using 'd'.
> 
> You can get python values for nan, -inf and inf by using
> float('nan'), float('-inf'), float('inf').
> 
> I've not been able to properly test this, as struct seems
> to work fine in Python 2.3 and 2.4 on MacOS X.

Thanks for the ideas, Paul!  I came up with something that works for me, but
this has a few ideas that I'm going to implement in my wrapper to make for
cleaner code.

As to testing it on MacOS X: yeah, it can be a somewhat system-dependent
problem, so may not show up on all architectures.

Thanks for the tips!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

GUI for viewing/editing python data structures?

2007-09-26 Thread Joshua J. Kugler
A while back, I seem to remember coming across a small program that could
view and edit python data structures via a nice expanding tree view.  I'm
now in need of something like that (to verify data is imported correctly
into a shelve file) and having a GUI would be much simpler than trying to
wade through the output of str(d) or repr(d).

I've tried googling with the obvious keywords (gui (view OR edit) python
data structures) but t didn't get me anywhere.

Pointers?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: GUI for viewing/editing python data structures?

2007-09-28 Thread Joshua J. Kugler
On Thursday 27 September 2007 22:40, David wrote:

> On 9/27/07, Joshua J. Kugler <[EMAIL PROTECTED]> wrote:
>> A while back, I seem to remember coming across a small program that could
>> view and edit python data structures via a nice expanding tree view.  I'm
>> now in need of something like that (to verify data is imported correctly
>> into a shelve file) and having a GUI would be much simpler than trying to
>> wade through the output of str(d) or repr(d).
>>
>> I've tried googling with the obvious keywords (gui (view OR edit) python
>> data structures) but t didn't get me anywhere.
>>
>> Pointers?
>>
> 
> non-gui alternatives: Try pprint module. Or output as yaml (external
> library) into a text file. You could also output as XML (using
> built-in python modules), save to file and then use Firefox or another
> XML gui to inspect it. I haven't done the latter before but it should
> work.

I may give those a try.  I was also looking at the editing aspect too.  But
that's a good start.

Thanks.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: GUI for viewing/editing python data structures?

2007-09-28 Thread Joshua J. Kugler
On Thursday 27 September 2007 20:20, Paddy wrote:

> On Sep 26, 11:23 pm, "Joshua J. Kugler" <[EMAIL PROTECTED]> wrote:
>> A while back, I seem to remember coming across a small program that could
>> view and edit python data structures via a nice expanding tree view.  I'm
>> now in need of something like that (to verify data is imported correctly
>> into a shelve file) and having a GUI would be much simpler than trying to
>> wade through the output of str(d) or repr(d).
>>
>> I've tried googling with the obvious keywords (gui (view OR edit) python
>> data structures) but t didn't get me anywhere.
>>
> 
> The magic googling phrase is:
>   Python bean-editor
> 
> Which gave http://home.gna.org/oomadness/en/editobj/index.html
> 
> I've never used it. Could you tell me how you get on?
> 
> - Paddy.

Thank you!! This is EXACTLY what I was looking for. Should serve me well. 
For editing shelves, you just have to pull the data out via the key, and
then edit that, since a shelf is not a true dict, just acts like one.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: Millisecond timestamp function?

2007-10-19 Thread Joshua J. Kugler
On Friday 19 October 2007 05:44, Dmitri O.Kondratiev wrote:

> What Python module / function can be used to get millisecond timestamps?
> time.time() returns the time as a floating point number expressed in
> seconds since the epoch, in UTC.
> 
> Thanks!

See the module datetime.

The datetime object can return down the to microsecond.

>>> import datetime
>>> datetime.datetime.now()
datetime.datetime(2007, 10, 19, 9, 13, 53, 289075)

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: ConfigParser preserving file ordering

2007-10-18 Thread Joshua J. Kugler
On Thursday 18 October 2007 15:23, Frank Aune wrote:

> Hello,
> 
> I use ConfigParser and actually quite like it, EXCEPT that it doesnt
> preserve the section order of the original config file when writing a new.
> This behaviour is hopeless IMO, and I've been looking for alternatives.
> 
> I've been reading the interesting discussion on python-dev about
> improvements to ConfigParser:
> 
> http://mail.python.org/pipermail/python-dev/2006-January/060138.html
> 
> I know there are patches to archieve what I want, but tbh I need
> functionality present in the standard library or as a last option
> sub-class ConfigParser to archieve ordering preservation.
> 
> Since the thread above is nearly two years old, I'm wondering if something
> has happended in this department?

Have you taken a look at ConfigObj?

http://www.voidspace.org.uk/python/configobj.html

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

Re: PDF rendering toolkit?

2007-01-11 Thread Joshua J. Kugler
Jorge Vargas wrote:

> On 1/6/07, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>> > I'm looking for a tool to take an actual .pdf file and display it in a
>> > window (I'm using wxwidgets at the moment)
>>
>> No idea if there is a one-shot-kills-them-all solution out there - but
>> if you have a way to go for windows, you might checkout PyQt and PyKDE
>> to embed a kpfd-view in a window of yours.
>>
>> I agree that it is less than desirable to switch toolkits - but if you
>> _have_ to...
>>
> yes indeed the problem with that is I want my code to be portable that
> is the reason I'm working on top of wx.

Qt3 (and PyQt3) is available on all platforms.  Qt4 (and PyQt4) is GPL on
all platforms for GPL projects.  You no longer *have* to stick with wx for
cross platform GPL goodness.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Doing date/time + TZ math in python

2007-01-11 Thread Joshua J. Kugler
[EMAIL PROTECTED] wrote:

>> The problem is, how do I create a datetime object and tell it that it's
>> America/Anchorage *daylight savings time* instead of whatever the system
>> is
>> currently set at?  pytz only has America/Anchorage, and I saw no way to
>> tell it explicitly that the timezone is in Daylight instead of Standard
>> time (e.g. using AKST vs. AKDT for the time zone).
>>
>> I'm sure there is a way to do it, and I'm sure it's quite simple, but it
>> hasn't jumped out at me yet.  Is there a module that I haven't seen that
>> would be better suited for this?
> 
> It looks like3 you're 9 hours in this example:
> http://docs.python.org/lib/datetime-tzinfo.html, see e.g.
> http://www.worldtimezone.com/index12.php

Right, I know I'm at GMT-9, and tzinfo correctly deduces that when it
creates an object.  But what if I were currently at GMT-8 (my time zone on
daylight savings time) and I was importing data created during standard
time?  How would I create an object and tell it this is America/Anchorage
on standard time, or conversely, how would I right now create and object
and tell it to use daylight time?  In other words, how can I explicitly
specify whether or not the time object being created is daylight savings
time or not?  I did not see that option in the documentation reading I did.

Thanks!

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: how to mimik a main() function to start a program with entry point?

2007-01-20 Thread Joshua J. Kugler
krishnakant Mane wrote:

> hello all.
> I have one simple query and may be that's to stupid to answer but I am
> not finding the answer any ways.
> I have a set of modules in my package and out if which one is my
> actual starting point to my entire program.  say for example I have an
> entire database application ready and I want a main (as in java or c)
> to initiate the program and may be bring up a login screen and then
> pass the control on to the main window.
> if I am giving raw source code that is easy because I will tell user
> to run the command ./xyz.py which has that function.
> but if I freze it into an executable with py2exe for example , how do
> I solve this problem?
> thanks.
> Krishnakant.

See http://www.artima.com/weblogs/viewpost.jsp?thread=4829
by GvR himself.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: My python programs need a GUI, wxPython or PyQt4?

2007-01-23 Thread Joshua J. Kugler
Daniel Jonsson wrote:
> So, I've reached the point where my building pipeline tools actually
> needs to be used by other people in my company. By this reason I
> actually need to think about the usability, and I've come to the
> conclusion that I need a GUI. So, which of the two packages should I
> learn, and which one is easier to pick up?
> Thanks in advance!

Wow...are you *trying* to start a flamewar? :)

Anyway, here are a few points to think about.  This is by no means
exhaustive, and I'm sure others will add to (and/or correct) what I say. 
I'm most familiar with Qt, so my comments will be directed that way.

Qt4 *is* GPL, but you can only use it for free if the software you're
writing is GPL.  So, if there is no issue with you making your source code
public, there is no problem using Qt.  wxWindows is essentially LGPL, so
might be easier to use, depending on how closely you need to hold your
source code.

wxWindows uses Gtk widgets on *nix.  In *my opinion* the Qt widgets look
better, but that's just me.

From what I've seen of the PyQt4 API, it's very clean and easy to use.

You can design your forms using the standard QtDesigner and compile them to
Python by using py-uic.  You can also load .ui files at run time if you
want.  I have no idea of the form design facilities in wxWindows, others
can add their input there.

It's very easy to create forms with QtDesigner.  And also easy to make sure
they still nicely laid out and proportionate by using layouts and spacers.

Anyway, those are the thoughts off the top of my head, I'll chime in again
if I think of more.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: My python programs need a GUI, wxPython or PyQt4?

2007-01-23 Thread Joshua J. Kugler
Daniel wrote:

> I've downloaded both the wxPython and the PyQt4 package, and by the
> first impression I must say that the PyQt4 system had a very
> compelling presentation. From what I can understand from the feedback
> I've gotten so far is that the wxPython is a better choice when it
> comes to compability (with linux), and it's free even if I want to
> create applications and sell them.
> So, from what I understand I will have to go with PyQt4 since (from
> my understanding):
> 1. I will not sell the applications I'm working with since they will
> only be used by the internal QA at a computer game company.

Even that is getting on shaky ground, at least according to Troll Tech. 
See: http://www.trolltech.com/developer/knowledgebase/190/  So, write it
for internal use, and put up for distribution on your personal web site
(pending company approval, of course).

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Beginners Tutorial in PDF Format?

2007-01-24 Thread Joshua J. Kugler
W. Watson wrote:

>>> http://docs.python.org/download.html
>> 
>> Try again. The first url goes to this page:
>> Download Python 2.5 Documentation (19 September 2006): To download an
>> archive containing all the documents for this version of Python in one
>> of various formats [pdf included, you can choose between Letter/A4].
>> Below, it says "These documents are not available for download
>> individually."
>> 
> There is nothing there with the title "Python 2.5 Documentation".

Really? At http://docs.python.org/download.html the header across
says "Download Python 2.5 Documentation (19 September 2006)" and the links
for downloading are, for example,
http://docs.python.org/ftp/python/doc/2.5/pdf-letter-2.5.zip  "2.5" occurs
twice in that URL.  I think that's a pretty good indicator that it is a
download for version 2.5.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Return images with matplotlib?

2007-02-06 Thread Joshua J. Kugler
Jan Danielsson wrote:

> Hello all,
> 
>I have written a program which takes some data from a postgresql
> database, and via mod_python outputs it as tables on a web site. Now I
> would like to present these tables as graphs, which matplotlib can do.
>   But in order to properly display these graphs on the web page, I need
> to return the image data, like so:
> 
> def barchart(req, params):
>some_format = matplotlib.generate_fancy_graph(params)
>png_buf = make_png_buffer(some_format)
>return png_buf
> 
>Is this possible? If so -- how?

If you are returning the buffer (and nothing else) directly to a browser you
can't print a Content-type header that says it's a png file, and the
browser will accept it as a graphic, as long as you call the script from
within an IMG tag.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Graphs, bar charts, etc

2007-02-06 Thread Joshua J. Kugler
Jan Danielsson wrote:

> Hello all,
> 
>I have some data in a postgresql table which I view through a web
> interface (the web interface is written in python -- using mod_python
> under apache 2.2). Now I would like to represent this data as graphs,
> bar charts, etc.
> 
>I know about matplotlib, and it seemed like exactly what I was
> looking for. I tried importing it in my script, but it gave me some
> error about a home directory not being writable. I'm not sure I like the
> idea of it require to be able to write somewhere. Am I using it wrong?
> 
>Is there something else I can use which can produce graphs easily?

We've had good success with matplotlib.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Output to a text window

2007-02-16 Thread Joshua J. Kugler
[EMAIL PROTECTED] wrote:

> Hi,
> 
> I'm going around in circles so I'm asking for help. I want to read a
> simple text file and output the contents to a GUI window when I click
> on a button. I have written a small python program to read the
> contents of a file when a button is clicked but can only output this
> to a console window. I'm using the pygtk binding with glade for the
> gui.
> 
> I know it must be quiet simple but a mental block has rapidly
> descended.
> 
> Any help would be appreciated.

What does your code look like?  What are you using to print?  Are you
writing to the GUI or using the 'print statement?'

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Creating a daemon process in Python

2007-02-22 Thread Joshua J. Kugler
Benjamin Niemann wrote:

>> What is the easiest way to create a daemon process in Python?  Google
>> says I should call fork() and other system calls manually, but is
>> there no os.daemon() and the like?
> You could try
> 

Also, more discussion on the topic here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Why does SocketServer default allow_reuse_address = false?

2007-02-26 Thread Joshua J. Kugler
Considering that UNIX Network Programming, Vol 1 (by W. Richard Stevens)
recommends "_All_ TCP servers should specify [SO_REUSEADDR] to allow the
server to be restarted [if there are clients connected]," and that
self.allow_reuse_address = False makes restarting a server a pain if there
were connected clients, why does SocketServer default allow_reuse_address
to False?  It's kind of bemusing to subclass ThreadingTCPServer just to
change one variable that arguably should have been True in the first place.

Is there some history to this of which I'm not aware?  Is there a good
reason for it to default to false?

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: getting terminal display size?

2007-02-26 Thread Joshua J. Kugler
jeff wrote:

> I don't really understand any of that; can you right me a function
> that'll return the size as a tuple?

Did you even *try* his code?  I ran this: 

import termios, fcntl, struct, sys

s = struct.pack("", 0, 0, 0, 0)
fd_stdout = sys.stdout.fileno()
x = fcntl.ioctl(fd_stdout, termios.TIOCGWINSZ, s)
print '(rows, cols, x pixels, y pixels) =',
print struct.unpack("", x)

And got this result:

(36, 96, 0, 0)

Looks like a tuple to me.  return 'return' instead of 'print' the result. 
We don't mind helping, but it's nice to know that the user has made some
attempt to understand what is going on before asking for free work to be
done.

j



-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: convert many excel files to pdf in batch

2007-02-28 Thread Joshua J. Kugler
Wensui Liu wrote:

> Adam,
> If you could come up with a way without using Adobe writer, it should
> also work for me.
> thanks.
> 
> On 28 Feb 2007 12:53:52 -0800, Adam <[EMAIL PROTECTED]> wrote:
>> 1. Get PDFCreator
>> 2. Install
>> 3. Set as default printer
>> 4. Have all excel files in same folder
>> 5. Select all excel files
>> 6. Right click
>> 7. Select Print
>> 8. Save Each PDF to a location
>> 9. ???
>> 10. Profit
>>
>> Never done it with Adobe Writer. I'm a cheapskate.

He didn't use Adobe Writer!  In fact he said he didn't.  PDFCreator is a
free utility.  Download it here:
http://www.pdfforge.org/products/pdfcreator/

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

Re: Python Tutorial

2007-03-01 Thread Joshua J. Kugler
Timm Florian Gloger wrote:

> Hi,
> 
> is Guido van Rossum's "Python Tutorial" in non-HTML formats (e.g. PDF
> or PS) avaiable for free?
> 
> Regards,
> Timm

You mean like here: http://docs.python.org/download.html

You have to download them all, but a download of the PDFs will include the
tutorial.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com

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

ANNOUNCE: AwstatsReader 0.01

2009-08-03 Thread Joshua J. Kugler
ABOUT THE MODULE

AwstatsReader is an attempt at a pythonic interface to AWStats data 
cache
files.  Using it, you can access year, month, and individual data points
via dictionary-like accessors.

Download here: http://azariah.com/open_source.html

ABOUT THE AUTHOR

Joshua Kugler (jos...@azariah.com) is a programmer and system 
administrator
with over 10 years of industry experience.  He is currently looking for 
a
job.  Happen to have one you could offer him? :)
Resume at: http://jjncj.com/papers/KuglerAll.pdf

DISCLAIMER
==
This is a "release early, release often" release, codnamed Joshua-hopes-
somebody-downloads-this-and-likes-code-quality-and-hires-him.

This is an early release...probably pre-alpha.  There are no tests yet
(haven't
generated cache files I can release publically), not much documentation,
and the interface may change (but I hope not too much).

And I haven't even put this in a public repository, as the name might 
(but
probably won't) change.

I wrote this via examples from an AWStats cache file, so I'm sure there 
are
sections for which I do not have definitions.  If you would send me 
those
sections, I'll be sure to add them.

The error handling is probably a little light.  Certainly could be 
improved.

Right now, this will parse and display cache files from AWStats 6.5. 
I've
not
tested other versions yet, as 6.5 is the only version I've had access to 
so
far.


INSTALLATION

See INSTALL

LICENSE
===
See COPYING

EXAMPLE
===
import AwstatsReader

obj  = 
AwstatsReader.AwstatsReader('/path/to/awstats_logs', 'example.com')

print obj[2007]
print obj[2008][6]
m = obj[2009][7]
print m['general']
# Access like a dictionary...
print m['general']['LastLine']
#...or like an object attribute
print m['general'].LastLine
print m.general.LastLine

FEEDBACK

Please send questions/comments/suggestions to awstatsrea...@azariah.com
For now, you can find the latest version here:
http://azariah.com/open_source.html
-- 
http://mail.python.org/mailman/listinfo/python-list