Re: calling NetShareEnum win32api with ctypes

2008-08-28 Thread Tim Golden
taghi wrote: I want to call NetShareEnum, a function from netapi32.dll Not a straightforward answer but... are you aware that this particular call is already wrapped by the pywin32 packages: https://sourceforge.net/projects/pywin32/ http://timgolden.me.uk/pywin32-docs/win32net__NetShareEnum_m

Re: Getting references to obect instances into a list

2008-08-27 Thread Tim Golden
Marc 'BlackJack' Rintsch wrote: On Wed, 27 Aug 2008 08:32:52 -0700, [EMAIL PROTECTED] wrote: Thanks for your reply Simon. I will read the article you told me to but first, please, have a look at this snippet: [... snipped snippet plus Mark's comment ...] I think, in short, the best thing fo

Re: Date type in win32com?

2008-08-27 Thread Tim Golden
Haeyoung Kim wrote: Hi. I'm migrating a VBScript into python. How should I convert Date type parameter in VBScript's COM interface with win32com? I couldn't find any answer yet... Could you give an example of code you're trying to translate? Normally it's quite simple, but different subsyste

Re: Launch an application and continue the script's execution

2008-08-27 Thread Tim Golden
Gabriel Genellina wrote: Start the application in a separate console (using `start "" bat_file` might be the easiest way) and then, within your Python script, wait until the new process is ready. The wmi module by Tim Golden can help <http://tgolden.sc.sabren.com/python/wmi.htm

Re: Python open of c:\ path Problem

2008-08-23 Thread Tim Golden
Wayne Watson wrote: Python doesn't like this: junkfile = open('c:\tmp\junkpythonfile','w') I get junkfile = open('c:\tmp\junkpythonfile','w') IOError: [Errno 2] No such file or directory: 'c:\tmp\\junkpythonfile' The clue, if you needed one, is there in that traceback. Notice the *single

Re: Debugging of a long running process under Windows

2008-08-21 Thread Tim Golden
R. Bernstein wrote: I don't know how well Microsoft Windows allows for sending a process a signal in Python, but if the Python signal module works reasonably well on Microsoft Windows, then reread http://bashdb.sourceforge.net/pydb/pydb/lib/node38.html The answer is: not terribly well. (Or, rat

Re: How to use win32com to convert a MS WORD doc to HTML ?

2008-08-19 Thread Tim Golden
Lave wrote: Hi, all ! I'm a totally newbie huh:) I want to convert MS WORD docs to HTML, I found python windows extension win32com can make this. But I can't find the method, and I can't find any document helpful. You have broadly two approaches here, both involving automating Word (ie using

Re: very rare python expression

2008-08-12 Thread Tim Golden
甜瓜 wrote: Howdy everyone, I saw a strange python code in pygame project. What does "while not(x&528or x in l):" mean? Below code works in python2.5, so "x&528" is not HTML strings. Well I can't say I'd format it that way myself, but it is valid. More conventionally laid out the expression look

Re: very rare python expression

2008-08-12 Thread Tim Golden
甜瓜 wrote: Howdy everyone, I saw a strange python code in pygame project. What does "while not(x&528or x in l):" mean? Below code works in python2.5, so "x&528" is not HTML strings. Well I can't say I'd format it that way myself, but it is valid. More conventionally laid out the expression look

Re: Win32 trouble with threading, signals, and sleep()

2008-08-09 Thread Tim Golden
Lowell Alleman wrote: I'm running into this issue on Windows with the follow exception at the time when the signal handler is called: Traceback (most recent call last): ... self.done.wait(30) File "D:\Python24\lib\threading.py", line 348, in wait self.__cond.wait(timeout) File "D:

Re: CAB files

2008-08-08 Thread Tim Golden
Virgil Stokes wrote: I would appreciate python code for creating *.cab files. I'm not aware of any existing modules for creating CABs. I thought there were some MS API calls for doing that kind of thing but a quick search hasn't shown anything up. You may have to roll your own: http://support

Re: Calculate sha1 hash of a binary file

2008-08-06 Thread Tim Golden
LaundroMat wrote: Hi - I'm trying to calculate unique hash values for binary files, independent of their location and filename, and I was wondering whether I'm going in the right direction. Basically, the hash values are calculated thusly: f = open('binaryfile.bin') import hashlib h = hashlib.

Re: win32com ChartObject pythonwin vs idle

2008-07-31 Thread Tim Golden
sterling wrote: I'm curious as to why the difference between IDLE and pythonWin when using win32com. opening an excel file, i've attempted to grab the chart information out of the file. commands like co = ChartObjects(1) works in pythonWin but doesn't work in IDLE. however, on both co = charto

Re: variable expansion with sqlite

2008-07-30 Thread Tim Golden
Gerhard Häring wrote: My code would probably look very similar. Btw you don't need to use list() on an iterable to pass to executemany(). pysqlite's executemany() accepts anything iterable (so generators work fine, too). Thanks for that. My finger-memory told me to do that, possibly because so

Re: variable expansion with sqlite

2008-07-30 Thread Tim Golden
marc wyburn wrote: Hi I'm using SQlite and the CSV module and trying to create a class that converts data from CSV file into a SQLite table. My script curently uses functions for everything and I'm trying to improve my class programming. The problem I'm having is with variable expansion. self.

Re: Windows Interpreter

2008-07-29 Thread Tim Golden
Victor Subervi wrote: def a(): chars = ['\\i0', '\\u0', '\\qc', '\\b0', '\\ql', '\\i', '\\u', '\\b', '\\yz'] rtf_markup = 'viewkind4\uc1\pard\nowidctlpar\qc\i\f0\fs36 Who is like the Beast? Who can wage war against him?\par' for char in chars: c = '(?<=' + char + ')' test = re.se

Re: Windows Interpreter

2008-07-29 Thread Tim Golden
Victor Subervi wrote: Hi: I would like to make my windows python interpreter work like my linux one. I want to be able to cut and paste multiple lines of code. You can already do this: what are you trying which isn't working? Now I can only paste one line at a time. I do not want it to inde

Re: Questions on 64 bit versions of Python (Thank-you!)

2008-07-29 Thread Tim Golden
[EMAIL PROTECTED] wrote: Thanks for everyone's feedback - excellent detail - all my questions have been answered. BTW: Roel was correct that I got confused over the AMD and Intel naming conventions regarding the 64 bit versions of Python for Windows. (I missed that nuance that the Intel build re

Re: Encoding for Devanagari Script.

2008-07-28 Thread Tim Golden
Atul. wrote: Hi Fredrik and Terry, Well I got this on IDLE I think I have done something wrong. import codecs f = open("C:\Documents and Settings\admin\My Documents\corpus\dainaikAikya collected by sushant.txt","r", "utf_8") Traceback (most recent call last): File "", line 1, in f =

Re: GUID Generation

2008-07-28 Thread Tim Golden
Robert Rawlins wrote: I’ve been looking at the following recipe for generating a GUID http://code.activestate.com/recipes/163604/ however I note that its about 6 years old. Has python since adopted an internal module for GUID generation? Or is this 3^rd part module still the best option? Not

Re: Gracefull application exit.

2008-07-24 Thread Tim Golden
Robert Rawlins wrote: I’m looking to implement an exit/termination process for an application which can be triggered by A) a keyboard interrupt or B) termination of the application as a Daemon using a signal. I have a whole bunch of tasks I want to perform as a cleanup before the application

Re: Python / PAMIE

2008-07-24 Thread Tim Golden
frankrentef wrote: THNX for your response. Based on the authors code it's very simple. from cPAMIE import PAMIE ie=PAMIE () #ie.navigate ("google.com") #ie.linkClick #ie.textBoxSet #ie.writeScript ie.navigate ('https://login.yahoo.com/config/mail?.intl=us') #ie.scriptWrite () ie.scriptWrite

Re: Attack a sacred Python Cow

2008-07-24 Thread Tim Golden
Just wondered whether the OP's Subject was a deliberate play on "flog a dead horse" or merely an ironic one :) TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Python / PAMIE

2008-07-24 Thread Tim Golden
frankrentef wrote: Can someone help with a PAMIE issue? I'm new to Python / PAMIE and they seem like great tools but to be honest I'm finding that no responses to questions can be found (Experts Exchange, etc.) I'm hoping this will be the place. I tried to duplicate the authors "ie.writeScript

Re: Python / PAMIE

2008-07-24 Thread Tim Golden
frankrentef wrote: Can someone help with a PAMIE issue? I'm new to Python / PAMIE and they seem like great tools but to be honest I'm finding that no responses to questions can be found (Experts Exchange, etc.) I'm hoping this will be the place. I tried to duplicate the authors "ie.writeScript

Re: Recursion Performance Question

2008-07-24 Thread Tim Golden
B wrote: Now it works, but it runs quite slow (compared to the c++ app). I changed gwl from strait recursion to use a generator and that helped, but it still takes 0.5-1.0 seconds to populate the tree. What I'm wondering is am I doing it in a really inefficient way, or is it just python? W

Re: Is this a valid use of 'import'?

2008-07-22 Thread Tim Golden
Frank Millman wrote: In this particular case, when it is executed, it does a whole lot more. It reads in some parameters, establishes a socket connection, starts a thread, and starts monitoring the socket using select.select. It also exposes some functions that disguise the complexity of reading

Re: Missing sqlite3.h Error when Building Debug Python -- Windows Vista

2008-07-22 Thread Tim Golden
Bev in TX wrote: Thanks for letting me know about this. I installed Subversion and tried to make the build work like that, but it fails. [... snip problems ...] I'm afraid I'm not using VS 2005, nor Vista, nor 64-bit, so I hope someone else can help. If you don't get any take-up here try the

Re: Python Written in C?

2008-07-21 Thread Tim Golden
mk wrote: Grant Edwards wrote: Using punch-cards and paper-tape. Real programmers can edit their programs with a pointy stick and some home-made sticky-tape. Wrong! Real programmers can program using only Touring machine Is that some kind of bicycle? TJG -- http://mail.python.org/mailman/

Re: ntlm authentication

2008-07-21 Thread Tim Golden
Neuberger, Sheldon N. wrote: Is there any way to make urllib2 handle NTLM authentication? Frankly, I'd hate to try. Have a look at this: http://sourceforge.net/projects/ntlmaps/ in case it helps, either by providing a solution or at least by illustrating some code. In addition, look at the s

Re: Missing sqlite3.h Error when Building Debug Python -- Windows Vista

2008-07-20 Thread Tim Golden
Bev in TX wrote: I am a complete newbie at building Python. I am trying to build it under MS Windows Vista (64-bit AMD) with MS VS2005. I'm doing that because I need debug libraries, which I did not see in the standard distribution. I'll leave others to comment on whether or not it's expected

Re: About wmi

2008-07-17 Thread Tim Golden
patrol wrote: I will try to modify the wmi.py ,however I'm a novice.It will take a long time. You can give it up temporarily. If you don't mind ,can you tell me where needs modifying and how? Just unicode? Or Other? OK. Thanks for your patience on this one, Patrol. What I propose to do is to di

Re: About wmi

2008-07-16 Thread Tim Golden
patrol wrote: > On 7月17日, 上午12时16分, Tim Golden <[EMAIL PROTECTED]> wrote: >> Assuming that the error comes back in the sys.stdout encoding, the following >> version *should* work ok. I still haven't got a non-English set up to test >> it on, but it certainly doe

Re: About wmi

2008-07-16 Thread Tim Golden
patrol wrote: import wmi wmi.WMI('non-existent computer') > Traceback (most recent call last): > File "", line 1, in > File "C:\Python25\lib\wmi.py", line 1199, in connect > handle_com_error (error_info) > File "C:\Python25\lib\wmi.py", line 184, in handle_com_error > excep

Re: About wmi

2008-07-16 Thread Tim Golden
Assuming that the error comes back in the sys.stdout encoding, the following version *should* work ok. I still haven't got a non-English set up to test it on, but it certainly does return a Unicode error message. http://timgolden.me.uk/wmi-project/wmi.py The usual test case, if you wouldn't min

Re: About wmi

2008-07-16 Thread Tim Golden
patrol wrote: > -2147023174 > 'RPC \xb7\xfe\xce\xf1\xc6\xf7\xb2\xbb\xbf\xc9\xd3\xc3\xa1\xa3' > None > None > > -- > import pythoncom > import win32com.client > > > try: > win32com.client.GetObject ("winmgmts://blahblah") > exc

Re: About wmi

2008-07-16 Thread Tim Golden
patrol wrote: > The errors are in the following: > > Traceback (most recent call last): > File "D:\My Documents\code\python\wmi\test.py", line 5, in > c = wmi.WMI ("non-existent computer") > File "C:\Python25\lib\wmi.py", line 1199, in connect > handle_com_error (error_info) > File

Re: How to figure out if the platform is 32bit or 64bit?

2008-07-16 Thread Tim Golden
Fredrik Lundh wrote: Ken Hartling wrote: > Thanks .. but I want to find out if the system is "running on 64bit" > even when the interpreter is a 32-bit build executable ("what python > was built on"). platform.architecture() and platform() in general > seems to only be looking at the build

Re: isPrime works but UnBoundLocalError when mapping on list

2008-07-16 Thread Tim Golden
Andreas Tawn wrote: Terry Reedy wrote: Wrong. Thank you. For loop variables continue after the loop exits. This is intentional. I never knew that and I can't find reference to it in the docs. Interesting starting point. It never occurred to me that they might not. (So I didn't look for an

Re: About wmi

2008-07-16 Thread Tim Golden
patrol wrote: http://timgolden.me.uk/wmi-project/wmi.py It cannot work either. Oh well. It was only a quick fix! I'll try to get some kind of non-ASCII edition of Windows to test against. As I understand it, the situation is that some WMI exception (ie coming from the underlying WMI/COM subsy

Re: File Locking Forced? Newbie question.

2008-07-15 Thread Tim Golden
Sparky wrote: Hello! I am writing some software that will have many users accessing the same file resource at once for reading purposes only. I am programming on (Ubuntu) Linux and my question is in Windows, can I have it so that the same file can be open in read mode by more than one person or c

Re: need ldap windows binary and/or installation help

2008-07-15 Thread Tim Golden
Sells, Fred wrote: I'm running python 2.5 (or 2.4) in an XP environment. I downloaded and installed the .dll's from OpenLDAP-2.4.8+OpenSSL-0.9.8g-Win32.zip and copied the .dll's in c:/windows/system32 as instructed now I get this error. Is there anyway to avoid building the python_ldap b

Re: Zipping files

2008-07-15 Thread Tim Golden
dp_pearce wrote: When I saw "Permission denied", this was my suspicion. And I think you are very right. I have just gone back and tried writing to a file outside of C:, in this case C:/output/, and it seems to work again. Would I be right in guessing there is no way around this? Well, you coul

Re: About wmi

2008-07-15 Thread Tim Golden
patrol wrote: Situation (1): result = new_process.terminate() TypeError: 'int' object is not callable I'm not sure exactly what's causing that particular effect, but I would suggest that you call the method as .Terminate (note the initial capital). On my box, calling .terminate simply raise

Re: About wmi

2008-07-15 Thread Tim Golden
patrol wrote: Situation (2): result = new_process.terminate() File "C:\Python25\lib\wmi.py", line 494, in __getattr__ handle_com_error (error_info) File "C:\Python25\lib\wmi.py", line 190, in handle_com_error raise x_wmi, "\n".join (exception_string) UnicodeDecodeError: 'ascii' co

Re: How can I save command prompt screen

2008-07-15 Thread Tim Golden
Ty hensons wrote: how can i save my command prompt screen? (Trying to be helpful here...) What do mean by "save" and what do you mean by "command prompt screen"? And, especially, what platform are you running on? TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Zipping files

2008-07-15 Thread Tim Golden
dp_pearce wrote: Hi all, I have come across an error while using zipfile and I can't seem to find somewhere that explains the problem. My script needs to be able to take text files from one drive and add them to zip files on another drive. The following seems to work just fine. import zipfile

Re: About wmi

2008-07-14 Thread Tim Golden
codec can't decode byte 0xb7 in position 14: ordinal not in range(128) [... snip code ...] You should probably post this to comp.python.windows. Tim Golden (author of WMI interface) monitors that list religously (thanks Tim). Actually, I follow this one pretty much, too. I've just

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-11 Thread Tim Golden
Bill Davy wrote: Traceback (most recent call last): File "H:/Personal/OutlookIF1/t2.py", line 18, in outlook = win32com.client.gencache.EnsureDispatch ("Outlook.Application") File "C:\Python25\Lib\site-packages\win32com\client\gencache.py", line 536, in EnsureDispatch mod = EnsureM

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-11 Thread Tim Golden
Bill Davy wrote: and since then have been busy with work, and my other job, and the garden. Aha! So you're English, are you? Looks like you're in the West Country. Weather map suggests you're not short of rain over there :) Now I am back looking at this (and using WInUSB to talk to a Maxim 342

Re: importing .dll in a python file

2008-07-11 Thread Tim Golden
moijes12 wrote: I need to use a .dll from a python script.I have installed pywin.But in the program ,which is like: import dllName I get : Import Error : DLL not found Please suggest a solution! Well, the short answer is: use the ctypes module. The longer answer is: read around the subjec

Re: Local User Control

2008-07-10 Thread Tim Golden
Sparky wrote: On Jul 10, 9:58 am, Tim Golden <[EMAIL PROTECTED]> wrote: Sparky wrote: I don't know how feasible this is, but is it possible to have users log in to access a local database file in such a way that allows the program to know what user name and password they logged in

Re: Local User Control

2008-07-10 Thread Tim Golden
Sparky wrote: I don't know how feasible this is, but is it possible to have users log in to access a local database file in such a way that allows the program to know what user name and password they logged in with? This would involve separate user names and passwords for each user. Well, this

Re: Python / Windows process control

2008-07-10 Thread Tim Golden
Salim Fadhley wrote: Does anybody know of a python module which can do process management on Windows? The sort of thing that we might usually do with taskmgr.exe or process explorer? For example: * Kill a process by ID * Find out which process ID is locking an object in the filesystem * Find ou

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-10 Thread Tim Golden
Bill Davy wrote: I'm not sure OL2003 can read news. I think perhaps some later OL can (added tot he View menu, perhaps?). So I use OL Express to read news. The OL with which I wish to communicate is: Application name Outlook Version 11.0 Build 8217 Product ID 70141-700-0350904-56905 Languag

Re: Allow tab completion when inputing filepath?

2008-07-10 Thread Tim Golden
Keith Hughitt wrote: 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 tab completion

Re: Allow tab completion when inputing filepath?

2008-07-09 Thread Tim Golden
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 tab completion for program-related commands, but not for system filepaths. This would be nice to have when prom

Re: Newbie question

2008-07-09 Thread Tim Golden
|e0 wrote: I did not mean to use WMI on linux, but query win machines *from* linux. Thank you for your clarifications In principle you ought to be able to use some kind of DCOM bridge (since WMI access if via COM/DCOM). I've no idea if anyone's attempted this or even if all the pieces are in pl

Re: Newbie question

2008-07-09 Thread Tim Golden
A.T.Hofkamp wrote: On 2008-07-09, |e0 <[EMAIL PROTECTED]> wrote: So, i can't use wmi module on linux? On Wed, Jul 9, 2008 at 9:14 AM, Lamonte Harris <[EMAIL PROTECTED]> wrote: I think the win32 module is only for windows. Welcome to the world outside MS. Many python modules don't actually

Re: how to recognize IE window already opened using win32com extension

2008-07-07 Thread Tim Golden
korean_dave wrote: How do I use the win32com API to manipulate IE windows ALREADY open? ie = Dispatch("InternetExplorer.Application") opens a new window. But I'd like to be able to find, of windows already open, a specific window (with a specified property, matching url, etc.) I have this str

Re: python mysteriously halts

2008-07-07 Thread Tim Golden
Todd wrote: I ran a python script last night which connects to a matlab automation server via DCOM (using win32com). I expected to see the results when I came in this morning. But apparently, not long after I left, python stopped. I hit enter in the console, and it started again. Symptomati

Re: Can't get Python for Windows to run

2008-07-04 Thread Tim Golden
Tim Rowe wrote: I have Python 2.5 working just fine on my system. I've tried downloading and installing the MS Windows Python extensions, but can't get pythonw.exe (that's the windows executable, right?) to do anything. I double-click it, nothing happens. I run it from a command prompt, it just

Re: Recursive wildcard file search

2008-07-04 Thread Tim Golden
[sorry; this got stuck in my outbox] Robert Dailey wrote: Is there a way to perform a recursive file search using wildcards in python 3.0b1? For example, if I have: C:\foo\abc*xyz.* I want all files in C:\foo and all subfolders (recursively) of C:\foo that match the wildcard abc*xyz.* to be

Re: win32com.client (Howto edit Contacts in Outlook)

2008-07-04 Thread Tim Golden
Bill Davy wrote: I am trying to edit Contacts in Outlook. This is so I can transfer numbers from my address book which is an Excel spreadsheet to my mobile phone. I came across the following snippet of code --- hey! that looks familiar :) which enabled me to the contacts at least list. I

Re: better way to search the Python archive

2008-07-04 Thread Tim Golden
Jeremy Link wrote: Just an FYI out to folks that want a better way to search the Python archive… I’ve been using MarkMail (www.markmail.org ) to search the archives and it works MUCH better than the Google archive. It is a free hosting of all sorts of GNU/open source

Re: Win32.client, DAO.DBEngine and exceeding the file sharing count lock

2008-07-02 Thread Tim Golden
In case it helps, there's a recipe just shown up on the Python Cookbook which at least illustrates DAO use: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572165 TJG -- http://mail.python.org/mailman/listinfo/python-list

Re: Win32.client, DAO.DBEngine and exceeding the file sharing count lock

2008-07-02 Thread Tim Golden
Iain King wrote: On Jul 2, 3:29 pm, Tim Golden <[EMAIL PROTECTED]> wrote: Iain King wrote: Hi. I'm using the win32 module to access an Access database, but I'm running into the File Sharing lock count as inhttp://support.microsoft.com/kb/815281 The solution I'd like to

Re: Win32.client, DAO.DBEngine and exceeding the file sharing count lock

2008-07-02 Thread Tim Golden
Iain King wrote: Hi. I'm using the win32 module to access an Access database, but I'm running into the File Sharing lock count as in http://support.microsoft.com/kb/815281 The solution I'd like to use is the one where you can temporarily override the setting using (if we were in VB): DAO.DBEng

Re: shorten path to files

2008-06-27 Thread Tim Golden
On 2008-06-27, cesco <[EMAIL PROTECTED]> wrote: Hi, I need to retrieve the content of some files which are placed on a network drive so in order to open them I need the full path to the file. Unfortunately some times the path is longer than 256 characters and in Windows such a path is too long w

Re: Working with the Windows Registry

2008-06-27 Thread Tim Golden
teh_sAbEr wrote: Great! It works properly now but I have one more question, would anyone know how to get the changes to take effect immediately? Like some sort of Python way to force the desktop to reload? AFAIK the only way that'll happen is if I use the Display Properties dialog box. The Regist

Re: Windows process ownership trouble

2008-06-26 Thread Tim Golden
Tim Golden wrote: geoffbache wrote: Tim, Unfortunately my previous message was premature, it seems your workaround doesn't work either on my system (Windows XP, Python 2.5.1) I get the following printed out Traceback (most recent call last): File "C:\TextTest\processown.py&quo

Re: Windows process ownership trouble

2008-06-26 Thread Tim Golden
geoffbache wrote: Tim, Unfortunately my previous message was premature, it seems your workaround doesn't work either on my system (Windows XP, Python 2.5.1) I get the following printed out Traceback (most recent call last): File "C:\TextTest\processown.py", line 12, in os.remove ("filena

Re: Windows process ownership trouble

2008-06-26 Thread Tim Golden
geoffbache wrote: Tim, Unfortunately my previous message was premature, it seems your workaround doesn't work either on my system (Windows XP, Python 2.5.1) I get the following printed out Traceback (most recent call last): File "C:\TextTest\processown.py", line 12, in os.remove ("filena

Re: Windows process ownership trouble

2008-06-25 Thread Tim Golden
geoffbache wrote: Am currently being very confused over the following code on Windows import subprocess, os file = open("filename", "w") try: proc = subprocess.Popen("nosuchprogram", stdout=file) except OSError: file.close() os.remove("filename") Forgot to say: slightly awkward, b

Re: Windows process ownership trouble

2008-06-25 Thread Tim Golden
geoffbache wrote: Am currently being very confused over the following code on Windows import subprocess, os file = open("filename", "w") try: proc = subprocess.Popen("nosuchprogram", stdout=file) except OSError: file.close() os.remove("filename") This produces the following excepti

Re: Terminating processes on Windows (handles and IDs)

2008-06-24 Thread Tim Golden
(There must be one down there somewhere, surely?) Sorry for rambling a bit, am confused. Regards, Geoff Bache My way to do it is using excellent wmi module by Tim Golden, which relies on Mark Hammond's pywin32 and Windows native wmi functionality. Here is the link - http://tgolden.sc.sabr

Re: Using Python and MS-SQL Server

2008-06-23 Thread Tim Golden
[EMAIL PROTECTED] wrote: I have programmed before, but I am new to using Python. I am currently using the ArcGIS software which uses Python as its scripting language for automating tasks. The current script that I am working on requires pulling in some information from a Microsoft SQL Server.

Re: String question

2008-06-23 Thread Tim Golden
Andreu wrote: I want to split a sentence and assign each word to a variable. In Ruby I can do it as: v1,v2,v3,v4,v5 = str1.split Which will be the Python equivalent ? Thanks. That would be: str1 = "The quick brown fox jumps" v1, v2, v3, v4, v5 = str1.split () TJG -- http://mail.python.org/m

Re: pyTTS says, '"SAPI" not supported'

2008-06-23 Thread Tim Golden
weheh wrote: I'm running Python 2.3 and calling pyTTS. I've had it working forever. Today, I ran out of disk space. After deleting some of my personal files, for no apparent reason, pyTTS no longer runs. For the statement tts = pyTTS.Create() I get the error message: ValueE

Re: urllib (54, 'Connection reset by peer') error

2008-06-18 Thread Tim Golden
[EMAIL PROTECTED] wrote: Thanks for the help. The error handling worked to a certain extent but after a while the server does seem to stop responding to my requests. I have a list of about 7,000 links to pages I want to parse the HTML of (it's basically a web crawler) but after a certain number

Re: CSV variable seems to reset

2008-06-18 Thread Tim Golden
marc wyburn wrote: Hi, I'm using the CSV module to parse a file using whitelistCSV_file = open("\\pathtoCSV\\whitelist.csv",'rb') whitelistCSV = csv.reader(whitelistCSV_file) for uname, dname, nname in whitelistCSV: print uname, dname, nname The first time I run the for loop the conte

Re: How to set directory in save as combo box

2008-06-13 Thread Tim Golden
Couple of things, Gopal, which you might want to remember when posting to mailing lists etc. One is that it's *much* better (and more considerate) to post in plain text, not in HTML. (You should be able to tell Outlook to use plain text). *Especially* when posting code. And even *more* especiall

Re: suppress opening command window after using os.system command

2008-06-12 Thread Tim Golden
Gabriel Genellina wrote: En Thu, 12 Jun 2008 07:08:00 -0300, boriq <[EMAIL PROTECTED]> escribió: On 12 Jun., 11:51, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: En Thu, 12 Jun 2008 05:28:13 -0300, boriq <[EMAIL PROTECTED]> escribió: > I'm using in my script command os.system('command') o

Re: How to set directory in save as combo box

2008-06-12 Thread Tim Golden
gopal mishra wrote: In 'save as' dialog of window application, I am trying to set the path in 'save in' combo box using python win32 programming. How we can set the directory in the 'save in' combo box. There are several ways to display a "Save As" dialog. Can you post [a minimal version of]

Re: Python doesn't understand %userprofile%

2008-06-10 Thread Tim Golden
[EMAIL PROTECTED] wrote: On Jun 10, 2:09 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: [EMAIL PROTECTED] wrote: In xp when I try os.path.getmtime("%userprofile/dir/file%") Python bites back with "cannot find the path specified" Since my script has to run on machines where the username is unspecif

Re: Python doesn't understand %userprofile%

2008-06-10 Thread Tim Golden
[EMAIL PROTECTED] wrote: In xp when I try os.path.getmtime("%userprofile/dir/file%") Python bites back with "cannot find the path specified" Since my script has to run on machines where the username is unspecified I need a fix. Well I can see a few problems here. First is that putting percent

Re: How to remove read-only from a file

2008-06-06 Thread Tim Golden
Robert Dailey wrote: Hi, Using Python 3.0, how can I remove a read-only property from a file in Windows XP? Thanks. import os import stat os.chmod ("c:/temp/temp.txt", stat.S_IWRITE) (Haven't actually checked that on Python 3.0 but I don't believe it's changed...) TJG -- http://mail.python.

Re: Question regarding re module

2008-06-05 Thread Tim Golden
Paul McGuire wrote: On Jun 5, 7:11 am, Tomohiro Kusumi <[EMAIL PROTECTED]> wrote: It could be that the result overloads the __getattr__-method to delegate calls to some object. Thus it's not part of the outer instance. Didn't I read that Py3 will support a __dir__ method so that classes *could

Re: Finding file details...

2008-05-29 Thread Tim Golden
Kalibr wrote: On May 29, 7:55 pm, Tim Golden <[EMAIL PROTECTED]> wrote: You don't say, but I assume you're on Windows since you mention GetFileVersionInfo (which doesn't have anything to do with media files, by the way) and WMA. There may be packages out there to do all th

Re: [python-win32] How to get all the variables in a python shell

2008-05-29 Thread Tim Golden
[Bizarrely, my mail system seems to be randomly misfiring. If you've already seen this, please ignore!] Tim Golden wrote: Sorry, having seen Roger D's memcached suggestion, I realise I may have misinterpreted your requirement. I thought that you wanted a Python interpreter session to

Re: [python-win32] How to get all the variables in a python shell

2008-05-29 Thread Tim Golden
Tim Golden wrote: [EMAIL PROTECTED] wrote: I'm currently working on a scientific computation software built in python. What I want to implement is a Matlab style command window <-> workspace interaction. For example, you type 'a=1' in the command window, and you see a l

Re: How to get all the variables in a python shell

2008-05-29 Thread Tim Golden
[EMAIL PROTECTED] wrote: I'm currently working on a scientific computation software built in python. What I want to implement is a Matlab style command window <-> workspace interaction. For example, you type 'a=1' in the command window, and you see a list item named 'a' in the workspace. You dou

Re: Finding file details...

2008-05-29 Thread Tim Golden
Kalibr wrote: I've been trying to figure out how to find the details of files (specifically music for now) for a little sorting script I'm making, My aim is to get details on the artist, album, and genre for mp3 and wma files (possibly more in the future). My closest match was when I stumbled acc

Re: run a script in vista

2008-05-29 Thread Tim Golden
Graham Feeley wrote: Hi, I have a script which runs in xp, however now I have upgraded to vista this script now does'nt work Can someone help with this problem please ? this is the start of the script import cPAMIE import cModalPopUp import winGuiAuto as wga import time, datetime import os, sys

Re: How to get all the variables in a python shell

2008-05-29 Thread Tim Golden
[EMAIL PROTECTED] wrote: I'm currently working on a scientific computation software built in python. What I want to implement is a Matlab style command window <-> workspace interaction. For example, you type 'a=1' in the command window, and you see a list item named 'a' in the workspace. You dou

Re: UTF problem?

2008-05-25 Thread Tim Golden
Vesa-Matti Sarenius wrote: I am trying to set up Linux printing via Windows XP and using this HOWTO: http://justin.yackoski.name/winp/ I have one problem. When I send a file via CUPS to the windows spool directory dirwatch.py (http://justin.yackoski.name/winp/dirwatch.txt) dies and gives: Unic

Re: Showing the method's class in expection's traceback

2008-05-22 Thread Tim Golden
Agustin Villena wrote: I don't see things like you, because I'm accustomed to design my software though classes and see the code in an "object = software's functional atom/component" way I agree that python's dynamic nature make things complicated here, but for me it its just an implementation pr

Re: List of disk drives on Windows?

2008-05-20 Thread Tim Golden
Bob Greschke wrote: This MUST have been asked before, but I can't seem to Google the right thing. How can I get a list of drives on a Windows box, like ["C:\", "D:\"], like I can if I do something like listdir("/Volumes") on a Mac? A couple of options to get the ball rolling: 1) win32api.Get

Re: Using Python for programming algorithms

2008-05-19 Thread Tim Golden
Bruno Desthuilliers wrote: 2/ actually, all known Python implementations compile to byte-code. In curiosity, did your "actually" mean, in the French sense, "at the moment" or, in the English sense, "in contrast to something stated earlier"? Or maybe both? TJG -- http://mail.python.org/mailma

Re: Problem creating a shorcut

2008-05-16 Thread Tim Golden
Duncan Booth wrote: It's not too hard to get the required command line from the registry: import _winreg print _winreg.QueryValue(_winreg.HKEY_CLASSES_ROOT, 'FirefoxURL\shell\open\command') and of course it throws an exception if firefox isn't installed. Then just replace %1 with the url t

<    4   5   6   7   8   9   10   11   12   13   >