Detecting open files and forcing closure

2009-01-09 Thread Andrew Robert
Hi Everyone, We have a process that does a copy of a share from one location to another. This usually works fine but can occasionally bomb if a file is opened by a user somewhere. Is there a way to code detection of open files and force a close? The files in question are typically PDF files

Re: Detecting open files and forcing closure

2009-01-09 Thread Andrew Robert
MRAB wrote: Andrew Robert wrote: Hi Everyone, We have a process that does a copy of a share from one location to another. This usually works fine but can occasionally bomb if a file is opened by a user somewhere. Is there a way to code detection of open files and force a close? The files

Re: newbie question: if var1 == var2:

2008-11-29 Thread Andrew Robert
Two issues regarding script. You have a typo on the file you are trying to open. It is listed with a file extension of .in when it should be .ini . The next issue is that you are comparing what was read from the file versus the variable. The item read from file also contains and

Re: question on python syntax

2007-09-10 Thread Andrew Robert
a.m. wrote: If I type this in shell $ ./yourfile.py 12:34 PM What does '$', '.', '/' and ' means in this succession? Note: 12:34 PM is a argument to the yourfile.py. This not python syntax but Unix shell. $ = shell prompt ./= look for the program in my current

Re: Python editor

2006-08-29 Thread Andrew Robert
[EMAIL PROTECTED] wrote: John Salerno wrote: Is it possible to get vim-python for Windows, or is that just a Linux build? It builds for windows. When installed, you may also want to consider the python add-on located at http://www.vim.org/scripts/script.php?script_id=790 Enhanced

Re: Middle matching - any Python library functions (besides re)?

2006-08-28 Thread Andrew Robert
Simon Forman wrote: Paul Rubin wrote: EP [EMAIL PROTECTED] writes: Given that I am looking for matches of all files against all other files (of similar length) is there a better bet than using re.search? The initial application concerns files in the 1,000's, and I could use a good solution

Re: Middle matching - any Python library functions (besides re)?

2006-08-28 Thread Andrew Robert
Simon Forman wrote: Andrew Robert wrote: Simon Forman wrote: Paul Rubin wrote: EP [EMAIL PROTECTED] writes: Given that I am looking for matches of all files against all other files (of similar length) is there a better bet than using re.search? The initial application concerns files

Question regarding commit/backout of a message using the pymqi module

2006-06-21 Thread Andrew Robert
Hi everyone, Could someone help explain what I am doing wrong in this code block? This code block is an excerpt from a larger file that receives transmitted files via IBM WebSphere MQSeries an drops it to the local file system. Transmission of the file works as designed but it has a flaw. If

Re: Newbie Question

2006-06-19 Thread Andrew Robert
Saint Malo wrote: I am new to programming, and I've chosen python to start with. I wrote a simple program that asks several questions and assings each one of them a variable via raw_input command. I then combined all the variables into one like this a = b + c + d. After this I wrote these

Re: __getattr__ question

2006-06-09 Thread Andrew Robert
If I remember correctly, this behavior depends on how the class is created (classic mode versus modern). Modern class foo(object): pass Classic ( pre python 2.2 I believe ) class foo(): pass The modern method of specifying object in the class

Re: what are you using python language for?

2006-06-08 Thread Andrew Robert
I use python and the pymqi module to work with IBM WebSphere MQSeries and IBM WebSphere Message broker. -- http://mail.python.org/mailman/listinfo/python-list

regex/lambda black magic

2006-05-25 Thread Andrew Robert
Hi everyone, I have two test scripts, an encoder and a decoder. The encoder, listed below, works perfectly. import re,sys output = open(r'e:\pycode\out_test.txt','wb') for line in open(r'e:\pycode\sigh.txt','rb') : output.write( re.sub(r'([^\w\s])', lambda s: '%%%2X' % ord(s.group()),

Re: regex/lambda black magic

2006-05-25 Thread Andrew Robert
Max Erickson wrote: snip /snip Try getting rid of the lamba, it might make things clearer and it simplifies debugging. Something like(this is just a sketch): max Yeah.. trying to keep everything on one line is becoming something of a problem. To make this easier, I followed something

Re: regex/lambda black magic

2006-05-25 Thread Andrew Robert
Hi Everyone, Thanks for all of your patience on this. I finally got it to work. Here is the completed test code showing what is going on. Not cleaned up yet but it works for proof-of-concept purposes. #!/usr/bin/python import re,base64 # Evaluate captured character as hex def

Conversion of perl based regex to python method

2006-05-24 Thread Andrew Robert
I have two Perl expressions If windows: perl -ple s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge somefile.txt If posix perl -ple 's/([^\w\s])/sprintf(%%%2X, ord $1)/ge' somefile.txt The [^\w\s] is a negated expression stating that any character a-zA-Z0-9_, space or tab is ignored. The ()

Re: how to change sys.path?

2006-05-24 Thread Andrew Robert
Dennis Lee Bieber wrote: On Wed, 24 May 2006 14:45:55 GMT, John Salerno [EMAIL PROTECTED] declaimed the following in comp.lang.python: I just right-clicked on My Computer -- Properties -- Advanced -- Environment Variables, and added a new one called PYTHONPATH. I don't know if that edits

Re: Conversion of perl based regex to python method

2006-05-24 Thread Andrew Robert
Andrew Robert wrote: I have two Perl expressions If windows: perl -ple s/([^\w\s])/sprintf(q#%%%2X#, ord $1)/ge somefile.txt If posix perl -ple 's/([^\w\s])/sprintf(%%%2X, ord $1)/ge' somefile.txt The [^\w\s] is a negated expression stating that any character a-zA-Z0-9_

Testing for file type

2006-05-22 Thread Andrew Robert
Hi Everyone, Is there a way to test if a file is binary or ascii within Python? I'd prefer not to text against file extension. Any help you can provide would be greatly appreciated. Thanks, Andy -- http://mail.python.org/mailman/listinfo/python-list

Class probkem - getting msg that self not defined

2006-05-22 Thread Andrew Robert
Hi Everyone, I am having a problem with a class and hope you can help. When I try to use the class listed below, I get the statement that self is not defined. test=TriggerMessage(data) var = test.decode(self.qname) I would have thought that self would have carried forward when

Re: Class probkem - getting msg that self not defined

2006-05-22 Thread Andrew Robert
wes weston wrote: Andrew Robert wrote: Hi Everyone, I am having a problem with a class and hope you can help. When I try to use the class listed below, I get the statement that self is not defined. test=TriggerMessage(data) self is not known here; only inside the class. var

File encoding strategy question

2006-05-20 Thread Andrew Robert
Hi everyone, I am in the process of creating a file transmit/receiver program using MQSeries. The way it works is through creation of an XML message. Elements within the XML message contain things such as file name, size, and the file contents. The file contents are encoded, currently using

Re: 'error reading datastream' -- loading file only when transfer is complete?

2006-05-20 Thread Andrew Robert
[EMAIL PROTECTED] wrote: hello -- i'm running python/pygame on maemo (nokia 770). my situation is that i'm continually scouring this one directory for incoming files. if i see if there's a new file (coming in via wireless scp), i proceed to load it and process it. however, i think i am

Conversion of perl unpack code to python - something odd

2006-05-18 Thread Andrew Robert
Hey everyone, Maybe you can see something I don't. I need to convert a working piece of perl code to python. The perl code is: sub ParseTrig { # unpack the ibm struct that triggers messages. my $struct = shift; my %data; @data{qw/StructID Version QName ProcessName TriggerData

Re: Conversion of perl unpack code to python - something odd

2006-05-18 Thread Andrew Robert
Peter Otten wrote: Andrew Robert wrote: format='4s 4s 48s 48s 64s 4s 256s 128s 128s 48s' You are trying to squeeze 10 items into just d1,d2=struct.unpack(format,data) two variables (d1 and d2) ValueError: too many values to unpack and Python is quite explicit that it doesn't

Re: number of different lines in a file

2006-05-18 Thread Andrew Robert
r.e.s. wrote: I have a million-line text file with 100 characters per line, and simply need to determine how many of the lines are distinct. On my PC, this little program just goes to never-never land: def number_distinct(fn): f = file(fn) x = f.readline().strip() L = []

Re: Option parser question - reading options from file as well as command line

2006-05-17 Thread Andrew Robert
Tim N. van der Leeuw wrote: Andrew Robert wrote: Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the individual swithces do not get passed to option

Process forking on Windows

2006-05-17 Thread Andrew Robert
Hi everyone, I have a python program that will need to interact with an MQSeries trigger monitor. It does this fine but it hogs the trigger monitor while it executes. I'd like to fork the program off and terminate the parent process so that the trigger monitor frees up. Does anyone how this

Re: Process forking on Windows

2006-05-17 Thread Andrew Robert
bruno at modulix wrote: Andrew Robert wrote: Hi everyone, I have a python program that will need to interact with an MQSeries trigger monitor. It does this fine but it hogs the trigger monitor while it executes. I'd like to fork the program off and terminate the parent process so

Re: Process forking on Windows - or what is MQSeries

2006-05-17 Thread Andrew Robert
Gary Herron wrote: Andrew Robert wrote: snip The windows CreateProcess call has many of the same semantics as the Unix fork, i.e., a new process is created sharing all the resources of the original process. The subprocess modules uses CreateProcess, but if that does not give you

Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Hi Everyone. I tried the following to get input into optionparser from either a file or command line. The code below detects the passed file argument and prints the file contents but the individual swithces do not get passed to option parser. Doing a test print of options.qmanager shows it

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Max Erickson wrote: Andrew Robert [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: snip \snip Check parser.usage, it is likely to look a lot like your infile. I'm not sure, but I think you need to pass your alternative arguments to parser.parse_args. max Hi Max, I tried

Re: Option parser question - reading options from file as well as command line

2006-05-16 Thread Andrew Robert
Max Erickson wrote: I don't know much about optparse, but since I was bored: help(o.parse_args) Help on method parse_args in module optparse: parse_args(self, args=None, values=None) method of optparse.OptionParser instance parse_args(args : [string] = sys.argv[1:],

Re: Question regarding checksuming of a file

2006-05-14 Thread Andrew Robert
When I run the script, I get an error that the file object does not have the attribute getblocks. Did you mean this instead? def getblocks(f, blocksize=1024): while True: s = f.read(blocksize) if not s: return yield s def

Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Good evening, I need to generate checksums of a file, store the value in a variable, and pass it along for later comparison. The MD5 module would seem to do the trick but I'm sketchy on implementation. The nearest I can see would be import md5 m=md5.new() contents =

Re: Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Actually, I think I got it but would like to confirm this looks right. import md5 checksum = md5.new() mfn = open(self.file_name, 'r') for line in mfn.readlines(): checksum.update(line) mfn.close() cs = checksum.hexdigest() print

Re: Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Roy Smith wrote: However this does not appear to be actually returning the checksum. Does anyone have insight into where I am going wrong? After calling update(), you need to call digest(). Update() only updates the internal state of the md5 state machine; digest() returns the hash.

MQSeries based file transfers using the pymqi module

2006-05-05 Thread Andrew Robert
Hi everyone, Has anyone developed a pymqi module based file transfer method for use with WebSphere MQSeries v5.3? If so, would it be possible to point me towards examples of how this was done? Any help that can be provided would be greatly appreciated. Thanks --

Using Python to interact with BMC Patrol

2005-09-07 Thread Andrew Robert
Hi Everyone, Has anyone done any Python coding to manage/interact/customize BMC Patrol? If anyone has, could you please point me to where I can find documentation/guides on this? I checked the Python SIGs and Vault of Parnasus but didn't see anything available. Any insight you might have on

Re: screen clear question

2005-01-05 Thread Andrew Robert
the resident OS the program is running against and set the clear command based on that. -- Thank you, Andrew Robert E-mail: [EMAIL PROTECTED] Ur: http://shardservant.no-ip.info -- http://mail.python.org/mailman/listinfo/python-list

Re: How to make executable file ?

2005-01-05 Thread Andrew Robert
. Details on it can be found at http://starship.python.net/crew/atuining/cx_Freeze/ Binaries are available for Linux and Windows. Alternately, source code is available if you need to compile it for a different platform. -- Thank you, Andrew Robert E-mail: [EMAIL PROTECTED] Ur: http

Re: Python mascot proposal

2004-12-13 Thread Andrew Robert
What about a dead camel? -- http://mail.python.org/mailman/listinfo/python-list