Re: Anyone use GD with pyhton?

2006-12-08 Thread Jonathan Curran
On Friday 08 December 2006 16:17, jeff wrote:
> could somebody explain to me how to install (or compile) GD for linux,
> so that it works in pyhton?

Jefff, the gd-library's website is at http://www.boutell.com/gd/ and they have 
a link there for download as well. It is highly likely that your linux 
distribution already has a gd library package ready to install. Use your 
package manager to search for 'gd' and you should get something.

Now that you have that installed, you will need to get the python binding to 
it. A quick google search revealed gdmodule @ 
http://newcenturycomputers.net/projects/gdmodule.html

Hope this helps,

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


Re: How to create a global hotkey?

2006-12-08 Thread Jonathan Curran
On Thursday 07 December 2006 05:53, [EMAIL PROTECTED] wrote:
> I want to make a Python app that runs in the background, and when a
> user hits a key combination, for a function to run. This sounds simple
> enough, but all of the keypress detecting libraries I can find count on
> you creating a window and then detecting keypresses while that window
> has focus. I want my function to execute when the user presses the
> hotkey anywhere. I searched the PyGTK documentation and found an old
> newsgroup post where someone mentioned the C GTK+ library has it but
> PyGTK does not, PyQT showed no results, not sure where else I should
> look. I'd be willing to use a library that isn't a windowing toolkit --
> I just want to be able to be able to globally detect a keypress. Any
> ideas?

A little bit of googling revealed:

XGrabKey: http://tronche.com/gui/x/xlib/input/XGrabKey.html
Example: http://tigerdyr.wheel.dk/ctwm-archive/1328.html

It's done here in C, hopefully you can do the same with the python module for 
xlib that was mentioned earlier.

- Jonathan

Google = best friend
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interacting with keyboard LEDs

2006-12-08 Thread Jonathan Curran
On Friday 08 December 2006 23:18, Chris Lasher wrote:
> Is there a way to interact with keyboard LEDs (for Caps/Scroll/Num
> Lock) in Python? I'd like to achieve an effect similar to the *NIX
> command "setleds -L", but I'm not sure where to start, but I figured
> someone out there would have an idea or maybe experience with something
> similar. Thanks very much in advance for your help!
>
> Chris

Spur of the moment answer: call setleds program from within your program

better answer (fox X11): 
http://python-xlib.sourceforge.net/doc/html/python-xlib_16.html

Take a look at get_keyboard_control() and change_keyboard_control(). As far as 
knowing how to properly invoke them, I have no idea, maybe you could google 
for examples or take a look at the setleds source?

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


Re: Interacting with keyboard LEDs

2006-12-09 Thread Jonathan Curran
Chris,
I googled for {xlib caps led} and the first link was to a forum post: 
http://forums.whirlpool.net.au/forum-replies-archive.cfm/619126.html

The third post down, the guy made a program to set the LED of his scroll lock 
key. The C source is at http://members.optusnet.com.au/foonly/hddled.c

If you can manage to convert his code into python w/python-xlib you will be 
set. When you do, e-mail me the snippet will you ;)

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


Re: speed of python vs matlab.

2006-12-13 Thread Jonathan Curran
On Wednesday 13 December 2006 18:07, Chao wrote:
> I've been trying to develop some numerical codes with python, however
> got disappointed.
>
> A very simple test,
>
> a = 1.0
>
> for i in range(1000):
>  for j in range(1000):
>a = a+1
>
> unfortunately, it took 4.5 seconds to finish(my machines is fine. P4
> 3.0G, 1G RAM, it varies according to machine configuration, but should
> be in the same level)
>
> for matlab, the same operation took 0.1 seconds,
>
> I use numpy & scipy, they solve the problem most of the times, but
> there are cases you can't avoid loops by vectors. I appreciate the
> elegancy of python so much, but I guess I have to gave it up in these
> numerical codes.(image processing algorithms),  for application
> dev/scripting, it's still my first choice.
>
> A good news is that the same code takes ruby 9.8 seconds.

[EMAIL PROTECTED] ~]$ time python foo # where foo contained your exact code

real0m0.469s
user0m0.443s
sys 0m0.017s

4.5 seconds? ouch. I've got somewhere near 1 second. Something sounds a little 
fishy b/c my machine is an AMD 3200+ (2.2GHz) w/ 1GB RAM. Yours is a lot 
faster in terms of clock speed.

Anyway, do take a look at some of the available python compilers. They should 
help considerably.

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


Re: Strange return value from SOAP call

2006-12-14 Thread Jonathan Curran
Toby,
Strange stuff, I just tried it out myself and got flattened lists for both 
examples that you pasted. Maybe the answer to this could lie in the 
documentation provided in the source of SOAPpy: simpleTypes.txt & 
complexTypes.txt

There are a few examples in there that show how to serve/retrieve actual data 
structures. I don't know all the details but SOAPpy is an incomplete library 
from what I've read. It works for me though (for now anyway) b/c I only use 
simple single dimensioned arrays.

Let me know if you make any progress.

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

Re: Writing and reading variables to/from flat file

2006-12-14 Thread Jonathan Curran
On Thursday 14 December 2006 09:31, Kevin Walzer wrote:
> I want to write some variables (user preferences, specifically) to a
> text file and then read the values from that file.
>
> Here is my code to write the data:
>
> verbosemodes= """
> Detailed = "-vv"
> Basic = "-q"
> """
>
> file = open('prefs', 'w')
>
> file.writelines(verbosemodes)
>
> file.close()
>
> And here is my code, in a separate module, to read the file and display
> the variable values:
>
> readfile = open('prefs').readlines()
>
> for line in readfile:
>   print line
>
> print Basic
>
>
> Running the second module yields this error:
>
> Detailed = "-vv"
>
> Basic = "-q"
>
>
> Traceback (most recent call last):
>   File "readprefs.py", line 6, in 
> print Basic
> NameError: name 'Basic' is not defined
>
> Clearly the data is getting read (the lines are being printed), but the
> variable itself ("Basic") is not being initialized properly. I'm not
> sure what I'm doing wrong here--can anyone point me in the right
> direction?  Thanks.
>
> --
> Kevin Walzer
> Code by Kevin
> http://www.codebykevin.com

I'm surprised that no one has mentioned the wonderful ConfigParser class. 
Documentation is @ http://docs.python.org/lib/module-ConfigParser.html

Straight to the point example @ 
http://mail.python.org/pipermail/tutor/2001-November/010066.html

This way you can focus on your application instead of dealing with trivial 
things such as saving/loading data :)

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


Re: connecting webservers through HTTP port using python

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 06:28, pradeep kumar wrote:
> hii iam working on socket programming,
> i've to connect webservers through HTTP port and send/receive data..
> so currently i'm installed apache server and trying to connect that server
> using python.
> so any tell me how to connect the apache server by python code.
> give suggestions..

Pradeep, first of all you might want to formulate your sentences properly so 
that it is understandable by the people who read it. Secondly, take the time 
to describe what your question/goal is.

>From what I've read & possibly misunderstood, it seems that you want to be 
able to retreive data from a web page. If so you might want to glance at 
http://diveintopython.org/http_web_services/ and also take a look at the SGML 
section that is mentioned earlier on in the book.

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


Re: Windows Authetication vs seperate process

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 10:24, [EMAIL PROTECTED] wrote:
> I was wondering of someone could steer me in the right direction.
>
> We have a package that we would like to "secure" so that only specific
> individuals can access specific portions of the application.  Our
> wxPython application will revolve around updating a central database
> with information submitted from the app.  We will eventually have a web
> front end fo rsome aspects of the app.
>
> With several packages I have seen options to "Use Windows
> Authentication", which seems to mean that "If the user has
> authenticated and signed onto Windows, then our application will use
> their windows userid and we will just focus on the the tasks within our
> application the user is authorized to perform"
>
> Does anyone have any experience using this type of authentication
> scheme ?
>
> Any related tips or suggestions ?
>
> I have found a few wikipedia entries, but they seem to be more related
> to webpages, etc.
>
> Thanks.

Using windows authentication IMHO should only be used if there is an Active 
Directory/LDAP server set up against which the users are authenticated. I 
googled for 'active directory python' and came across 
http://tgolden.sc.sabren.com/python/ad_cookbook.html It seems to be very 
simple to use.

If I were to implement an authentication system like you want. I would:
1. Check to see if the local machine was part of a domain. If not then inform 
the user that they need to be.
2. Check to see if the user who ran the application is part of a specific 
group in AD.

I would assign each group a certain 'level' of privilege and accordingly let 
the user do what they should be able to do.

I hope this is a good starting point.

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


Re: Is there any python-twisted tutorial or texts?

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 20:45, Jia Lu wrote:
> Hi all
>  I want to study twisted of python . But I donot know how to start.
>  Any suggistions?
>
>  Thank you

There is a book about using Twisted. It's called 'Twisted Network Programming 
Essentials.' It is an entry-level book at best, but it does go over quite a 
lot of things that the Twisted library is capable of.

Available at amazon.com: 
http://www.amazon.com/Twisted-Network-Programming-Essentials-Fettig/dp/0596100329/sr=8-1/qid=1166501681/ref=sr_1_1/102-5086830-3709707?ie=UTF8&s=books

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


Re: regexp

2006-12-19 Thread Jonathan Curran
On Tuesday 19 December 2006 13:15, vertigo wrote:
> Hello
>
> I need to use some regular expressions for more than one line.
> And i would like to use some modificators like: /m or /s in perl.
> For example:
> re.sub(".*","",data)
>
> will not cut out all javascript code if it's spread on many lines.
> I could use something like /s from perl which treats . as all signs
> (including new line). How can i do that ?
>
> Maybe there is other way to achieve the same results ?
>
> Thanx

Take a look at Chapter 8 of 'Dive Into Python.' 
http://diveintopython.org/toc/index.html

You can modify the code there and get the results that you need. Buy the book 
if you can :) It has lots of neat examples.

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


Re: regexp

2006-12-19 Thread Jonathan Curran
On Tuesday 19 December 2006 15:32, Paul Arthur wrote:
> On 2006-12-19, vertigo <[EMAIL PROTECTED]> wrote:
> > Hello
> >
> >> Take a look at Chapter 8 of 'Dive Into Python.'
> >> http://diveintopython.org/toc/index.html
> >
> > i read whole regexp chapter -
>
> Did you read Chapter 8?  Regexes are 7; 8 is about processing HTML.
> Regexes are not well suited to this type of processing.
>
> > but there was no solution for my problem.
> > Example:
> >
> > re.sub("","",htmldata)
> > would remove only comments which are in one line.
> > If comment is in many lines like this:
> >
> >
> > it would not work. It's because '.' sign does not matches '\n' sign.
> >
> > Does anybody knows solution for this particular problem ?
>
> Yes.  Use DOTALL mode.

Paul, I mentioned Chapter 8 so that the HTML processing section would be taken 
a look at. What Vertigo wants can be done with relative ease with SGMLlib.

Anyway, if you (Vertigo) want to use regular expressions to do this, you can 
try and use some regular expression testing programs. I'm not quite sure of 
the name but there is one that comes with KDE.

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


Re: Website Capture

2006-12-24 Thread Jonathan Curran
On Monday 25 December 2006 00:57, [EMAIL PROTECTED] wrote:
> Hi,
>
> I want to capture a web site into gif image using Python.
> I installed the PIL if it can help.

It can't be done with just Python & PIL, that much is for sure. First of all 
you need some sort of module/program/(whatever you want to call it) that can 
render a given webpage. Then you would proceed to capturing the graphical 
output of that module/program/...

Maybe what you should look into are graphical toolkits that possibly provide a 
HTML widget from which you can get a graphical display. WxWidgets/WxPython is 
one option, and the only other I can think of is GTK/pyGTK.

I hope this helps a little, and Merry Christmas!

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


Re: python, zlib, and fedora 64bits

2007-01-06 Thread Jonathan Curran
On Saturday 06 January 2007 03:47, Tarek Ziadé wrote:
> Hello,
>
> I am trying to compile Python on a Fedora 64bits, and I can't make zlib
> work.
>
> a python setup.py build leads to :
>
> ...
> building 'zlib' extension
> gcc -pthread -shared
> build/temp.linux-x86_64-2.4/usr/local/src/Python-2.4.4/Modules/zlibmodule.o
> -L/opt/python-2.4.4/lib -L/usr/local/lib -lz -o build/lib.linux-x86_64-2.4
> /zlib.so
> /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against
> `a local symbol' can not be used when making a shared object; recompile
> with -fPIC
> /usr/local/lib/libz.a: could not read symbols: Bad value
> collect2: ld gab 1 als Ende-Status zurück
> running build_scripts
> running install_lib
> ...
>
> I've tried to recompile zlib, but didn't find any way to avoid this error
>
> any ideas ?
>
> Otherwise, does anyone has a zlib.so for fedora 64bits to send me ?
>
> Thx
>
> Tarek

Tarek, I would first check and see if fedora offers python for a 64-bit 
environment. If so, it would be easier to get python up and running quickly. 
I haven't used any redhat deviant in a while, but I think the command should 
be: yum search python. This should bring up a list of packages that are 
installable. The rest should be simple as: yum install . I hope 
this helps.

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

Re: Traceback of hanged process

2007-01-06 Thread Jonathan Curran
On Saturday 06 January 2007 16:45, Hynek Hanke wrote:
> Hello,
>
> please, how do I create a pythonic traceback from a python process that
> hangs and is not running in an interpreter that I executed manually
> or it is but doesn't react on CTRL-C etc? I'm trying to debug a server
> implemented in Python, so I need some analog of 'gdb attach' for C.
>
> Unfortunatelly, googling and reading documentation revealed nothing, so
> please excuse if this question is dumb.
>
> Thank you,
> Hynek Hanke

Hynek,
It is possible to redirect stderr to a file so that in case of a crash 
or 
fault the errors will be logged to a file. I think the following code would 
do it.

import sys

log_file = open('errors.log', 'w')
sys.stderr = open('errors.log', 'w')



log_file.close()

Hope it helps.

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


Re: Traceback of hanged process

2007-01-06 Thread Jonathan Curran
Heh, I kinda messed up the code there. It should be:

import sys

log_file = open('errors.log', 'w')
sys.stderr = log_file



log_file.close()

As for the Ctrl-C, you can catch that when KeyboardInterrupt exception is 
raised.

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


Re: spidering script

2007-01-18 Thread Jonathan Curran
On Thursday 18 January 2007 11:57, David Waizer wrote:
> Hello..
>
> I'm  looking for a script (perl, python, sh...)or program (such as wget)
> that will help me get a list of ALL the links on a website.
>
> For example ./magicscript.pl www.yahoo.com and outputs it to a file, it
> would be kind of like a spidering software..
>
> Any suggestions would be appreciated.
>
> David

David, this is a touchy topic but whatever :P Look into sgmllib, and you can 
filter on the "A" tag. The book 'Dive Into Python' covers it quite nicely: 
http://www.diveintopython.org/html_processing/index.html

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


Re: Data structure and algorithms

2007-01-28 Thread Jonathan Curran
What are you trying to make in the first place? A singly linked list? If so 
google is littered with examples of linked lists done in python. A simple 
search for 'python linked list' brings up many results.

Btw, for future reference, no need for apologetics (the second post).

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


Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan,
The DOM (Document Object Model) is such that it loads all the elements 
of the 
XML document into memory before you can do anything with it. With your file 
containing millions of child nodes this will eat up as much memory as you 
have. A solution to this is to use the SAX method of parsing XML documents 
and working on it. SAX is such that it only reads the XML doc. a node (or a 
few nodes) at a time.

Unfortunately, the use of DOM or SAX completely depends on what kind of 
processing you need to be done on the XML document. If it is editing a record 
at a time (from what I've gathered from your code) it would be wise to use 
SAX. I highly suggest looking into this method of processing.

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


Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan,
I jumped the gun and didn't read your entire post. I ended up skipping 
a lot 
of parts, especially where you say that you are creating a document (for some 
reason I thought you were reading it). I looked at the setAttribute function 
and thought: ah he's writing it out.
Sorry about all that. I'd still ask you to look into SAX though :) 
Especially 
when dealing with really large XML documents, whether it be reading or 
writing them.

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


Re: xml.dom.minidom memory usage

2007-02-01 Thread Jonathan Curran
Dan,
Take a look at http://www.xml.com/pub/a/2003/03/12/py-xml.html. It's a 
starting point to output XML data via use of SAX. Bruno also mentioned 
Genshi. I haven't used Genshi myself, but it'd be worth it to take a look at 
what it has to offer.

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


Re: Spring Python 0.2.0 is released

2007-02-02 Thread Jonathan Curran
Greg,
You have managed to peak my interest. I'll be dabbling with this in the 
next 
few hours. This looks very promising, keep up the good work.

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


Re: Where Does One Begin?

2007-02-02 Thread Jonathan Curran
Hey n00b :)

If you want to start 2d game programming w/python, I would look at the package 
pygame. There are some intro. tutorials at 
http://www.pygame.org/wiki/tutorials. These should give you a head start. 
Besides that, I suggest you scour the web via google to look at the source of 
simple 2d games to learn more.

Good places to look at: gamedev.net, allegro.cc, amit's game programming 
information

Good luck!

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


Re: Can a jet fuel/hydrocarbon fire collapse a steel structure? An experiment.

2007-02-03 Thread Jonathan Curran
I've been seeing this topic for a day or two so far. Why don't we stick to 
discussing python on this mailing list? I'm sure there are other mailing 
lists specifically for discussing chemistry. =\

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


Re: "President Bush ... you are under arrest" - 911 truth video by Dr Morgan Reynolds, Former Chief Economist under Bush

2007-02-03 Thread Jonathan Curran
dude, please go spam elsewhere. don't post unrelated material here.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: It is good to blow up a marketplace full of people buying and selling food

2007-02-04 Thread Jonathan Curran
Frank,
Could you please try and stick to discussing python related subjects on 
this 
mailing list?

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


Re:

2007-02-05 Thread Jonathan Curran
On Monday 05 February 2007 10:07, Zahid Ahmadzai wrote:
> HI THERE
>
> I NEED HELP WITH THE FOLLOWING EXERSISE CAN YOU PLEASE HELP IF YOU CAN.
>
> PLEASE SEND ME THE CODE ON E-MAIL
>
> MANY THANKS
>
>

Quick, everyone, send him the solution to his homework problem!

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


Re: Will Python Run On Microsoft Vista?

2007-02-05 Thread Jonathan Curran
On Monday 05 February 2007 11:08, slogging_away wrote:
> I know, I know - flame away but its not clear to me if Python will run
> on a system running Microsoft Vista.  Is anyone successfully running
> Python on Vista?  If so, is it what version of Python are you
> running?  I'm ordering a new system and if Python won't work on Vista
> then it will definately influence the OS selection.
>
> Thanks in advance!

I don't see why Python wouldn't work. The 2.5 version clearly has a version 
for Vista albeit its the x64 Edition. If you downloaded the regular version 
(x86) then I assume it would work just fine. D/L an evaluation copy of Vista 
and try it yourself.

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


Re: Pyhton script

2007-02-11 Thread Jonathan Curran
On Sunday 11 February 2007 11:47, soussou97 wrote:
> Hi;
>
> I would like to automatically delivery, I seek a script in python which
> will be excecute from a Windows station to allows via sftp:
>
> 1- to connect to a Linux server for storing of the files
> 2- Next execute on the Linux server, some actions: Copy, gzip, mv etc...
> 3- to use a config file for the parameters: server name, login, password...
>
> Regards;
> --
> View this message in context:
> http://www.nabble.com/Pyhton-script-tf3209528.html#a8912801 Sent from the
> Python - python-list mailing list archive at Nabble.com.

How much are you willing to spend on this script? ;-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pyhton script

2007-02-11 Thread Jonathan Curran
On Sunday 11 February 2007 11:47, soussou97 wrote:
> Hi;
>
> I would like to automatically delivery, I seek a script in python which
> will be excecute from a Windows station to allows via sftp:
>
> 1- to connect to a Linux server for storing of the files
> 2- Next execute on the Linux server, some actions: Copy, gzip, mv etc...
> 3- to use a config file for the parameters: server name, login, password...
>
> Regards;
> --
> View this message in context:
> http://www.nabble.com/Pyhton-script-tf3209528.html#a8912801 Sent from the
> Python - python-list mailing list archive at Nabble.com.

Just joking with the last message, though I hope that you weren't looking for 
someone to just send it to you. Take a look at Paramiko, it's exactly the 
library you need to do these things.

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


Re: help please!!

2007-02-11 Thread Jonathan Curran
On Sunday 11 February 2007 13:40, darren112 wrote:
> Hi Im new to python and I desperately need help with this task
> This is everything of what I need to do...
>
> The program to be written in Python obviously..
>
> The program should support brute-forcing of the authentication process
> for a Telnet server via a dictionary attack.
>
> The python program is required to take four parameters: a) the IP
> address of a Computer, b) the port number that the Telnet server is
> running on the computer , c) the name of a file containing a list if
> usernames, and b) the name of a file containing a list of word/phrases
> to be used as passwords.
>
> The program should then attempt to authenticate itself to the Telnet
> server via trying every password for every username. The program
> should report when it is successful.
>
> Please help me And as I am new to all this please post step by
> step instructions...

/me points and laughs at you. Hahahahaha, stupid script kiddie. Get a life.
-- 
http://mail.python.org/mailman/listinfo/python-list


message processing/threads

2007-02-11 Thread Jonathan Curran
I've been thinking about this for a bit and wanted some input as to the design 
of it. The problem is as such:

I need a program running in the background to process messages (FIFO order) 
which I would send using soap/xmlrpc/pyro (haven't decided yet). According to 
my thinking I would need to make this a threaded application. One thread to 
process the messages and the other thread(s) would be used to listen for 
messages and insert it into the message queue.

Is my thinking correct? Is there a better way to do such a thing?

Thanks for any input,

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