py2exe + win32com + DAO

2009-05-12 Thread Trevor
I have a Python code module that adds records to a MS Access
database.  The following line of code executes successfully when the
code module is run as a Python script:

daoEngine = win32com.client.Dispatch(r'DAO.DBEngine.36')

It also runs successfully when the Python script is compiled and run
as an executable using the Py2exe utility.  However, when the compiled
executable is called from VBA using the win32 CreateProcess function,
the preceding code produces this output:

!!python/name:pywintypes.com_error ''

What is causing this error?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: py2exe + win32com + DAO

2009-05-12 Thread Trevor
I do not believe your assertion applies to the following line of code:

daoEngine = win32com.client.Dispatch(r'DAO.DBEngine.36')

The preceding code snippet instantiates a COM object and is
prerequisite to creating a reference to a specific database:

daoDB = daoEngine.OpenDatabase(dbname)

As the compiled Python module executes successfully when invoked from
a command-line but not when invoked using the win32 CreateProcess
function, I suspect that one or more of the arguments to CreateProcess
is preventing successful execution.  I will investigate this further
(possibly on a win32 forum); however, is it possible to obtain more
verbose error output from Python modules?  The error message in the
original post was generated from:

print sys.exc_info()[0]

On May 12, 5:31 pm, David Lyon  wrote:
> Maybe VB is opening the table in Exclusive mode... then when you
> are opening it as a subprocess, it's already locked.
>
> It's possible the win32com module is not giving you a very
> descriptive error message.
>
> Try running your process while vb is running at the same time
> with the database open and if you get the same error then it
> might confirm my assertion.
>
> Otherwise it is likely that it is something else.
>
> On Tue, 12 May 2009 17:20:15 -0700 (PDT), Trevor 
> wrote:
>
> > I have a Python code module that adds records to a MS Access
> > database.  The following line of code executes successfully when the
> > code module is run as a Python script:
>
> > daoEngine = win32com.client.Dispatch(r'DAO.DBEngine.36')
>
> > It also runs successfully when the Python script is compiled and run
> > as an executable using the Py2exe utility.  However, when the compiled
> > executable is called from VBA using the win32 CreateProcess function,
> > the preceding code produces this output:
>
> > !!python/name:pywintypes.com_error ''
>
> > What is causing this error?
>
>

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


Re: py2exe + win32com + DAO

2009-05-14 Thread Trevor
I think the problem I am experiencing bears a resemblance to the
content of this post:

http://mail.python.org/pipermail/python-list/2001-February/071421.html

Does anyone know what the GUID for the DAO 3.6 library is (or can
explain how I can find it)?

On May 12, 11:00 pm, David Lyon  wrote:
> On Tue, 12 May 2009 22:06:42 -0700 (PDT), Trevor 
> wrote:
>
> > I do not believe your assertion applies to the following line of code:
>
> > daoEngine = win32com.client.Dispatch(r'DAO.DBEngine.36')
>
> It doesn't. I'm simply suggesting that it is possible you are opening
> the database in Access or something in Administrator/dba mode. That
> could be causing an exclusive lock on the database so that no sub
> task can then open it.
>
> i have seen this on old versions of Access.
>
> To provide excellent performance, microsoft used to load the whole
> database into memory if it could. And just operate mostly from there.
>
> > is it possible to obtain more
> > verbose error output from Python modules?  The error message in the
> > original post was generated from:
>
> > print sys.exc_info()[0]
>
> possibly but i'm not sure how...
>
> David

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


Tkinter Window On Top

2009-05-15 Thread Trevor
Can a Tkinter application create a COM object and keep its own window
on top of it?

excel = win32com.client.Dispatch('Excel.Application')

I would like the user to be able to see and interact with the Excel
application but keep the Tkinter application on top.
-- 
http://mail.python.org/mailman/listinfo/python-list


2d barcode library?

2009-05-20 Thread Trevor
Is anyone aware of a good library for building 2d barcodes (any format
will work for me) and outputing them as some picture format,
presumably png or bmp to be used for html printing? For 1D barcodes a
simple barcode font will suffice, but obviously 2D is not so simple
and i have yet to find the appropriate tool for use in a python
project...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2d barcode library?

2009-06-04 Thread Trevor
>
> Christian
>
> [1]https://cybernetics.hudora.biz/projects/wiki/huBarcode

Thanks guys! huBarcode will work..
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing Python 3.1.2 from source, how do you resolve the sqlite3-dev dependency?

2010-06-16 Thread Trevor
Running ubuntu 9.04 "jaunty".

When I run make I get the following error:

Python build finished, but the necessary bits to build these
modules were not found:
_sqlite3


So the easy solution is to just install the missing dependency using
apt-get, "sudo apt-get -f install libsqlite3-dev" but I get the
following error:

The following packages have unmet dependencies:
  libsqlite3-dev: Depends: libsqlite3-0 (= 3.6.10-1) but
3.6.10-1ubuntu0.2 is to be installed
E: Broken packages

I tried uninstalling "libsqlite3-0" but synaptic said many things
needed it (50+).

So now I am stuck. I can't install the missing dependency. And
therefore I can not install python 3.1.2.

**Any ideas on how to fix the missing libsqlite3-dev dependency?**
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: No more Python support in NetBeans 7.0

2012-07-16 Thread trevor . carlston
On Wednesday, October 26, 2011 8:06:16 PM UTC-6, w...@naveed.net wrote:
> Sorry to comment on an old topic, but I wanted to clarify for others like me 
> who might get the wrong idea. 
> 
> It looks like this is no longer true. Netbeans 7 might be supporting python 
> after all.
> 
> http://wiki.netbeans.org/Python70Roadmap

This article is dated January 29th of 2011
http://netbeans.org/projects/www/lists/nbpython-dev/archive/2011-01/message/0
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: No more Python support in NetBeans 7.0

2012-07-16 Thread trevor . carlston
On Wednesday, October 26, 2011 8:06:16 PM UTC-6, w...@naveed.net wrote:
> Sorry to comment on an old topic, but I wanted to clarify for others like me 
> who might get the wrong idea. 
> 
> It looks like this is no longer true. Netbeans 7 might be supporting python 
> after all.
> 
> http://wiki.netbeans.org/Python70Roadmap

I checked the date on that document it's last update was  5 November 2009
-- 
http://mail.python.org/mailman/listinfo/python-list


AI Example Help

2012-10-11 Thread Trevor Nelson
Hello all,

For the first time in well... a very long time I am coming to a loss on where 
to really get started here on the project I wish to undertake to help me really 
get into Python programming.

A quick explanation of how I learn. I learn best with example working small 
code bits. With the code I then disect it to understand how each part works. 
(within "beginner" limits of course).


I have been looking around the web and google searching a whole lot the past 
week about and really have not had much luck on what I am needing / that is 
really helpful. So, I am here to beg/plead for some help on this.

My end game goal is to create a "hybrid" chat bot. Such as that you can ask it 
questions and talk to it etc. Such as asking "What's the server's current 
load?". I found out I could do that with the HOWIE bot I have been playing 
with. But, I am looking to build up a more "AI" system where instead of me 
asking all the questions, the bot can yell at me and say " HEY THE SERVER IS 
OUT OF RESOURCES".


Further developement will lead to a FAQ style bot as well. Such as that where I 
can ask them things like (for a very basic example, what is a 404 error?), or 
even (what is causing a 500 ISE on the site? [by having it read the logs and 
tell me what the logs say for the site])


These are just the basics to help me get started. As I get more advanced and 
better at this, I would like to be able to have it crawl sites and learn 
different informain. Something as far fetched and I consider a "dream" would be 
it crawling the cpanel forums and gathering up the responses to questions so 
that I could query it as well.


So, as I really, really, hate to have to ask. Does anyone have any example 
coding in what my basic needs are? As I feel that working off the HOWIE bot 
won't turn out to what I am wanting and then I will end up wasting a whole lot 
of time going in the wrong direction. Which is also why I am here


TL;DR
I really would truely appreciate and example coding of how to put together an 
initial basic "AI" bot where it can monitor the system and tell me alerts as 
with being able to query it for questions. As with I am looking for some sort 
of time efficient way for it to gather it's own data. As otherwise all the 
information I would have to manually put in would be extreme.


I greatly appreciate any help you guys can prodive me with to help me get 
started. Before you assume I want everyone to do all the work for me, it's not 
the case. It's just that I learn best/faster from example code.
Also, I am thinking of going with python 2.7 for this since it seems all the 
documentation I run into isn't for the 3.x Python.


Thank you so much anyone who can help me. Also, if you are someone who actually 
knows how to do everything I have mentioned, I would even ben willing to hire a 
"tutor" to teach me these things.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: AI Example Help

2012-10-11 Thread Trevor Nelson

> 
> An interesting concept. AI monitoring systems have never really
> 
> appealed to me; I personally prefer something with simpler and clearer
> 
> rules (eg "if server load exceeds 3.0, raise an alert"), coupled with
> 
> information retrieval commands that read like commands, not natural
> 
> English. But I can see the value of the more "human-friendly style",
> 
> if that's the term for it.
The other goal on this project is to make the application work it's best to 
automatically narrow down the cause and correct it by itself with a report.



> 
> > I greatly appreciate any help you guys can prodive me with to help me get 
> > started. Before you assume I want everyone to do all the work for me, it's 
> > not the case. It's just that I learn best/faster from example code.
> 
> > Also, I am thinking of going with python 2.7 for this since it seems all 
> > the documentation I run into isn't for the 3.x Python.
> 
> >
> 
> 
> 
> Understandable.
> 
> 
> 
> I would recommend treating this as two completely separate projects:
> 
> 1) Natural language request/response - the "AI" bit, tinkering with
> 
> the HOWIE bot
> 
> 2) Server status querying, log analysis, etc, etc.
> 
> 
> 
> You may already be familiar with one or the other, I don't know. But
> 
> in any case, they're quite separate; it'll be easier to develop one
> 
> and then the other. Divide your problem into pieces, then divide the
> 
> pieces further, and keep on dividing until you have a series of
> 
> one-banana problems[1].

This is what I have actually been thinking of doing is splitting up the HOWIE 
bot.  But, that is one thing I am working on still to really figure out how to 
split it apart between automagicness of telling you things without user input.  
And then the input and answer part.  Although, from what I can think of at this 
time is to write a main program that is the "Automagic part" and then it can 
call in Howie as needed?
> 
> 
> 
> I would also recommend using Python 3.3, for several reasons:
> 
> * There's plenty of docs for 3.3; perhaps web searches are
> 
> highlighting 2.x, but if you go to the main docs page[2] you'll find
> 
> 3.3 there.
> 
> * Py3 has much better Unicode support than Py2, a significant factor
> 
> when you're working with natural language parsing
> 
> * The 2.x line is no longer being developed. Only bugfixes and
> 
> security patches will be applied. 3.x, on the other hand, has cool
> 
> toys added periodically with new versions.

I will have to see how HOWIE runs with python 3, and give it a shot.

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


Writing formatted data (numeric) to a binary file

2005-09-01 Thread Trevor . Dhu
I am just starting to use python, and as such my question may well be a
bit simplistic.  I am currently trying to write what should be a very
basic set of routines for reading and writing to a binary grid format
(ERMapper).  However:

I am struggling to find the correct tools to write a row of a
2-dimensional array to a binary file.  In matlab the command looks
like:

fid=fopen(filename,'wb');
for y=1:NrOfLines
   fwrite(fid,in(y,:)','real*4');
end
fclose(fid);

I'm conscious that the "write" command would allow me to write text to
a binary file, but I'm not clear how to:
1) format my numeric data such that it matches the real*4 format
2) parse an entire row of a 2D array without using a for loop.

If anyone has any suggestions on how to do this (or even hints as to
what modules I should be looking at) they would be greatly appreciated.
 Alternativly, if anyone has written routines for dealing with basic
ERMapper grids (as opposed to the wavelet compressed data) I'd love to
save myself from re-inventing the wheel.

Thanks
Trevor Dhu

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


Using classes in python

2006-10-25 Thread trevor lock
Hello,I've just started using python and have observed the following :class foo:    a=[]    def __init__(self, val):    self.a.append ( val )    def getA(self):    print self.a    return self.az = foo(5)y = foo(4)z.getA()>> [5, 4]I was expecting that everytime I created an instance of the class that a unique dictionary was also created, however it seems that only one dictionary is created.How can I create a new dictionary for each instance?Thanks,Trevor. 
		 All-new Yahoo! Mail - Fire up a more powerful email and get things done faster.-- 
http://mail.python.org/mailman/listinfo/python-list

Help required with Python App

2007-05-21 Thread Trevor Hennion
Hi,

I am producing a Web based database application for a customer and could
do with some help producing pdf documents from the data.

The project uses Apache. Postgresql and Python CGI scripts on a Linux
server for a company with 20-25 users.

I have been looking at the http://www.reportlab.org - ReportLab Toolkit,
but am rather busy with the other parts of the project, so if any one
located in the UK - Reading/Basingstoke area has the right
skills and time available now, please contact me.

I have a small budget available for this work. 

Regards

Trevor

PS UK/Reading/Basingstoke area is essential.
-- 
http://mail.python.org/mailman/listinfo/python-list


Meta Class

2008-02-01 Thread Trevor Johnson
Hi;
I think I have a good candidate for a meta class here. Never done this
before and would like someone to help. In the code that follows, there is
one variable that needs to be changed: the letter 'a' as inserted in
construction of the variable 'word'. In other applications, I will need to
change that to two variables, but they are independent within this code. How
do I go about abstracting these variables to make a meta class?
TIA,
Trevor

 >>> def testing():
...   for word in wordPool:
... i = 0
... i2 = 0
... i3 = []
... new = []
... for letter in word:
...   if letter == 'a':
... i3.append(i2)
... i2 += 1
... new.append(word[0:i + 1] + 'a' + word[i + 1:len(word)])
...   i += 1
...   i2 += 1
... i4 = 0
... i5 = 0
...   for word in new:
... wordPool.append(word)
...   print 'i3: ', i3
...   for word in wordPool:
... while len(i3) > i4:
...   new.append(word[0:i3[i4]] + 'a' + word[i3[i4]:len(word)])
...   i4 += 1
...   while len(i3) > i5:
... new.append(word[0:i3[i5] + 1] + 'a' + word[i3[i5] +
1:len(word)])
... i5 += 1
... i4 = 0
...   for word in new:
... i = 2
... while i < len(word):
...   if word[i - 2] == word[i - 1]:
... if word[i - 1] == word[i]:
...   new.remove(word)
...   i += 1
...   for word in new:
... if word[len(word) - 3:len(word)] == 'aaa':
...   new.remove(word)
...   for word in new:
... wordPool.append(word)
...   i = 0
...   i2 = 0
...   for word in wordPool:
... for test in wordPool:
...   if i != i2:
... if test == word:
...   wordPool.remove(test)
...   i2 += 1
... i += 1
...   for word in wordPool:
... print 'second: ',word
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: xmlrpclib, testing server presence

2008-02-02 Thread Trevor Hennion
On Sat, 02 Feb 2008 00:22:15 -0800, rocco.rossi wrote:

> I'm employing xmlrpclib for a project at work, and I must say that I'm
> quite impressed with its effectiveness and ease of use.
> 
> However, I was recently doing some tests when I realized that if the
> server was down, the client quite simply hanged (no use of "try ...
> except" here) with no error or tracebacks or exceptions whatsoever.
> 
> Is there some way in Python of "testing" the presence of the server on
> the other end, so as to avoid this situation?
> 
> Thank you.

Hi,

Could you test for a socket timeout?:

socket.setdefaulttimeout(20.0) # timeout = 20.0 secs

regards

Trevor
http://www.infocentrality.co.uk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Meta Class

2008-02-04 Thread Trevor Johnson
You're right I totally misunderstood it. And your idea is obvious and simple
enough :)

On Feb 1, 2008 6:33 PM, Gabriel Genellina <[EMAIL PROTECTED]> wrote:

> En Fri, 01 Feb 2008 15:46:05 -0200, Trevor Johnson
> <[EMAIL PROTECTED]> escribió:
>
> > I think I have a good candidate for a meta class here. Never done this
> > before and would like someone to help. In the code that follows, there
> is
> > one variable that needs to be changed: the letter 'a' as inserted in
> > construction of the variable 'word'. In other applications, I will need
> > to
> > change that to two variables, but they are independent within this code.
> > How
> > do I go about abstracting these variables to make a meta class?
>
> I think you totally misunderstood the metaclass concept. A class is an
> instance of its metaclass, that is, a metaclass is the "thing" used to
> create a new class. You don't even use (custom) classes in your example.
>
> If you want to make a more generic function, that is, something that works
> for other letters instead of just 'a', you want a function parameter:
>
> >  >>> def testing(searched_letter):
> > ...   for word in wordPool:
> ...
>
> and replace all occurences of 'a' with searched_letter, and 'aaa' with
> searched_letter*3
>
> Usage: testing('a'), it should give the same results as before. Try
> testing('e') etc.
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Python Contract/Job Opportunity

2008-03-11 Thread Trevor Hennion
InfoCentrality are a small company who provided a custom Web/Database 
application for a customer in the Insurance industry. Our customer now 
wants a number of improvements to this application.

To provide these improvements in a timely manner we need an additional 
programmer.

3 months contract initially - possibly leading to much more.

We use Python, PostgreSQL, Html, Javascript and Linux.
Suite a recent Computer Science or Programming graduate.

Location - just south of Reading, Berks, UK.
Must be able to travel to us.
Phone Trevor Hennion on 0845 5083766.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python is slow

2008-05-22 Thread Matthew Trevor
On May 23, 2:14 am, cm_gui <[EMAIL PROTECTED]> wrote:
> I've yet to see a web application written in Python which is really
> fast.

Then stop looking at your own inept Python code and open your eyes.

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


Re: serach file for regexp, return if found?

2008-05-22 Thread Matthew Trevor
On May 23, 9:10 am, [EMAIL PROTECTED] wrote:
> but search and match only returns matchobjects(what are those anyway?
> i dont get what to do with them, do they contain true/false,
> stringposition etc?)

It's all covered in the docs:

http://docs.python.org/lib/module-re.html
http://docs.python.org/lib/match-objects.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Returning to 'try' block after catching an exception

2008-05-22 Thread Matthew Trevor
On May 23, 4:01 am, "inhahe" <[EMAIL PROTECTED]> wrote:
> Might have a stack overflow issue, if it retries too many times?

In which example? Neither of them is looping...
--
http://mail.python.org/mailman/listinfo/python-list


Peer-to-Peer Chat Program

2008-08-03 Thread Trevor Slocum
Python seemed like the right choice for writing a peer-to-peer application,
as the support for sockets is adequate and the cross-platform ability is
nominal.  That's why I searched around for P2P frameworks in Python, and
didn't have much luck.  The framework that I did find was designed
specifically for file transfers, rather than simple message carriers, and
implemented a complex multicast system.

So, with Python in one hand and Google in the other, I set out to write my
own P2P app in Python, with zero previous P2P experience.  I had to start
off by looking up how P2P works, then figure out how to get messages across
the network, and then how to bootstrap each node, without centralizing the
network.

I decided to make it connectionless because they were simple messages.  The
current implementation is that a peer creates a message and forwards it to
all of its known peers, and then the other peers do the same.  This is for
simplicity, as it causes quite a bit of needless rebound from each of the
other peers sending a message which has already been received.  In order to
reduce this, each message is tagged with a unique ID which is verified
against upon each arrival.

Once that worked well, I needed to get peers to know each other.  My current
solution is a provider script running on a single server which is
auto-pinged every minute by each peer, and any new peers receive a list of
known peers from it.  This can easily be expanded to many more servers in
case any go offline.  Even if zero providers are online, users can manually
add nodes from the console and the framework will automatically build a
known peer list from them.

Like I said, I didn't know anything about P2P before this, and I'm sure much
of what I've done so far can be improved upon.  That's why I'm posting
here.  I'd like to make an open request to anyone who would like to assist
me in the application development to reduce the resource usage and improve
the overall network efficiency.  Even simple "Ah, I saw you were doing this
in your code, I recommend you do this..." would be of great help.

If you are interested, you may view the Google Code page at
http://code.google.com/p/kaishi/ or checkout the SVN repository directly
using http://kaishi.googlecode.com/svn/trunk/

I have proper hosting and can set up a specific website for collaboration on
project ideas and such if support is carried after this message.  I thank
anyone who has taken their time to read this.

-- 
Trevor "tj9991" Slocum
--
http://mail.python.org/mailman/listinfo/python-list

Re: attributes, properties, and accessors -- philosophy

2009-12-09 Thread Trevor Dorsey
Back to the subject of good tools.  Use an IDE that's intended for python.
 We started using WingIDE because it had an inline debugger and came with
all the nice things like autocomplete etc that things like eclipse or visual
studio have.

On Wed, Nov 25, 2009 at 8:46 AM, Bruno Desthuilliers
 wrote:

> Ethan Furman a écrit :
>
>
>> Very helpful, thank you.  Hopefully my brain will be up to the descriptor
>> protocol this time... the last couple times were, um, less than successful.
>>  :)
>>
>
> Well, it's quite simple in fact. Most of the "magic" happens in
> object.__getattribute__ and object.__setattr__. You'll find a rough
> description of what happens here:
>
>
> http://groups.google.com/group/comp.lang.python/browse_frm/thread/a136f7626b2a8b7d/70a672cf7448c68e
>
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 

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


Mailman forwarding (was: Don't feed the troll...)

2013-06-15 Thread W. Trevor King
On Sat, Jun 15, 2013 at 01:07:29PM -0400, D'Arcy J.M. Cain wrote:
> On Sat, 15 Jun 2013 18:41:41 +0200 Chris “Kwpolska” Warrick wrote:
> > On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano wrote:
> > > In the name of all that's good and decent in the world, why on earth
> > > would you do that when replying to a mailing list??? They're already
> > > getting a reply. Sending them TWO identical replies is just rude.
> > 
> > Mailman is intelligent enough not to send a second copy in that case.
> > This message was sent with a CC, and you got only one copy.
> 
> Actually, no.  Mailman is not your MTA.  It only gets the email sent to
> the mailing list.  Your MTA sends the other one directly so Steve is
> correct.  He gets two copies.  If his client doesn't suppress the
> duplicate then he will be presented with both.

Mailman can (optionally) assume that addresses listed in To, CC, …
fields received an out-of-band copies, and not mail them an
additional copy [1].

Cheers,
Trevor

[1]: http://www.gnu.org/software/mailman/mailman-member/node21.html

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


CC etiquette for mailing lists (was: Don't feed the troll...)

2013-06-15 Thread W. Trevor King
On Sun, Jun 16, 2013 at 12:51:04AM +, Steven D'Aprano wrote:
> On Sun, 16 Jun 2013 09:09:37 +1000, Chris Angelico wrote:
> > Mailman is the software that runs python-list@python.org, so this
> > *is* applicable to everyone who reads the mailing list (including
> > myself).  The fact that there's other mailing list software isn't
> > significant;
> 
> I'm not making an argument about CCing the sender on specifically
> this list, I'm making a general observations about list etiquette in
> general.

For some lists [1], the convention *is* to CC interested parties
(which presumably includes the person who's message you are replying
to).  In the case of Mailman-hosted lists, it would seem to be more
considerate to CC folks (since they can opt-out via Mailman), while
folks who only follow the list via occasionally reading Gmane [2] will
probably appreciate the direct ping.  I'm not saying that this should
be the convention for python-list@, I'm just saying that it's not
immediately obvious what the conventions are for a particular list [3],
and there are valid arguments going both ways.

What seems more obvious (to me), is that it's polite to adjust the
subject line if your response if far enough off-topic that the
original subject no longer applies ;).

Cheers,
Trevor

[1]: http://git.kernel.org/cgit/git/git.git/tree/MaintNotes?h=todo#n10
[2]: http://news.gmane.org/gmane.comp.python.general
[3]: Unless you tell new subscribers what the conventions are.  For
 example, the git@ list emails [1] to new list subscribers.

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [python] email 8bit encoding

2013-07-29 Thread W. Trevor King
On Sun, Jul 28, 2013 at 04:41:27PM -0700, ru...@yahoo.com wrote:
> How, using Python-3.3's email module, do I "flatten" (I think
> that's the right term) a Message object to get utf-8 encoded
> body with the headers:
>  Content-Type: text/plain; charset=UTF-8
>  Content-Transfer-Encoding: 8bit
> when the message payload was set to a python (unicode) string?

I asked about this a while back [1], but never got a response.  My
current best-guess is here [2].  My fallback flattening works for
everything except the 8-bit encoded messages using the UTF-16 charset,
but it's pretty ugly.

Let me know if you figure out something cleaner :).

Cheers,
Trevor

[1]: http://thread.gmane.org/gmane.comp.python.general/725425
[2]: https://github.com/wking/rss2email/blob/master/rss2email/email.py#L226

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Flatten an email Message with a non-ASCII body using 8bit CTE

2013-01-24 Thread W. Trevor King
Hello list!

I'm trying to figure out how to flatten a MIMEText message to bytes
using an 8bit Content-Transfer-Encoding in Python 3.3.  Here's what
I've tried so far:

  # -*- encoding: utf-8 -*-
  import email.encoders
  from email.charset import Charset
  from email.generator import BytesGenerator
  from email.mime.text import MIMEText
  import sys

  body = 'Ζεύς'
  encoding = 'utf-8'
  charset = Charset(encoding)
  charset.body_encoding = email.encoders.encode_7or8bit

  message = MIMEText(body, 'plain', encoding)
  del message['Content-Transfer-Encoding']
  message.set_payload(body, charset)
  try:
  BytesGenerator(sys.stdout.buffer).flatten(message)
  except UnicodeEncodeError as e:
  print('error with string input:')
  print(e)

  message = MIMEText(body, 'plain', encoding)
  del message['Content-Transfer-Encoding']
  message.set_payload(body.encode(encoding), charset)
  try:
  BytesGenerator(sys.stdout.buffer).flatten(message)
  except TypeError as e:
  print('error with byte input:')
  print(e)

The `del m[…]; m.set_payload()` bits work around #16324 [1] and should
be orthogonal to the encoding issues.  It's possible that #12553 is
trying to address this issue [2,3], but that issue's comments are a
bit vague, so I'm not sure.

The problem with the string payload is that
email.generator.BytesGenerator.write is getting the Unicode string
payload unencoded and trying to encode it as ASCII.  It may be
possible to work around this by encoding the payload so that anything
that doesn't encode (using the body charset) to a 7bit value is
replaced with a surrogate escape, but I'm not sure how to do that.

The problem with the byte payload is that _has_surrogates (used in
email.generator.Generator._handle_text and
BytesGenerator._handle_text) chokes on byte input:

  TypeError: can't use a string pattern on a bytes-like object

For UTF-8, you can get away with:

  message.as_string().encode(message.get_charset().get_output_charset())

because the headers are encoded into 7 bits, so re-encoding them with
UTF-8 is a no-op.  However, if the body charset is UTF-16-LE or any
other encoding that remaps 7bit characters, this hack breaks down.

Thoughts?
Trevor

[1]: http://bugs.python.org/issue16324
[2]: http://bugs.python.org/issue12553
[3]: http://bugs.python.org/issue12552#msg140294

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: parametized unittest

2014-01-11 Thread W. Trevor King
On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote:
> I'm finding it hard to use unittest in a for loop.  Perhaps something like:
> 
> for val in range(25):
>   self.assertEqual(val,5,"not equal)
> 
> The loop will break after the first failure.  Anyone have a good
> approach for this?  please advise.

If Python 3.4 is an option, you can stick to the standard library and
use subtests [1].

Cheers,
Trevor

[1]: 
http://docs.python.org/3.4/library/unittest.html#distinguishing-test-iterations-using-subtests

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [python] Re: GitHub's ³pull request² is proprietary lock-in

2016-01-03 Thread W. Trevor King
On Sun, Jan 03, 2016 at 04:31:55AM -0500, Random832 wrote:
> But there is no command to create a "pull request", nowhere for such
> a thing to exist in the repository, etc.

There is this [1].

> Also if someone puts through a github pull request and then their
> patch is accepted, my understanding is that the pull request has to
> be "closed" through a github online interface and merely merging the
> patch through the git command line will not update the status on the
> pull request.

This is incorrect.  GitHub will automatically mark PRs as “Merged”
when their tip commit lands in the target branch.  I haven't looked up
docs for when this landed (if it was even announced), but next to
GitHub's “Merge pull request” button there's currently an “or view
command line instructions” link which sketches out some command-line
Git to accomplish the same thing.

But I agree that it's nice to keep the discussion around pull requests
somewhere portable.

Cheers,
Trevor

[1]: http://git-scm.com/docs/git-request-pull

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy


signature.asc
Description: OpenPGP digital signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Deditor 0.2.2

2010-11-08 Thread Trevor J. Christensen
I really like that editor!  Great work!!  Great ideas!!

On Sat, 2010-11-06 at 06:06 -0700, Kruptein wrote:
> Hey,
> 
> I released version 0.2.2 of my pythonic text-editor  Deditor.
> It adds the use of projects, a project is a set of files which you can
> open all at once to make development much faster and easier.
> 
> For more information visit launchpad: http://launchpad.net/deditor
> 
> I also uploaded a video to introduce you to deditor:
> http://www.youtube.com/watch?v=hS8xBu-39VI
> (note: youtube is still processing the file so you might have to wait
> a bit to see it)


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