Merge two directories together

2010-04-16 Thread Keith Hughitt
Suppose you have two file-trees with common sub-directories but different files that you want to merge together, e.g. /test/ /test/a/ /test/a/file1 /test2/ /test2/a/ /test2/a/file2 You can easily merge the directories in Linux using the "cp" command: cp -r test/* test2/ While Python provides s

Re: Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-24 Thread Keith Hughitt
Hi John, Thanks for the suggestions: I have finally been able to get it working :) In anyone else runs into the same problem, here is some example code that works in Python 2.4+: = Begin Example == #!/usr/bin/env python #-*- coding:utf-8 -*- import sys def main():

Re: Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-20 Thread Keith Hughitt
Hello, Thanks for the suggestions and information Diez! On Nov 18, 9:38 am, "Diez B. Roggisch" wrote: > > You are aware that the coding-declaration only affects unicode-literals (the > ones like u"i'm unicode")? So the above insert-statement is *not* unicode, > it's a byte-string in whatever enc

Inserting Unicode text with MySQLdb in Python 2.4-2.5?

2009-11-18 Thread Keith Hughitt
Hi all, I ran into a problem recently when trying to add support for earlier versions of Python (2.4 and 2.5) to some database related code which uses MySQLdb, and was wondering if anyone has any suggestions. With later versions of Python (2.6), inserting Unicode is very simple, e.g.: # -*-

Re: Corrupted images after attempting to store PNG images as BLOBs in MySQL?

2008-08-13 Thread Keith Hughitt
Thanks Fredrik. That certainly explains things :) I also appreciate the suggestion on coding guidelines: I'm still becoming familiar with python. Originally we were not using the database to store images, but we started testing out storing images there as well as meta-data. We may end up switching

Corrupted images after attempting to store PNG images as BLOBs in MySQL?

2008-08-13 Thread Keith Hughitt
Hi all, I've run into a strange error while trying to store some PNG images in a MySQL database using MySQLdb. When I try to insert smaller images (< 64kb or so) everything seems to work fine. When I start trying to insert larger images (~150kb), however, the images get corrupted along the way. T

Re: Converting from local -> UTC

2008-07-16 Thread Keith Hughitt
Thanks Gabriel! That helps clear things up for me. The above method works very well. I only have one remaining question: How can I pass a datetime object to MySQL?' So far, what I've been doing is building the query as a string, for example: query = "INSERT INTO image VALUES(%d, %d, %s, '%s')" %

Re: Angle brackets in command-line arguments?

2008-07-16 Thread Keith Hughitt
On Jul 16, 11:16 am, Gary Herron <[EMAIL PROTECTED]> wrote: > Keith Hughitt wrote: > > Hi all, > > > I am using someone else's script which expects input in the form of: > > >      ./script.py arg2 > > > I was wondering if the angle-brackets here hav

Angle brackets in command-line arguments?

2008-07-16 Thread Keith Hughitt
Hi all, I am using someone else's script which expects input in the form of: ./script.py arg2 I was wondering if the angle-brackets here have a special meaning? It seems like they specify an input and output stream to use in place of the console. I could not find anything in the python man

Re: Converting from local -> UTC

2008-07-14 Thread Keith Hughitt
On Jul 12, 12:52 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Fri, 11 Jul 2008 15:42:37 -0300, Keith Hughitt   > <[EMAIL PROTECTED]> escribi�: > > > I am having a little trouble figuring out how to convert a python > > datetime to UTC. I ha

Converting from local -> UTC

2008-07-11 Thread Keith Hughitt
Hi, I am having a little trouble figuring out how to convert a python datetime to UTC. I have a UTC date (e.g. 2008-07-11 00:00:00). I would like to create a UTC date so that when I send it to MySQL (which treats all dates at local dates by default), it will already have incorporated the proper UT

Re: Allow tab completion when inputing filepath?

2008-07-09 Thread Keith Hughitt
On Jul 9, 10:18 am, Tim Golden <[EMAIL PROTECTED]> wrote: > Keith Hughitt wrote: > > I've been looking around on the web for a way to do this, but so far > > have not come across anything for this particular application. I have > > found some ways to enable ta

Allow tab completion when inputing filepath?

2008-07-09 Thread Keith Hughitt
Hi all, I've been looking around on the web for a way to do this, but so far have not come across anything for this particular application. I have found some ways to enable tab completion for program-related commands, but not for system filepaths. This would be nice to have when prompting the user