Sys.exit() does not fully exit
I have this script: import os, thread, threading, time, sys class Script1(threading.Thread): def run(self): os.system('runScript1.py') class Script2(threading.Thread): def run(self): os.system('runScript2.py') if __name__ == '__main__': s = Script1() s.start() time.sleep(5) a = Script2() a.start() time.sleep(5) while True: answer = raw_input('Type x to shutdown: ') if answer == 'x': print 'Shutting down' time.sleep(1) print 'Done' sys.exit(0) When x is typed, everything does shut down but the main script never fully ends. Is there any way to get it to quit? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Pull Last 3 Months
Is there a module that can pull str values for say the last 3 months? Something like: print lastMonths(3) ['Sep', 'Aug', 'Jul'] Thanks -- http://mail.python.org/mailman/listinfo/python-list
Pull Last 3 Months
Is there a module that can pull str values for say the last 3 months? Something like: print lastMonths(3) ['Sep', 'Aug', 'Jul'] Thanks -- http://mail.python.org/mailman/listinfo/python-list
Decimal formatting
Cant believe I have to post this and get help... and can't believe I couldnt Google it reasonably well enough... I need to take a float variable and have it display as a string to always have two decimal places: 12. - 12.33 1.0 - 1.00 etc... Anyone willing to help with this one? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: How to create a single executable of a Python program
On Jul 25, 6:19 am, Graeme Glass [EMAIL PROTECTED] wrote: On Jul 25, 8:34 am, NicolasG [EMAIL PROTECTED] wrote: Dear fellows, I'm trying to create a executable file using py2exe . Unfortunately along with the python executable file it also creates some other files that are needed in order to the executable be able to run in a system that doesn't have Python installed. Can some one guide me on how can I merge all this files created by py2exe in a single exe file ? If I have a python program that uses an image file I don't want this image file to be exposed in the folder but only to be accessible through the program flow.. Regards, Nicolas. Have you taken a look at cx_Freeze? (http://python.net/crew/atuining/ cx_Freeze/)http://www.velocityreviews.com/forums/t354325-singlefile-executables If you're using py2exe (I'm assuming Win32 platform here), you can do this but you'll have to read the documentation on how to include the library.zip file into the exe. Also there are different levels where the .exe file will include the .pyd files. Unfortunately though, you will likely encounter errors doing it the more you try to condense. If you can solve this problem, heck tell the guys at py2exe ;-) they have been trying to solve this issue for some time now. If you're doing it with Linux/Unix, cx_freeze is the only way i know to get this done and even then it may have the same limitations. If you're trying to hide/proprietize code, you may want to use pyobfuscate. Good Luck Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Python ODBC
Is there a Python odbc module that will work on Linux? I have a jdbc connection to a DB2 server. I am looking hopefully for an open source solution and not a commercial one. Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Lame wrapper for Python
Is there any type of lame_enc.dll wrapper for Python that's available? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Catching an unknown error
Using the code below: ---BEGIN CODE--- value = raw_input(Type a divisor: ) try: value = int(value) print 42 / %d = %d % (value, 42/value) except ValueError: print I can't convert the value to an integer except ZeroDivisionError: print Your value should not be zero except: print Something unexpected happened ---END CODE--- In the last 'except' block, how can I print out the particular error name even though one is not specifically named? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching an unknown error
On Mar 23, 9:42 am, [EMAIL PROTECTED] wrote: On Mar 23, 8:16 am, Harlin Seritt [EMAIL PROTECTED] wrote: Using the code below: ---BEGIN CODE--- value = raw_input(Type a divisor: ) try: value = int(value) print 42 / %d = %d % (value, 42/value) except ValueError: print I can't convert the value to an integer except ZeroDivisionError: print Your value should not be zero except: print Something unexpected happened ---END CODE--- In the last 'except' block, how can I print out the particular error name even though one is not specifically named? Thanks, Harlin Thanks for pointing that out. I was following logic I was taught in Hetland's book, which supposedly was up-to-date for Python 2.4. Typical textbook error. Mike Thanks guys... that gets 'er done. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Convert to binary and convert back to strings
Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I'd also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks! Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert to binary and convert back to strings
On Feb 21, 7:02 pm, Colin J. Williams [EMAIL PROTECTED] wrote: Harlin Seritt wrote: Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I'd also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks! Harlin Try opening your file in the 'wb' mode. Colin W. Thanks for the help. I tried doing this: text = 'supercalifragilisticexpialidocius' open('sambleb.conf', 'wb').write(text) Afterwards, I was able to successfully open the file with a text editor and it showed: 'supercalifragilisticexpialidocius' I am hoping to have it show up some weird un-readable text. And then of course be able to convert it right back to a string. Is this even possible? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Convert to binary and convert back to strings
On Feb 21, 7:12 pm, Larry Bates [EMAIL PROTECTED] wrote: Harlin Seritt wrote: Hi... I would like to take a string like 'supercalifragilisticexpialidocius' and write it to a file in binary forms -- this way a user cannot read the string in case they were try to open in something like ascii text editor. I'd also like to be able to read the binary formed data back into string format so that it shows the original value. Is there any way to do this in Python? Thanks! Harlin I promise you that everything written to a file is done in binary. Computers don't know how to work with anything BUT binary. I think what you want to do is to encrypt/obstifucate the string. For that you will need to encrypt the string, write it out, read it back in, and decrypt it. If you want it to be REALLY strong use pyCrypto and something like AES-256. http://www.amk.ca/python/code/crypto If you just want to make it somewhat hard for someone to decypher you can do something like below (sorry I can't remember where I found this to attribute to someone): import random import zlib import time def tinycode(key, text, reverse=False): rand = random.Random(key).randrange if not reverse: text = zlib.compress(text) text = ''.join([chr(ord(elem)^rand(256)) for elem in text]) if reverse: text = zlib.decompress(text) return text def strToHex(aString): hexlist = [%02X % ord(x) for x in aString] return ''.join(hexlist) def HexTostr(hString): res = for i in range(len(hString)/2): realIdx = i*2 res = res + chr(int(hString[realIdx:realIdx+2],16)) return res if __name__ == __main__: keyStr = This is a key #testStr = which witch had which witches wrist watch abc def ghi testStr=time.strftime(%Y%m%d, time.localtime()) print String:, testStr etestStr = tinycode(keyStr, testStr) print Encrypted string:, etestStr hex=strToHex(etestStr) print Hex: , hex print Len(hex):, len(hex) nonhex=HexTostr(hex) #testStr = tinycode(keyStr, etestStr, reverse=True) testStr = tinycode(keyStr, nonhex, reverse=True) print Decrypted string:, testStr WARNING: THIS IS NOT A STRONG ENCRYPTION ALGORITHM. It is just a nuisance for someone that really wants to decrypt the string. But it might work for your application. -Larry Thanks Larry! I was looking for something more beautiful but what the hey, it works! Harlin -- http://mail.python.org/mailman/listinfo/python-list
Logging errors to a file
Is there any way to automatically log errors that occur within an executed script to a file? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Importing from upper directory
I have a script that I want to import called upper.py. It is 2 directories above the script that will call it - i'll call that one main.py. How am I able to import a script in a directory that is above it? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Getting a class name
Hi, How does one get the name of a class from within the class code? I tried something like this as a guess: self.__name__ Obviously it didn't work. Anyone know how to do that? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: How to determine what exceptions a method might raise?
Hi Ed, Generally checking the sources give a very good clue as to what exceptions the interpreter can raise. Look around _builtins_ for this. Harlin Seritt Ed Jensen wrote: I'm really enjoying using the Python interactive interpreter to learn more about the language. It's fantastic you can get method help right in there as well. It saves a lot of time. With that in mind, is there an easy way in the interactive interpreter to determine which exceptions a method might raise? For example, it would be handy if there was something I could do in the interactive interpreter to make it tell me what exceptions the file method might raise (such as IOError). Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: where is python on linux?
Hi Frank, Usually Python is installed in /usr/lib/python[VER] but you should be able to call up /usr/bin/python without any difficulty. Harlin Seritt Frank Potter wrote: I installed fedora core 6 and it has python installed. But the question is, where is the executable python file? I can't find it so I come here for help. I want to config pydev for eclipse and I need to know where the ececutable python file is. Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Finding web host headers
Is there any way to fetch a website's host/version headers using Python? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Valid SQL?
I have this string that I am sending via a Cursor.execute() using MySQLdb: insert into table Ping82_eb13__elearn__ihost__com (`dateTime`, `values`) values( Fri May 12 11:39:02 2006, 1) Does anyone see anything wrong with this SQL syntax? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Valid SQL?
Thanks for the help. I set up the SQL statement to be like: INSERT INTO tblFoo (field1, field2) VALUES ('value1', 'value2') I get this error: insert into Web1_DLTDS10_RootSite (dateTime, values) values('Sat Apr 15 08:58:13 2006', '0') Traceback (most recent call last): File librarian.py, line 45, in ? Cursor.execute(InsertValuesSQL) File C:\Python24\lib\site-packages\MySQLdb\cursors.py, line 137, in execute self.errorhandler(self, exc, value) File C:\Python24\lib\site-packages\MySQLdb\connections.py, line 33, in defau lterrorhandler raise errorclass, errorvalue _mysql_exceptions.ProgrammingError: (1064, You have an error in your SQL syntax ; check the manual that corresponds to your MySQL server version for the right s yntax to use near 'values) values('Sat Apr 15 08:58:13 2006', '0')' at line 1) Any idea why I'm getting this? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Valid SQL?
I am using the exact same query string generated and it works when i type it in the MySQL client but doesn't work when using the MySQLdb module. :( -- http://mail.python.org/mailman/listinfo/python-list
How to append to a dictionary
I have some code here: groups = {'IRISH' : 'green', 'AMERICAN' : 'blue'} I want to add another key: 'ITALIAN' : 'orange' How do I append this to 'groups'? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Suggestion for Web App
I want to make a recommendation to a group of internal customers where I work concerning a Python web framework. They are seeking to build a portal that can handle around 5000 total users but probably no more than 100-200 simultaneous users. This is supposed to serve mainly static content - the content will hold references, tutorials and examples for different technologies, a forum (similar probably to phpbb) and podcasts (rss and mp3 files). Also I believe it will definitely need a decent DB server for this. They have some other suggestions ranging from Websphere/JSP's to PHP. I personally don't think the PHP will scale well for growth and I also think that using Java/JSPs will be too slow for this sort of thing. I normally work as system and application admin and use Python in a number of ways to get the job done. Naturally, I am naturally inclined to suggest something that uses Python or something Pythonic. I wanted to suggest Zope but there are also other ones I'm thinking of as well like CherryPy and Karrigell. Which one of these (or other ones you guys know of) would do the best job in this situation? Also do you guys know if MySQL would work with this or should they use something more robust like DB2 (IBM shop)? Any suggestions are welcome. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Caching in memory for Apache
Pickle (http://www.network-theory.co.uk/docs/pytut/tut_58.html) comes to mind when anyone mentions wanting to save a value, method, object, etc without writing to storage (file or db). Is it possible for you to post some code? There may be an alternative algorithm so you can avoid writing to memory. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Food for thought... I admit it would be best if you could use the same editor for both *nix and Windows -- in that case, I'd say Scite would be best as it is almost identical in both environments. However, my own personal favorites are: Crimson Editor for Windows and Kate for Linux. Yes, I know... strange choices (especially Kate) but they both do what I need them to do. :-) Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for Web App
Why not just use static HTML for the static content ? Makes sense... now, what about for having the portal capabilities (users log in, save profiles, etc)... what would be best for that? I really don't think though that a CMS is necessary. Does anyone know of a Python forum package similar to phpBB? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: What's The Best Editor for python
Was actually going to throw in jEdit for the category of what's good on both platforms... For someone who despises Java, I actually like it. :-) Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Get Root access in Linux?
sudo is something of a quick fix. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: mascyma
You'll almost certainly need to take a look at mascyma's support facilities: support web page, forum, etc (provided they do indeed exist). Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Python CGI not working in Firefox but does in IE
I have this Python CGI script running: [CODE] print 'Content-type: text/plain\n' location = 'http://server1.com' page = ''' html head meta http-equiv=Refresh content=0; URL='''+location+''' /head body/body /html''' print page [/CODE] It works fine and redirects perfectly when using Internet Explorer but only shows this in a Firefox window: [OUTPUT] html head meta http-equiv=Refresh content=0; URL=http://server1.com; /head /html [/OUTPUT] Is there anything I can do to fix this? Also, is there a redirect command somewhere within Python CGI that can get this done instead as I would actually prefer to have the CGI code execute this rather than depend on the HTML to do it. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Python CGI not working in Firefox but does in IE
Ack... I'm an idiot... Thanks Richard -- You're the Man! -- http://mail.python.org/mailman/listinfo/python-list
FTPlib
Using ftplib from Python I am trying to get all files in a particular directory using ftplib and then send those same files to another ftp server. I have tried using commands like 'get *' and 'mget *' with no success. I am using the following: srcFtp = FTP(srcHost) srcFtp.login(srcUser, srcPass) srcDir = srcFtp.nlst('.') for file in srcDir: print file[2:] srcFtp.transfercmd('get '+file[2:]) I've verified that I do have a connection with the ftp server and the files as 'file[2:]' are indeed the file names. Anyone know why I get the following error? podcast-1.mp3 Traceback (most recent call last): File podsync.py, line 17, in ? srcFtp.transfercmd('get '+file[2:]) File C:\Python24\lib\ftplib.py, line 345, in transfercmd return self.ntransfercmd(cmd, rest)[0] File C:\Python24\lib\ftplib.py, line 327, in ntransfercmd resp = self.sendcmd(cmd) File C:\Python24\lib\ftplib.py, line 241, in sendcmd return self.getresp() File C:\Python24\lib\ftplib.py, line 216, in getresp raise error_perm, resp ftplib.error_perm: 500 Syntax error, command unrecognized. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Tkinter: is there a has_focus method or property for a window?
I have two windows. One is a main config window. The other is an 'Add Setting' window. Both are using two different classes. Once the Add Setting button is clicked on the Add Setting window, the setting is written to file. At that time the main config window should update its setting listing but it doesn't because it doesn't know it should. I do notice that when the Add Setting window closes, the focus goes right back to the main config window. Is there a has focus event that can trigger a command for this window? Also, if there is another way to get this done, I am open to suggestions. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Catching very specific exceptions
I am running the following code: import socket host = '9.9.45.103' port = 10001 conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) conn.connect((host, port)) When conn.connect() is run, there can be two different exceptions: socket.error: (10061, 'Connection refused') socket.error: (10060, 'Operation timed out') How can I set up exceptions for each of these differently? Normally I would use: except socket.error: code goes here... Of course, though, these are two separate error messages under the same error handler though. I've tried: except socket.error, (10061, 'Connection refused'): and except (socket.error, 10061, 'Connection refused'): to no avail. What do I need to do to catch each one specifically? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching very specific exceptions
Thanks for the effort on this last post, Roy. You asked what I was hoping to do differently on these two very minutely different error messages. What I have been trying to do for some time is to write a ping client (for Win32 platform -- Yes, I develop almost exclusively for Win32 environment, unfortunately) that would be a bit less buggy than ones already written, avoid Twisted, and not even involve myself in pynms (way overkill for what I want and need). I am finding that with the many quirks (and really bad foundation for Win32 APIs) that I am having to write a lot of voodoo code so to speak. If I use a dummy port... let's say port 10001 for example... I can attempt to connect to a machine at this port. If I get an error that says Connection refused, I know that the node is up but is just not going to allow a connection. On the other hand, if I try to connect to a node and it's really not up, I'll get a Connection timed out error. In this manner I can really tell if a node is up or not (providing a TCP/IP stack is installed there). This really what I've wanted. I am not so concerned whether or not the node pongs back in a certain amount of time. Yeah normally it's annoying when people ask what you're trying to do when you ask a specific question, but in this case it's probably necessary to explain myself before some are willing to help out. I'm really not interested in even negotiating a successful connection on a specific port, but this is just a way to tell if something is up or down (and perhaps the only real way to do it running from a Win32 platform). Thanks for the help. However, if you do have suggestions on how to get this done better, I am more than glad to hear it! Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Catching very specific exceptions
Reasons why it still won't work: * Firewall * Unknown-modes-operating-systems-get-into Yeah, I dont think these things can be avoided. Nonetheless, if I can come up with some way (via help from this group--thank God!) to find if the node is up (barring the two aforementioned reasons), I am doing well. Maybe my standards are not so high. :-| Nonetheless, thanks for the help and the commentary. I was beginning to think I was losing my mind. Harlin -- http://mail.python.org/mailman/listinfo/python-list
socket.gethostbyaddr() question
I have a list of IP addresses I am testing with socket.gethostbyaddr(). For the most part, I am able to get a hostname returned to me when I run gethostbyaddr(). I am also hoping this will allow me to tell if a computer is up or down. However, in my environment, I am finding that I am able to get a hostname even though I am unable to actually ping that server (when I ping a server i like this, I get 'request timed out' messages telling me that the server is not up). Other times, I am able to ping a server with success but the gethostbyaddr() request will not be able to return a hostname for me making me think that machine is truly down when I know it's not. Can anyone give me any pointers as to why this happens? Is there anyway I can do a reliable ping to another server with Python? I am not interested in doing system calls with a system Ping client (I have to ping way too many machines and this either takes too long or causes severe memory leakage due to MS's horrible ping client). Also, I am unable to use Jeremy Hylton's Python ping client because it does little more than call gethostbyaddr(). Thanks for taking a look at this. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Converting milliseconds to human amount of time
How can I take a time given in milliseconds (I am doing this for an uptime script) and convert it to human-friendly time i.e. 4 days, 2 hours, 25 minutes, 10 seonds.? Is there a function from the time module that can do this? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Converting milliseconds to human time
I would like to take milliseconds and convert it to a more human-readable format like: 4 days 20 hours 10 minutes 35 seconds Is there something in the time module that can do this? I havent been able to find anything that would do it. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting milliseconds to human time
Thanks Dan, that would be perfect or close enough I should say. :-) Regards, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
How to Retrieve Data from an HTTPS://URL
I am trying to pull data from a web page at https://localhost/wps. While this would work if the url was http://localhost/wps, it doesn't work with 'https.' I can do this: import urllib data = urllib.urlopen('http://localhost/wps').read() But not with https. How can I pull data from a https url? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Need eyes to look at code... time not having an attribute called asctime()
from utilities import * from extractor import * import time import os print 'Running AgentPing at '+time.asctime() confFile = '../conf/AgentPing/AgentPing.conf' ex = extractor(confFile) names = ex.array('name') comments = ex.array('comment') ips = ex.array('ip') counts = ex.array('count') thresholds = ex.array('threshold') alarms = ex.array('alarm') levels = ex.array('level') records = ex.array('record') plogger = Logger('../logs/AgentPing.log') for name,comment,count,ip,threshold,alarm,level,record in zip(names,comments,counts,ips,thresholds,alarms,levels,records): msg = 'AGENT INFORMATION: Pinging '+ip+' at '+time.asctime() print msg plogger.loggit(msg) line = 'ping -n '+count+' '+ip try: data = os.popen(line).readlines() time = data[-1].split()[-1][:-2] except: msg = 'AGENT FAILURE: Unable to run ping on '+ip+' for unknown reason.' print msg msg += 'Error created at '+time.asctime() time = float(threshold)*2 plogger.loggit(msg) createAlarm(name, comment, ip, threshold, level, msg) Whenever I run this I get: Traceback (most recent call last): File agentPing.py, line 23, in ? msg = 'AGENT INFORMATION: Pinging '+ip+' at '+time.asctime() AttributeError: 'str' object has no attribute 'asctime' Press any key to exit I'm sure this is something simple but for this I am having trouble figuring it out. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Function to retrieve running script
Thanks Mike, that will work just as well... just disappointed in myself that i lack the creativity to think of something that simple ;-) thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Function to retrieve running script
Is there a function that allows one to get the name of the same script running returned as a string? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: pinging from within python
You can do the following: import os data = os.popen('ping machineName').read() if 'request timed out' in data or 'unknown host' in data: Ping Failed Code else: Ping Returned Something Good Code This is the quickest and really most effective way to get it done IMO. Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Putting a lock on file.
I have a file that a few different running scripts will need to access. Most likely this won't be a problem but if it is, what do I need to do to make sure scripts don't crash because the input file is in use? Would it be best to run a loop like the following: flag = 0 while not flag: try: open(file, 'r').read() flag = 1 except: pass This may seem nice on paper but I hate to run a while for an indeterminate amount of time. Is there anything else that can be done that would be better? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Rendering HTML
Hi DH, Thanks for this blurb from ASPN. I am really looking, however, to do this on a Windows machine as opposed to a Unix one at this point. This will come in handy down the road I am sure. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Rendering HTML
I am looking for a module that will render html to console but formatted much like one might see with Lynx. Is there such a module already out there for this? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Python Search Engine app
Hi, Is anyone aware of an available open-source/free search engine app (something similar to HTDig) written in Python that is out there? Googling has turned up nothing. Thought maybe I'd mine some of you guys' minds on this. thanks, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Re: python script under windows
Hi Jan, Unfortunately you will have to register it as a service. I am almost certain there is no other way to do it. However, setting up an executable as a true Windows Service is extremely tedious. You can try this utility that I use. You can get it here: http://www.seritt.org/pub/srvinst13b.exe. I'm probably not supposed to distribute it, but the site and owners that used to host it have gone belly up best that I can tell. As with anything, use it at your own risk. I found it as freeware a few months back. If you want a decent cheap solution, FireDaemon is pretty good. I think it's like 30USD but it does a great job and adds a few extra features. HTH, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Re: problems with smtplib
What are you getting in your smtpd logs? Are you using postfix? sendmail? or are you running this against a Windows stmp service? Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Win32: Possible to use Python to create Snap-Ins for MMC?
Is it possible to use Python to create snapins for the MMC? Thanks, Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Re: use threading without classes
Is there any reason why you wouldn't want to do this using the the threading class? To each his own I suppose. You can try the following though you'll at least need to use functions: import time import thread def myfunction(string,sleeptime,*args): while 1: print string time.sleep(sleeptime) #sleep for a specified amount of time. if __name__==__main__: thread.start_new_thread(myfunction,(Thread No:1,2)) while 1:pass -- http://mail.python.org/mailman/listinfo/python-list
Re: Considering moving from PowerBuilder to Python
For: snip So, is there any data on the popularity of IDEs (most users), or is there a chart comparing the most popular versions. /snip Hi Norm, You can do a Google search for these sorts of things like opinions and comparisons. Believe me, there are more blogs and articles on these things than you can shake a stick at :-). Harlin Seritt Internet Villa: www.seritt.org -- http://mail.python.org/mailman/listinfo/python-list
Machine Name
How does one get the machine name with Python that the actual script is running on? Obviously, one could parse the hosts file but I was wondering if there was a quick way to get it done? thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Help with Regular Expressions
I have been looking at the Python re module and have been trying to make sense of a simple function that I'd like to do. However, no amount of reading or googling has helped me with this. Forgive my stone-headedness. I have done this with .NET and Java in the past but damn if I can't get it done with Python for some reason. As such I am sure it is something even simpler. I am trying to find some matches and have them put into a list when processing is done. I'll use a simple example like email addresses. My input is the following: wordList = ['myname1', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]', '[EMAIL PROTECTED]'] My regular expression would be something like '[EMAIL PROTECTED]' (I realize it could and should be more detailed but that's not the point for now). I would like to find out how to output the matches for this expression of my 'wordList' into a neat list variable. How do I get this done? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Regular Expressions
Ahh that's it Frederik. That's what I was looking for. The regular expression problems I will take care of, but first wanted to walk before running. ;) Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Help with Regular Expressions
Forgive another question here, but what is the 'r' for when used with expression: r'\w+...' ? -- http://mail.python.org/mailman/listinfo/python-list
How to run python script in background after i logout
I have a remote linux server where I can only access it via ssh. I have a script that I need to have run all the time. I run like so: python script.py It runs fine. When I log off ssh I notice that the script died when I logged off. How do I make sure it stays running? thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Formatting data to output in web browser from web form
This is perfect. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Formatting data to output in web browser from web form
Hi, I am using CherryPy to make a very small Blog web app. Of course I use a textarea input on a page to get some information. Most of the time when text is entered into it, there will be carriage returns. When I take the text and then try to re-write it out to output (in html on a web page), I notice the Python strings don't translate these special characters (carriage returns) to a p so that these paragraphs show up properly in html for output. I tried doing something like StringData.replace('\n', 'p'). Of course this doesnt work because it appears that '\n' is not being used. Is there anything I can do to make sure paragraphs show up properly? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Want to learn a language - is Python right?
Aziz McTang wrote: Hi Paul, Thanks for your input. As usual, hearing some answers helps formulate the question... What I'm looking for is more to learn one good, comprehensive programming language well than several approximately on an ad hoc basis. What I also failed to mention is the desire to develop my presently limited computer skills a lot further. So although your answer to 1 suggests I'd be using a steam-roller to kill a fly, if I do need to go further (or ask other people to help and still understand what's going on: one site I may want to develop later involves a number of languages including Japanese as well as audio) I won't have to re-learn another program. Is this right? As to 2, I have yet to find a canned program that does what I want, and so far every programmer I've asked to write it has said hey that's easy then escaped, never to be heard of again. And 3: good! Actually, having learned half a dozen languages, I can vouch for it being an excellent way to acquire and consolidate vocabulary. Talking to (or, rather, understanding) the natives is another kettle of fish! Thanks again! Any new slants from yourself or others are welcome. Aziz You can use CherryPy for creating a Python-esque web application. Never buy into the fluff that says Python is not as good as PHP for web apps! PHP is still too Perl-Like (meaning old and useless)! Python is the choice of a new generation baby!!! :) JK... For your vocab program, Python is actually perfect. This could even go for apps that require some Unicode and other Internationalization snafus (like right-to-left characters and Cyrillic typesets). If you're looking for one programming language then you should consider the idea that no one language can do it all (although Python comes close in my biased opinion). Python is not for memory management, writing device drivers and the like. As far as needing something for web apps, CherryPy is great -- just learn Python first. PHP is good but it has fallen out of favor with me though there are a ton of people out there who think it is the greatest thing since sliced bread. Take a look at the Python tutorial: http://docs.python.org/tut/tut.html. Good luck, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: extreme newbie
? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to learn OO of python?
? -- http://mail.python.org/mailman/listinfo/python-list
Re: Does TKinter Have A Grid ?
Not a grid widget necessarilly but a 'grid' method you can use instead of pack(). Take a look at http://www.pythonware.com/library/tkinter/introduction/grid.htm. If this isn't what you mean, come back. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Active Directory Modules?
Does anyone know if there are any Python Active Directory Modules out there? I looked at LDAP module but there is no version for Python 2.4 and it's support for Active Directory seems to be lacking a bit. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
SGMLlib module
I am trying to use SGMLlib module to extract all links from some data I pulled from the web (via urllib). I have looked at the documentation online and can not make sense of it. As a quick example, how would I get the hyperlinks for an html file? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: SGMLlib module
Thanks for the help, I just didn't like the way that SGMLlib forces one to instantiate a class to do this (or httplib for that matter). I looked at those links you graciously sent (thanks!) but didn't like them. At any rate, I went ahead and wrote my own. Thank goodness that it's easy to parse with Python on your own! Thanks for the help, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Using wildcards...
I looked all over the net but could not find if it is possible to insert wildcards into strings. What I am trying to do is this: I am trying to parse text from a Bible file. In case you're not familiar with the way the Bible organizes itself, it is broken down into Books Chapters Verses. The particular text I am working with are organized into Book files (*.txt -- flat text file). Here is what the file looks like: {1:1} Random text here. {1:2} More text here. and so on. Of course the {*} can be of any length, so I can't just do .split() based on the length of the bracket text. What I would like to do is to .split() using something akin to this: textdata.split('{*}') # The '*' being a wildcard Is this possible to do? If so, how is it done? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Displaying formatted - data with TKinter
I've used multiple listboxes in the past. Also, you can build a widget that contains multiple listboxes as well. As far as there being one ready to go, I don't know of one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Quick and dirty dialogs?
Try EasyDialog: http://www.talkaboutprogramming.com/group/comp.lang.python/messages/314003.html It should also be on Vaults of Parnassus. -- http://mail.python.org/mailman/listinfo/python-list
Re: Using wildcards...
George that is what I'm looking for. Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Running script in background.
Hi, I have a script.py that is converted to .exe using py2exe. From another script I call script.exe and would like to be able to run this script.exe in the background (as well as in console -- giving the user some simple options). How can I make this happen? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing process
I actually tried mapping the PID to an integer value and it still didn't work. At any rate, I found another way to do it. Thanks anyways. -- http://mail.python.org/mailman/listinfo/python-list
Re: tkMessageBox dialog help
Nathan, From what I've seen I'm afraid this is the way it is. If you call an instance of tkMessageBox and you don't have a 'master' Tk instance running, it will create its own. Still, I'm sure with a bit of voodoo you can hide the self created tk window while showing the message box. If you find a more elegant way to accomplish this, please post back ! Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Writing to log file when script is killed
I am looking for a way for my script to write to a log file saying something like this: I was killed at time.asctime() I would like to be able to do this if/when the script is killed by means rather than my own. How in the world would I accomplish this? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Getting PID for process
Let's say I have a simple script on Windows NT. I would like for that script to find its own PID once it's started and store that as a value within the script. Also, down the road I'd like to kill that process by its PID. How is this done? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Killing process
I am using os.getpid() to get the pid value for a script running. I store that value (as a string) to a file. Later when I try to kill that pid (i pull this from the file as a string value) I get errors. Using the following lines I get the subsequent error. (pid is a string value) win32api.TerminateProcess(int(pid), 0) OR ctypes.windll.kernel32.TerminateProcess(int(pid), 0) Errors: Exception in Tkinter callback Traceback (most recent call last): File C:\Python23\lib\lib-tk\Tkinter.py, line 1345, i return self.func(*args) File vngconsole.py, line 27, in StopVngSvc win32api.TerminateProcess(int(pid), 0) error: (6, 'TerminateProcess', 'The handle is invalid.') How exactly do I kill a pid using a string value? -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing process
Yeah I've kind of figured that. I was just wanting to know what I could use to kill a pid that is a string value. Thanks though. Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: Killing process
I think I need something besides TerminateProcess(). Is there anyway possible to terminate a process by just passing a string value to the function? Honestly, I am not interesting in terminating a process by its handle. -- http://mail.python.org/mailman/listinfo/python-list
Getting the sender widget's name in function (Tkinter)
I have the following script. Two widgets call the same function. How can I tell inside of the called function which button called it?: def say_hello(): print 'hello!' print widget['text'] root = Tk() button1 = Button(root, text='Button 1', command=say_hello) button1.pack() button2 = Button(root, text='Button 2', command=say_hello) button2.pack() root.mainloop() Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Can .py be complied?
Hi monkey, Not a stupid question especially if you're trying to create commercial software and don't want to reveal your source. At any rate, you can use py2exe to create a .exe file. It does have some cons to it since you are compiling an interpreted script but it works fine in this capacity. If you would like to obfuscate your code (disguise it) without an executable you can try pyobfuscate as well. Just Google for these two and you'll find easily. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Decent Win32All Documentation
Does anyone know of any decent documenation on Mark Hammond's win32all modules? I have tried looking at the documentation .chm file that comes with it, Python Programming On Win32 (OReilly book) and ActiveState's documentation and have found them all lacking -- yes I need it broken down to me. What I am hoping to do is to work on some Python versions of PSTools. I think the win32 modules will be perfect for helping me do this, however, I am having a (more than it should be) difficult time making sense of the win32process module. Any help would be appreciated. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Decent Win32All Documentation
Kartic, Thanks for the help. It's good to get a different perspective on something (i.e. MSDN, dir() etc). -- http://mail.python.org/mailman/listinfo/python-list
Parsing data from URL
I am trying to do the following: of course website.com is not the actual site import urllib url = 'http://www.website.com/file.shtml' dat = urllib.urlopen(url, 'r').read() print dat When I do so, I get the following data: !DOCTYPE HTML PUBLIC -//IETF//DTD HTML 2.0//EN HTMLHEAD TITLE405 Method Not Allowed/TITLE /HEADBODY H1Method Not Allowed/H1 The requested method POST is not allowed for the URL P HR ADDRESSApache/1.3.27 Server at website.com Port 80/ADDRESS /BODY/HTML How can I make sure that I get the actual html data instead of the data from redirected URL? thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Multiple tuples for one for statement
I have three tuples of the same size: tup1, tup2, tup3 I'd like to do something like this: for a,b,c in tup1, tup2, tup3: print a print b print c Of course, you get an error when you try to run the pseudocode above. What is the correct way to get this done? Thanks, Harlin -- http://mail.python.org/mailman/listinfo/python-list
Question Regarding PIL and PhotoImage classes
Why is that I can only get the PhotoImage class to show up when I write a straight procedural script (no object orientation) but not when I try to use object-orientation? These two scripts in theory should produce the same results but they don't. Is there any reason why? ---Procedural--- root = Tk() im = Image.open('image.gif') photo = ImageTk.PhotoImage(im) label = Label(image=photo) label.pack() root.mainloop() ---Object-Oriented--- from Tkinter import * import Image, ImageTk class App: def __init__(self, master): im = Image.open('dellserver.gif') photo = ImageTk.PhotoImage(im) label = Label(master, image=photo) label.pack() if __name__ == '__main__': root = Tk() app = App(root) root.mainloop() ---END of CODE--- Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Does Tk provide ComboBox ?
Hi Markus, Pmw has a ComboBox but it's ugly IMO. Tix also has one -- but it's not much different than the Pmw one. I created one and put it in a Tkinter.py file. You can see mine here: http://www.seritt.org/pub/tkinter/Tkinter-03132005.py -- I can honestly say it's almost fully functional :-) Seriously though, you can use the Listbox for almost anything you would need a combobox for. In my mind, it's good for tight spaces (I'm sure someone on this fine board will add something or disagree with me), looks and little else. Regards, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: serialize a tkinter thing
No reason why they shouldn't be. -Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: very simple tkinter demo program
Max, Thanks and good job! Harlin -- http://mail.python.org/mailman/listinfo/python-list
Re: workaround for generating gui tools
Benedict, Best to hand-code your code ;-) -- even GUI. This is kind of why I like Tkinter so much. Good luck. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: logging as root using python script
Hi Raghul, If possible, run your program as root. Harlin -- http://mail.python.org/mailman/listinfo/python-list
Showing errors explicitly in try... except
When using try... except... errors don't show up. Is there a way to force stderr despite using try...except? thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Combining digit in a list to make an integer
If anyone has time, would you mind explaining the code that Dan Bishop was so kind as to point out to me: int(''.join(num1)) This worked perfectly for me, however, I'm not sure that I understand it very well. Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Py2exe and dotNet Python
I downloaded PythonDotNet from the Zope site to my laptop. According to the docs I can use this with my regular Python installation. I copied CLR.dll and Python.Runtime.dll to my root folder (c:\\Python24). Doing this I was able to run the dotNet examples with no problems. When I tried to run py2exe on the scripts I received the following errors: --- The following modules appear to be missing: ['CLR.System.Drawing', 'CLR.System.Windows.Forms'] --- My setup.py script for py2exe looks like this: --- # setup.py from distutils.core import setup import py2exe setup(console=[helloform.py]) --- I run the setup like this: python setup.py py2exe. Is there anything else I need to do to get this converted into a *.exe file successfully? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: good IIS 6.0(win2k3) python CGI web ext. setup instructions
Thanks Mark. Since you were in the spirit of volunteering some valuable information, I thought I'd put in my two cents worth. If you are thinking of using Zope or Python CGI for web apps, please take a look at CherryPy (http://www.cherrypy.org). If you are wanting to create a simple, intermediate or even advanced (in a lot of cases), CherryPy allows one to actually program an entire website in Python. For me CherryPy has been the holy grail of web applications (at least for now) making me forget entirely about using PHP or even ASP.NET for web development projects. Cheers, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: hiding a frame in tkinter
faramarz, Most likely, you'll need to replace the 'forgotten' frame with another one or other widget. You can immediately do *.pack() and it will replace the frame (assumming you haven't already packed something else there). Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Shell Editor Question
The Python shell you get with IDLE is actually not a system shell like cmd.exe or sh, bsh, csh etc. It is a shell that allows the Python interpreter to evaluate each line of Python code as you type. This is why when you type 'hello.py' it tells you 'hello.py' is not defined. On a higher level it simply tells you: you haven't initialized this object called hello.py in memory and therefore the error. Also you can't run python anything because in the interpreter python *hasn't* been assigned any value. Also, you can't quit the Python interpreter shell by typing exit. You'll need to do a Control-D Enter ;-) Hope this makes sense. Good luck. Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
Re: How to ensure Maximize button shows in Linux/Unix (Tkinter)
Diez, Thanks for the quick reply. I am running this under KDE. I actually haven't tried doing so under any other wm for the moment. Any ideas how to get it to show in KDE? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list
How to ensure Maximize button shows in Linux/Unix (Tkinter)
I have a tkinter program that shows the 'maximize' button while running on Windows but not in Linux. Is there a way to make it show in Linux? Thanks, Harlin Seritt -- http://mail.python.org/mailman/listinfo/python-list