Convert hexadecimal characters to ascii

2008-11-29 Thread Durand
Hi,

I've got this weird problem where in some strings, parts of the string are in 
hexadecimal, or thats what I think they are. I'm not exactly sure...I get 
something like this: 's\x08 \x08Test!' from parsing a log file. From what I 
found on the internet, x08 is the backspace character but I'm still not sure.
Anyway, I need to clean up this string to get rid of any hexadecimal characters 
so that it just looks like 'Test!'. Are there any functions to do this?

Thanks =)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Convert hexadecimal characters to ascii

2008-11-29 Thread Durand
Wow, I didn't expect so many responses! Thanks! I will have to try out all
those solutions when I have access to my computer.. What I meant was that
when the string was printed onto a text file, it showed lots of boxes that
are usually associated with unknown characters...When I tried to work out
what the boxes were caused by, I found that there were random characters in
my text...So basically, I need the text to just be clean of anything silly
looking and for some reason printing to a file doesn't remove the characters
which really messed up the output.

This is an example of what I get: http://durand.zephyrhosting.net/tremcs/
Look at the top of the page under "Stats for..." The really weird thing is
that it only happens with some strings and I have no idea how to predict
which ones.

Thanks again! I will let you know of the outcomes.
--
http://mail.python.org/mailman/listinfo/python-list


PIL: Transparent PNGs and im.paste: ValueError: bad transparency mask

2008-07-10 Thread Durand
Hi!

I'm trying to paste a png with a transparent layer into an image using 
"image.paste(tesla,(20,10), tesla)" but I'm getting this error:

ValueError: bad transparency mask

I have used im.paste(image,box,image) sucessfully before to paste an image with 
transparency, however, it doesn't seem to work for this particular image. How 
would I change the image so that it doesn't give me this error?

The image is http://img293.imageshack.us/img293/1434/teslahv5.png

Thanks in advance!
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL: Transparent PNGs and im.paste: ValueError: bad transparency mask

2008-07-10 Thread Durand
I posted this too soon. Converting the images to png with image magick's 
convert did the trick...However, I'm still not sure why I need to convert the 
images in the first place. Are there different types of PNGs?
--
http://mail.python.org/mailman/listinfo/python-list


matplotlib: Plotting a graph against time

2008-07-19 Thread Durand
Hi,

I'm trying to plot a simple graph against date or time using matplotlib. I've 
read about date_plot but I'm not really sure how to use it. At the moment, I 
have some data arranged into lists, where list1 contains x values (time) and 
list2 contains y values just like is needed for the normal plot function. The 
time values are simply the output of datetime.date.today(), etc which I don't 
mind changing the format of.

My question is, how do I plot the graph with list1 on the x axis and list2 on 
the y axis. Using plot and unixtime I get a very ugly scale as is to be 
expected so I want to know how to use the date_plot function efficiently. At 
the moment, I'm only concerned about the actual plotting but help with Locater 
Ticks (Months and Years) is also very appreciated.

Thanks a lot!
--
http://mail.python.org/mailman/listinfo/python-list


Re: matplotlib: Plotting a graph against time

2008-07-20 Thread Durand
On Jul 20, 8:55 am, arsyed <[EMAIL PROTECTED]> wrote:
> On Jul 19, 3:09 pm, Durand <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I'm trying to plot a simple graph against date or time using matplotlib. 
> > I've read about date_plot but I'm not really sure how to use it. At the 
> > moment, I have some data arranged into lists, where list1 contains x values 
> > (time) and list2 contains y values just like is needed for the normal plot 
> > function. The time values are simply the output of datetime.date.today(), 
> > etc which I don't mind changing the format of.
>
> > My question is, how do I plot the graph with list1 on the x axis and list2 
> > on the y axis. Using plot and unixtime I get a very ugly scale as is to be 
> > expected so I want to know how to use the date_plot function efficiently. 
> > At the moment, I'm only concerned about the actual plotting but help with 
> > Locater Ticks (Months and Years) is also very appreciated.
>
> > Thanks a lot!
>
> I'm not sure if this is what you're looking for, but here's a quick
> sample that uses plot_date to plot some random values.
>
> import pylab, random
> from datetime import datetime, timedelta
>
> today = datetime.now()
>
> dates = [today + timedelta(days=i) for i in range(10)]
> values = [random.randint(1, 20) for i in range(10)]
> pylab.plot_date(pylab.date2num(dates), values, linestyle='-')

Oooh, this is almost what I want but I'm not really sure how I'd
incorporate this into real dates...
If I have a list of dates like ['2008-07-18 14:36:53.494013',
'2008-07-20 14:37:01.508990', '2008-07-28 14:49:26.183256'], how would
I convert it to a format that pylab can understand? When I tried
type(datetime.now()) it gave me datetime.datetime whereas the objects
in this list are strings...Am I doing something wrong here?
--
http://mail.python.org/mailman/listinfo/python-list


[PIL] quake like multicoloured text

2008-09-05 Thread Durand
I'm wondering how I could render text with PIL in which different
parts of the text are different characters. This is for a game stats
script where names are written like:
^1Red ^2Green ^3Yellow, etc.
The problem is that I currently use text in the ImageDraw module but
the only way I can think of rendering text is by rendering each bit of
text in a separate colour.

Example:

draw.text((0,0),"Red", fill="red")
draw.text((30,0),"Green", fill="green")
draw.text((60,0),"Yellow", fill="green")

except that I'm not sure how much spacing there is between each
coloured bit of text(30px is assumed in the example)...Would there be
an alternate method of doing this?

Thanks =)
--
http://mail.python.org/mailman/listinfo/python-list


Re: quake like multicoloured text

2008-09-05 Thread Durand
Oops, I meant, "I'm wondering how I could render text with PIL in
which different
parts of the text are different *colours*."
--
http://mail.python.org/mailman/listinfo/python-list


Re: quake like multicoloured text

2008-09-06 Thread Durand
On Sep 5, 10:32 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Fri, 05 Sep 2008 16:24:08 -0300, Durand <[EMAIL PROTECTED]> escribió:
>
>
>
>
>
> > I'm wondering how I could render text with PIL in which different
> > parts of the text are different characters. This is for a game stats
> > script where names are written like:
> > ^1Red ^2Green ^3Yellow, etc.
> > The problem is that I currently use text in the ImageDraw module but
> > the only way I can think of rendering text is by rendering each bit of
> > text in a separate colour.
>
> > Example:
>
> > draw.text((0,0),"Red", fill="red")
> > draw.text((30,0),"Green", fill="green")
> > draw.text((60,0),"Yellow", fill="green")
>
> > except that I'm not sure how much spacing there is between each
> > coloured bit of text(30px is assumed in the example)...Would there be
> > an alternate method of doing this?
>
> You could use the draw.textsize method to measure how much space will take  
> each part...
>
> --
> Gabriel Genellina

Thanks, I guess I should have done more research...
--
http://mail.python.org/mailman/listinfo/python-list


[matplotlib] Overlapping axis text

2008-09-06 Thread Durand
I got a really annoying problem with datetime graphs. The problem is
that with a long range time graph, the text on the x axis keeps
overlapping like here: http://durand.zephyrhosting.net/tremcs/graph_all.png

Would there be any way to fix this? I was thinking of rotating the
text so that there was enough space for each one but the best solution
would be to only display text with the right scale. IE, with a 7 day
graph, each day would have text, with a year long graph, each month
would be displayed, etc...

This is the code I use at the moment but its pretty messy:

import dateutil,pylab
from matplotlib.dates import MonthLocator, WeekdayLocator

fig = pylab.figure()
ax = fig.add_subplot(111)
days= MonthLocator()   # every monday
months   = MonthLocator()  # every month
ax.xaxis.set_major_locator(months)
ax.xaxis.set_minor_locator(days)

pylab.plot_date(pylab.date2num(dates), allkills, '.-', color='blue')
pylab.plot_date(pylab.date2num(dates), alldeaths, '.-',
color='red')
pylab.plot_date(pylab.date2num(dates), kills, '.-',
color='darkgreen')
pylab.plot_date(pylab.date2num(dates), deaths, '.-',
color='orange')
if legend == 1:
pylab.legend(("Total Kills","Total Deaths", "Single
Session Kills", "Single Session Deaths"), 'lower left')
pylab.xlabel('Date')
pylab.ylabel('Stats')
ax2 = pylab.twinx()
pylab.plot_date(pylab.date2num(dates), allratio, '.-',
color='purple')
pylab.plot_date(pylab.date2num(dates), ratio, '.-',
color='yellow')
pylab.ylabel('Ratio')
ax2.yaxis.tick_right()
pylab.show()
Please excuse the extra tabbing, it's part of an if statement.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Overlapping axis text

2008-09-06 Thread Durand
Err...made a mistake there.

days= WeekdayLocator()   # every monday
months   = MonthLocator()  # every month

That doesn't change my question though.

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


Re: Python & Oracle

2007-03-14 Thread Jean-Philippe Durand
So do I !

2007/3/14, Josh Bloom <[EMAIL PROTECTED]>:
> I would suggest using cx_Oracle as I have had good experience with it.
> http://www.cxtools.net/default.aspx?nav=cxorlb
>
> -Josh
>
>
> On 3/14/07, Facundo Batista <[EMAIL PROTECTED]> wrote:
> > Hi! I need to connect to Oracle.
> >
> > I found this binding,
> >
> >   http://www.zope.org/Members/matt/dco2
> >
> > that is the recommended in the Python page.
> >
> > But that page seems a bit confuse to me. In the upper right corner says
> > that the last release is PreRelease 1, from 2001-11-15.
> >
> > At the bottom, however, it says that 1.3 beta was released 2003-02-10,
> > and is a development version (the last stable is 1.2, from 2002-10-02),
> > four and a half years ago.
> >
> > The question is: is this connector the recommended one? it's aged
> > because it's stable and no more changes are necessary, or it just dead?
> > Works Ok?
> >
> > Thank you!! Regards,
> >
> > --
> > .   Facundo
> > .
> > Blog: http://www.taniquetil.com.ar/plog/
> > PyAr: http://www.python.org/ar/
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list