Compare content of two XML files

2009-08-18 Thread David Brochu
I need to compare a REST XML response with a 'gold standard' response (one
that we have already verified is correct). The problem is, sometimes the
REST response comes back and it is logically correct, but the order of
attributes and elements is different than what is in the 'gold standard'
file. For example:

'Gold Standard':









REST Response:








Notice how the attributes in  and  are in different order. The
response is correct, but obviously doesn't match the 'gold standard'.

Does anyone know how I would be able to compare these two files and verify
they match, even though the order of attributes and elements may be
different between the two? Is there a module I should be using for this?
-- 
http://mail.python.org/mailman/listinfo/python-list


comparing XML files to eachother

2009-08-17 Thread David Brochu
I need to compare one xml document to another to see if the content matches.
Unfortunately, the formatting (spacing) and order of elements may change
between files from run to run. I have looked into xml dom minidom but can't
seem to find how to accomplish this. Does anyone know how I can do a compare
between two XML documents using the STL?
-- 
http://mail.python.org/mailman/listinfo/python-list


httplib headers

2009-07-30 Thread David Brochu
Using the following code I am trying to pass a header to my POST request.
(Note: urls masked)

file = sys.argv[0]
url = sys.argv[1]
conn = httplib.HTTPConnection("XX.XXX.XX.XXX",)
headers = {'content-type':'application/xml'}
conn.request("POST",url,file,headers)
response = conn.getresponse()
head = response.getheaders()
status = response.status
response = response.read()
print response, status, head

When I run this script and view the headers that get printed the following
displays:

[('content-length', '691'), ('proxy-connection', 'Keep-Alive'),
('connection', 'Keep-Alive'), ('pragma', 'no-cache'), ('cache-control',
'no-cache'), ('content-type', 'text/html; charset=utf-8')]
Why isn't my content-type header using the value I pass in from headers?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Increment Variable Name

2008-01-25 Thread David Brochu
Basically what I am trying to do is pass each value from a list to  
the following line of code (where XXX is where I need to pass each  
value of the list


tests = easygui.multchoicebox(message="Pick the test(s) you would  
like to run from the list below."

, title="Validation Tests"
,choices=[XXX])

If i were to manually pass values to this line it would appear like :
tests = easygui.multchoicebox(message="Pick the test(s) you would  
like to run from the list below."

, title="Validation Tests"
,choices=["Test 1","Test 2", "Test 3"])

When I actually pass the list to the line of code, it works, however  
it doesn't really split the list by element. The desired output of  
this line of code would be a GUi that included a list consisting of  
each element from the passed list. Right now I can only get it to  
consist of a single element that contains every part of the list.


Does this make sense?-- 
http://mail.python.org/mailman/listinfo/python-list

Increment Variable Name

2008-01-23 Thread David Brochu
This is probably really trivial but I'm stumped :-(

Does anyone know how to increment a variable name?

For example:

I know the length of a list and I want to pass each element of a list  
to a unique variable, thus I want to increment variable names. If the  
list length = 4, i want to have the following variables: var1, var2,  
var3, var4.


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


Re: os.system questions

2007-03-31 Thread David Brochu








From: "Eric Price" <[EMAIL PROTECTED]>
Date: March 31, 2007 9:38:53 AM EDT
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Cc: python-list@python.org
Subject: Re: os.system questions


Oops! The problem isn't in the os.system call. It's in the fact  
that I don't call the function. That is, I write a script called  
"test.py" with a function in it called "freshReboot". Now, how do I  
call that function from test.py? That is, how do I write a cron  
event such that "freshReboot" actually gets called when I run test.py?

TIA,
Eric



>>> Eric - to call a function that is located inside another module  
you first need to import that module into the program you are running:



from test.py import * # this would import all functions from test.py
from test.py import freshReboot # this will import freshReboot from  
test.py



to call freshReboot in your program you would simply call it by it's  
name freshReboot


ex: x = freshReboot()-- 
http://mail.python.org/mailman/listinfo/python-list

PyFit documentation

2007-02-27 Thread David Brochu

I am trying to run some testing using Fitnesse with the PyFit python module.
For some reason I am not able to import the fit.ColumnFixture module from
PyFit. I use the following command:

from fit.ColumnFixture import ColumnFixture

I can't find any documentation on the web for PyFit syntax. Anyone know
where I might find documentation so I can see if this is, or ever was, a
valid module?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: book for a starter

2007-02-27 Thread David Brochu

From: "Wensui Liu" <[EMAIL PROTECTED]>
To: python-list@python.org
Date: Tue, 27 Feb 2007 10:09:57 -0500
Subject: book for a starter
Good morning, all,

[I just start learning python and have a question regarding books for a
newbie like me.
If you are only allowed to buy 1 python book, which one will you pick? ^_^.

Thank you so much!]

- If your new to programming I would recommend reading Learning Python
(O'Reilly). Along with that the tutorial by Guido on the Python website is a
good foundation. If you have programming experience I would recommend Dive
Into Python.

Either way you probably should have Learning Python and/or Programming
Python on your bookshelf for reference if you are going to really program
using Python.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Making a simple script standalone

2007-01-17 Thread David Brochu

Hi,
I'm new to this group. I've tried finding my answer in existing messages,
but no such luck.

What I want to do is to compile/bundle/prepare/whatever_term a simple
Python script for deployment on a Windows machine. Installing Python
itself on that machine, is not an option. Ideally I would like to obtain
a single executable file, but a script+runtime is acceptable.

There is nothing graphical, nothing fancy about the script.
The only imports are: os, stat, string and time.


Any suggestions on an - easy and clear - path to follow ?




cx_Freeze was not mentioned so far. its perhaps most easy and clear.



Robert

[You might also look into Py2Exe - http://www.py2exe.org/ I have used this
before and it wasn't too difficult to bundle everything up into 1 exe file.
Definately read the tutorial]

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

Re: Python-list Digest, Vol 40, Issue 215

2007-01-17 Thread David Brochu

How is it that when I try to send out a valid response to help someone with
their python issue I get flagged, but this guy can send out something
totally useless to the python community?






-- Forwarded message --
From: [EMAIL PROTECTED] (David Bostwick)
To: python-list@python.org
Date: Wed, 17 Jan 2007 18:42:35 GMT
Subject: Re: *POLL* How many sheeple believe in the 911 fairy tale and
willing to accept an Orwellian doublespeak and enslavement world ?
In article <[EMAIL PROTECTED]>, "Robert
Hicks" <[EMAIL PROTECTED]> wrote:
>Please, none of the real facts points to anything else except what
>actually happened. Two planes hit two towers and they came down.
>

You're talking to the wind.  This is a conspiracy precisely because people
deny the crackpots.  Denial of their "evidence" proves that there is a
coverup.  Logic is not involved, only belief that doesn't respond to
dissenting evidence.




-- Forwarded message --
From: "Carroll, Barry" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>, 
Date: Wed, 17 Jan 2007 10:50:20 -0800
Subject: RE: *POLL* How many sheeple believe in the 911 fairy tale and
willingto accept an Orwellian doublespeak and enslavement world ?

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 17, 2007 10:23 AM
> To: python-list@python.org
> Subject: Re: *POLL* How many sheeple believe in the 911 fairy tale and
> willingto accept an Orwellian doublespeak and enslavement world ?
>
>
> > ... buildings collapse all the time when you design to the
cold-formed
> > strength rather than the hot-formed strength of a material, then
heat
> > the material removing its tempered strength (which for steel occurs
at
> > much lower than usual flame temeratures).
>
> Actually, modern steel frame buildings have never collapsed from
> kerosine fire.
> Besides there are SERIOUS anomalies indicative of thermate and
> explosives.
> Yellow hot molten metal were seen trickling down less than hour after
> the fires.
> Red hot molten metal pools were seen in the rubble weeks after the
> collapse.
> The building and their contents pulverized to dust from the brisance
of
> very well
> planted and hidden explosives. I was not aware that Alqaeda has
> invisible man
> technology past the security cameras.
>
> > And what did this rant have to do with any of the sci.* or
programming
> > newsgroups you posted it to?
>
> Your ignoramus is the exact reason why this has to be posted there.
>
> > David A. Smith
>
> And why did bldg 7 commit suicide. How was the boeing767 maneouvered
> so close to the ground into pentagon?
>
> Where is the DNA to confirm the identities of 19 in the fairy tale?
>
> Do you work for the story writing agency ?
>
Ladies and Gentlemen:

PLEASE take this discussion to a more appropriate forum.  There are many

forums where people will be happy to debate this: physics, firefighting,
metallurgy, geopolitics, etc.  This forum is about the Python
programming language.  Let's keep it that way.

Regards,

Barry
[EMAIL PROTECTED]
541-302-1107

We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed






-- Forwarded message --
From: "Carroll, Barry" <[EMAIL PROTECTED]>
To: "Robert Hicks" <[EMAIL PROTECTED]>, 
Date: Wed, 17 Jan 2007 10:53:06 -0800
Subject: RE: *POLL* How many sheeple believe in the 911 fairy tale and
willingto accept an Orwellian doublespeak and enslavement world ?
> -Original Message-
> From: Robert Hicks [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 17, 2007 10:33 AM
> To: python-list@python.org
> Subject: Re: *POLL* How many sheeple believe in the 911 fairy tale and
> willingto accept an Orwellian doublespeak and enslavement world ?
>
> Please, none of the real facts points to anything else except what
> actually happened. Two planes hit two towers and they came down.
>
Ladies and Gentlemen:

PLEASE take this discussion to a more appropriate forum.  There are many

forums where people will be happy to debate this: physics, firefighting,
metallurgy, geopolitics, etc.  This forum is about the Python
programming language.  Let's keep it that way.

Regards,

Barry
[EMAIL PROTECTED]
541-302-1107

We who cut mere stones must always be envisioning cathedrals.

-Quarry worker's creed






-- Forwarded message --
From: "Robert Hicks" <[EMAIL PROTECTED]>
To: python-list@python.org
Date: 17 Jan 2007 10:54:54 -0800
Subject: Re: *POLL* How many sheeple believe in the 911 fairy tale and
willingto accept an Orwellian doublespeak and enslavement world ?

>
> Regards,
>
> Barry
> [EMAIL PROTECTED]
> 541-302-1107
> 
> We who cut mere stones must always be envisioning cathedrals.
>
> -Quarry worker's creed

Sure, but did you actually post your phone number on USENET?

Robert





-- Forwarded message --
From: "Emin" <[EMAIL PROTECTED]>
To: python-list@pyth

Re: Using Excel With Python

2007-01-11 Thread david brochu jr

Try using ExcelApp.Close(). This should kill the entire application (it
might prompt for a Save).
-- 
http://mail.python.org/mailman/listinfo/python-list

PyCon 07

2006-12-07 Thread david brochu jr

Anyone able to register yet for PyCon07? I can't find any link online..I
want to get in early to lock in on the cheaper registration rate..any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Ensure a variable is divisible by 4

2006-12-05 Thread david brochu jr

You can use the modulous "%" to check for a remainder of division. If no
remainder is found you know the number is divisible by 4.

Ex:

x = 111

if x%4 == 0:
  print "X is divisible by 4"

-- Forwarded message --
From: "John Machin" <[EMAIL PROTECTED]>
To: python-list@python.org
Date: 5 Dec 2006 11:26:49 -0800
Subject: Re: Ensure a variable is divisible by 4

Paul Rudin wrote:

Max M <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] skrev:
>> Nick Craig-Wood wrote:
>>> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
  I am sure this is a basic math issue, but is there a better way to
  ensure an int variable is divisible by 4 than by doing the

following;


  x = 111
  x = (x /4) * 4
>
> X *= 4
>
> ;-)
>


x=4

:)


Ensure x is divisible by *any* non-zero integer:

x = 0

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

wait for keystoke

2006-08-30 Thread david brochu jr
I want to add a "press any key to continue" option to my script, where the script pauses until the users presses any key. Does anyone know how I would do this without having to add in an if statement in the middle of my existing script? Is there a method already to accomplish this?

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

Automate logging into page

2006-08-11 Thread david brochu jr
I am trying to automate logging a website and have been unsuccessful. The code below is supposed to log me into the site, but changing the username/password to an incorrect combination does not cause an error or crash to be seen. My goal is to log into this page and save the cookie from the page so that when I spawn IE and navigate to this site I will be logged in. I am using the urllib2 module. Any suggestions? 
import urllibimport urllib2url = ''values = {'id_l_email': 'X', 'id_l_password':'X'}data = "">req = urllib2.Request(url,data)response = urllib2.urlopen(req)the_page = response.read()
-- 
http://mail.python.org/mailman/listinfo/python-list

can't kill os.system process

2006-07-27 Thread david brochu jr
When I run the following code:
 
import os
 
file = "C:\\progra~1\\mozill~1\\firefox.exe www.google.com"
os.system(file)  # this will spawn Firefox and naviage to google.com
 
kill = "taskkill /f /im firefox.exe"
os.system(kill)  # this should kill Firefox instance that was just spawned
 
 
 
the script never gets to kill the insance of firefox. When I manually close Firefox, my cmd window indicates that the taskkill command was unsuccessful, which leads me to believe that after I open Firefox the system is not getting any indication that the command finished executing, which would result in Firefox not being killed. I also tried substituting "
os.system" with "os.popen" which did the same thing.
 
Anyone have an idea how I can kill the instance of Firefox?
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Automate Mozilla Firefox

2006-07-26 Thread david brochu jr
 want to take a text file (which has a list of urls) and have my script go through them 1 by one using Firefox. 
 
So for instance, if the first two urls in my list were: 
www.google.com
www.amazon.com
 
I would want to spawn firefox and load www.google.com. Once google loads, I would like to kill Firefox and restart it, this time with 
www.amazon.com loaded. I am basically running a stress test on a browser based product.

 
I have been able to do this in IE with no problems (Calling IE's COM object).I also have used the PAMIE module without a problem in IE. The problem is Firefox uses XPCOM and I have never worked with XPCOM, and thus havent worked with PyXPCOM before. Any insight will help. 

 
FYI: I did try writing a script which loads firefox from the command line and navigates to a site, but once I try to kill Firefox and move to the next url nothing happens:
 
import os
import time
 
file = open("C:\urls.txt")
 
for x in file:
   
   firefox = "C:\progra~1\mozill~1\firefox.exe "
   firefox = firefox + x
   os.system(firefox)
   time.sleep(10)
   taskkill = "taskkill /f /im firefox.exe"
   os.system(taskkill)
 
file.close () 
-- 
http://mail.python.org/mailman/listinfo/python-list

Automate Mozilla Firefox

2006-07-26 Thread david brochu jr
Hey everyone,I am trying to automate navigating to urls (all from a txt file) 1 at a time in Firefox and then killing firefox before navigating to the next. I think I might have to use PyXPCOM to do this but I have never used this package and cannot find any good resources on the net to help me along. Anyone have an idea as to how I would do this or have any good resources they could point me to?
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

PAMIE error help needed

2006-07-19 Thread david brochu jr
I have thrown together a script which reads a list or urls from a txt file and navigates to each url while recording how long it takes for the page to render completely using PAMIE. For some reason I randomly get crashes reporting: 

 

  File "c:\Python24\scripts\PAM.py", line 30, in IE_Invoke    ie.Navigate(url)  File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in__getattr__    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: InternetExplorer.Application.Navigate
The code I use to browse through the list;
for x in f:    ie = IE_Invoke(x)    starttime = time.clock()   #get timestamp at IE startup    wait(ie) #wait for IE to completetly load page    stoptime = time.clock()#get timestamp at IE completion
    elapsed = stoptime-starttime   #calculate the runtime    ie.QUIT()    excel_open.xlApp.ActiveSheet.Cells(Row,1).Value = x excel_open.xlApp.ActiveSheet.Cells(Row,2).Value = elapsed
        Row = Row+1    count_non_no_tool = count_non_no_tool + 1    total_non_no_tool = elapsed + total_non_no_tool 
 
    f = f.close()
 
The script crashes in different locations when it crashes so it doesn't appear to be one url causing the problem. Any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list

Python to log into web site

2006-07-18 Thread david brochu jr
Hi,
 
I have been browsing around the net looking for a way (hopefully an easily implemented module) to log into a web site using python. The site I wish to log into is an internal site which requires email address and password for authentication. Does anyone have any suggestions or links that might point me in the right direction?

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

newbe: tuple

2006-06-14 Thread david brochu jr
I am trying to get my ip address through a script and I am using the following code:
 
import socket
 
ip = socket.gethostbyaddr(socket.gethostname())
 
 
 
ip then becomes a tuple and takes on three values. I am trying to pull the value of ip[2] which when printed displays:
['10.5.100.17'].
 
I want this ip that is being returned, but I would like it as a string, without the [' and ']. Any idea how I would trim this down?
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

RSS feeds

2006-06-06 Thread david brochu jr
Not sure where to post this one so here it goes...sorry to anyone if it shouldnt be here.
 
I am looking to take RSS feeds a process them with a python program..any idea where I can get RSS feeds for sports stats, and how I would use the script to connect automatically to the feed?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Starting New Process

2006-06-05 Thread david brochu jr
try os.spawn() using the os module
-- 
http://mail.python.org/mailman/listinfo/python-list

Tkinter

2006-06-02 Thread david brochu jr
Does anyone know how to get the value of the file selected when using tk_getOpenFile in Tkinter?
-- 
http://mail.python.org/mailman/listinfo/python-list

Tkinter question

2006-05-31 Thread david brochu jr
I am trying to create a GUI that will display a new window with information about my program when the user clicks on the info button (a green "i" bitmap). So far all I can get my program to do is show the new window (using Toplevel() ) when the program loads, not when the user presses the information bitmap. I think it has something to do with my command for the information button. Anyone have any ideas or have a GOOD resource that they could point me to?

 
Thanks
 

from Tkinter import *
class Application(Frame):  """ A GUI application with three buttons. """    def __init__(self, master):    """ Initialize the Frame. """    Frame.__init__(self,master)
    self.grid()    self.create_widgets()     def update_text(self):    message = self.toolbar.get()    self.results.delete(0.0, END)    self.results.insert(0.0, message)      def create_widgets(self):
    # create variable for single toolbar selection    self.toolbar = StringVar()        """Create button, text and entry widgets. """    #create welcome text    welcome = Label(self)
    welcome["text"] = "You are now about to run Automation Testing.\n"\    "Please check the toolbar to be tested and then select\n"\    "the test you would like to perform."
        welcome.grid(row = 0, column = 0, columnspan = 3, sticky = W)        #create Upr Radio    Radiobutton(self, text = "Upr", variable = self.toolbar,    value = "upr", command = 
self.update_text).grid(row = 1, column = 0, sticky = W)        #create Com Radio    Radiobutton(self, text = "Com", variable = self.toolbar,    value = "com", command = self.update_text
).grid(row = 1, column = 1, sticky = W)        #create CI Radio    Radiobutton(self, text = "CI", variable = self.toolbar,    value = "ci", command = self.update_text).grid(row = 1, column = 2, sticky = W)
        #create text box    self.results = Text(self, width = 40, height = 4, wrap = WORD)    self.results.grid(row = 2, column = 0, columnspan = 3, sticky = W)            #create Performance button
    self.perf_bttn = Button(self)    self.perf_bttn["text"] = "Performance"    self.perf_bttn["command"] = self.perf    self.perf_bttn.grid(row = 3, column = 0, sticky = W) 
    message = self.toolbar.get()        #create PII button    self.pii_bttn = Button(self)    self.pii_bttn["text"] = "PII"    self.pii_bttn.grid(row = 3, column = 1, sticky = W)
        #create info button    self.info_bttn = Button(self)    self.info_bttn["fg"] = "green"    self.info_bttn["bitmap"] = "info"    self.info_bttn.command = self.info
()    self.info_bttn.grid(row = 3, column = 2, sticky = W)        #create exit button    self.exit_bttn = Button(self)    self.exit_bttn["fg"] = "red"    self.exit_bttn["cursor"] = "pirate"
    self.exit_bttn["text"] = "EXIT"    self.exit_bttn["command"] = root.quit    self.exit_bttn.grid(row = 3, column = 3, sticky = W)    def perf(self):    import performance
    performance.perf(self.toolbar.get())
      def info(self):    # create child window     win = Toplevel()                  # mainroot = Tk()root.title("Automation Testing")app = Application(root)
root.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list

making IE toolbars visible

2006-05-02 Thread david brochu jr
Anyone know how if there is a module out there or some way to automate making an IE toolbar visible in IE?
 
 
Thanks,
Dave
-- 
http://mail.python.org/mailman/listinfo/python-list

detect enter key

2006-04-28 Thread david brochu jr
I am writing a script in which I need to wait for the user to press enter before continuing...how would I detect when the user presses the "Enter" key?
 
 
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

search files in a directory

2006-04-20 Thread david brochu jr
Hello,
 
I need to open every file in a directory and search for a string. What module is needed to do this and how would I go about searching each file?
-- 
http://mail.python.org/mailman/listinfo/python-list

search a string

2006-04-20 Thread david brochu jr
Hello,
 
 
I have a text file with the following string:
['\r\n', 'Pinging www.ebayyy.com [207.189.104.86] with 32 bytes of data:\r\n', '\r\n', 'Request timed out.\r\n', '\r\n', 'Ping statistics for 
207.189.104.86:\r\n', '    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),\r\n']
 
 
How would I search to find out if the string contained "Request" and report if "Request" was found or not in the string?
-- 
http://mail.python.org/mailman/listinfo/python-list

tail a file (win)

2006-04-20 Thread david brochu jr
Hello,
 
I wrote a script to monitor ping activity and output it to a log file. I am using windows and want to have another script constantly check the latest entry to see if Request timed out is seen. Is there a way to "tail" a file much like I would in Unix so I can just see the latest entry and move from there? 

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

Tail a file

2006-04-20 Thread david brochu jr
Hello,
 
I wrote a script to monitor ping activity and output it to a log file. I am using windows and want to have another script constantly check the latest entry to see if Request timed out is seen. Is there a way to "tail" a file much like I would in Unix so I can just see the latest entry and move from there?

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

re: ping

2006-04-14 Thread david brochu jr

Thanks,
 
Unfortunately substituting os.system with os.popen results in the output being:
www.google.com', mode 'r' at 0x009C4650>
www.boston.com', mode 'r' at 0x009C4650> www.espn.com', mode 'r' at 0x009C4650>
www.redsox.com', mode 'r' at 0x009C4650> 
instead of giving me the ping stats "pinging etc etc, packets sent 4 recienved 4 etc)
 
Any idea around this? 
-- 
http://mail.python.org/mailman/listinfo/python-list

ping

2006-04-14 Thread david brochu jr
I am trying to ping websites and output the results to a txt file:
 

import os
file = open("c:\python24\scripts\ip.txt")redirect = open("c:\python24\scripts\log.txt","a")
for x in file: ping = "ping " + x print >> redirect, os.system(ping) 
but the results seen in the log.txt file are:

 
What am i doing wrong?? How do I fix this so I can see the ping statistics inside the log.txt file?
-- 
http://mail.python.org/mailman/listinfo/python-list

whitespace again

2006-04-14 Thread david brochu jr
hello again,
 
still having problemsi have the following in a txt file:
 

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\software\compete\dca]"UserId"="92005851""PanelId"="mayflower""PanelName"="Consumer Input Toolbar""CaptureType"=dword:0002
"CapTypOvr"=dword:0001"ExePath"="C:\\Program Files\\Consumer Input Toolbar\\ConsumerInputToolbar.exe""DcaVer"=dword:0640"DcaUpdateVer"=dword:0640
"CfgVer"=dword:0640"RulesVer"=dword:0008"UaCheck"=dword:005a"Survey"=dword:0001"ErrWaitMin"=dword:0001"ErrWaitMax"=dword:0002
"KeepAlive"=dword:0001"PerfEnabled"=dword:"PerfPath"="http://www.consumerinput.com.edgesuite.net/speedera/10k2.txt
"
I want to remove the "  found at the beginning of each line. When I use:
for line in new_line.readlines(): line = re.sub('"',"",line)  print line
I get: 
i n d o w s   R e g i s t r y   E d i t o r   V e r s i o n   5 . 0 0  
 
H K E Y _ L O C A L _ M A C H I N E \ s o f t w a r e \ c o m p e t e \ d c a ]  
U s e r I d " = " 9 2 0 0 5 8 5 1 "  
P a n e l I d " = " m a y f l o w e r "  
P a n e l N a m e " = " C o n s u m e r   I n p u t   T o o l b a r "  
C a p t u r e T y p e " = d w o r d : 0 0 0 0 0 0 0 2  
C a p T y p O v r " = d w o r d : 0 0 0 0 0 0 0 1  
E x e P a t h " = " C : \ \ P r o g r a m   F i l e s \ \ C o n s u m e r   I n p u t   T o o l b a r \ \ C o n s u m e r I n p u t T o o l b a r . e x e "  
D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0  
D c a U p d a t e V e r " = d w o r d : 0 0 0 0 0 6 4 0  
etc etc...Too much space...how do i get the same output with all the space..this is killing me please help
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Remove Whitespace

2006-04-13 Thread david brochu jr
Hi again,
 
Trying to remove whitespace from a string in a text file.
 
the string is:
D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0
 
how would i go about doing this?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expressions

2006-04-12 Thread david brochu jr
Pete,
Why do you have to use a regular _expression_?
I don't, I just though this was the easiest way.> "DcaVer"=dword:0640Is all your other input pretty much identical in form?  Specifically,the number of interest is the last thing on the line, and always
preceded by a colon? 
The other information is pretty much identical in form, yes. Exactally, all I am interested in is the number following the colon.
> What I need to do with that string is trim down " "DcaVer"=dword:" and> convert the remaining number from hex to dec.What does "trim down" mean?  Do you need something out of the string, or
are you just discarding/ignoring it?
 
What I meant was I want to discard the "DcaVer"=dword: . All I am interested in is searching for "DcaVer, finding it, and then taking the numerical value found after the colon.
s = '"DcaVer"=dword:0640'value = int(s.split(':')[-1], 16)(In other words, split on colons, take the last field and, treating itas a hex value, convert to an integer.)
 
The only problem with this is DcaVer's value is not always going to be the same, so I need to search specially for DcaVer and then after finding it get the numerical value associated with it. 
 
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

Regular Expressions

2006-04-12 Thread david brochu jr
Hi, 
 
I am trying to grab the following string out of a text file using regular _expression_ (re module):
 
"DcaVer"=dword:0640
 
What I need to do with that string is trim down " "DcaVer"=dword:" and convert the remaining number from hex to dec.
 
I have been trying to figure this out for a while..I am fairly new so please any help would be greatly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list

String Matching

2006-03-31 Thread david brochu jr
Hello,
 
I am trying to write a script that takes strings from a text file and searches to see if they are present in another text file...here is the code:
 
import osimport re

search = open("c:\python24\scripts\pii\expected_rules_results.txt")
def find(x): file = open("c:\python24\scripts\pii\dave.txt") regexp = re.compile(x) for line in file.readlines():  if regexp.search(line):   print "Found", x   break 
file.close()  
for x in search: find(x)search.close()
 
Unfortunately the strings I will be searching for contain numerous "*" that cause an error. For example, when try to search for:
http://www.widget.com/personal_firewall.csp/?pin={6}
I get the error message:
Traceback (most recent call last):  File "C:\Python24\scripts\PII\search    find(x)  File "C:\Python24\scripts\PII\search    regexp = re.compile(x)  File "C:\Python24\lib\sre.py", line
    return _compile(pattern, flags)  File "C:\Python24\lib\sre.py", line    raise error, v # invalid expressiosre_constants.error: multiple repeat
 
Anyone know how to get around this?
-- 
http://mail.python.org/mailman/listinfo/python-list

Spawn/Kill Process

2006-03-31 Thread david brochu jr
I need to write a script that starts an exe and then continues throughthe script. I am able to start the exe file but my script doesn'tcontinue because the process I start runs in the background of Windows(as it is supposed to). I have tried using both 
os.system and os.popento get around this but still no luck. It seems as if Python does notmove to the next line of code UNTIL the program spawned completes(which this one never will as it is supposed to continuously run in
the background). Does anyone know of a way around this so I can spawnthe program and continue through my script?
-- 
http://mail.python.org/mailman/listinfo/python-list

Popen

2006-03-30 Thread david brochu jr
I am trying to write a script that starts a window process and then continues on to do other testing, but have encountered a little problem. When I start the exe (process to run) I cannot move on past that point in my script. Once started, the process is supposed to run in the background continuously and this is the reason my script stalls after starting the process. I have tried to initiate the process using 
os.system and os.popen and both run into the same problem. Is there a work around for this?
 
Thanks,
Dave
-- 
http://mail.python.org/mailman/listinfo/python-list

Clearing IE history

2006-03-15 Thread david brochu jr
Hello
 
I am trying to automate the clearing of IE history using python but keep running into problems. I cannot seem to find a good resource online about this, and I can't find an object in InternetExplorer's object module to point me in the right direction. I would rather not have to deal with deleting a bunch of registry values and keys or paths to do this, as this script will be run on numerous machines.

 
Anyone have any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list

Excel Object Model

2006-03-10 Thread david brochu jr
Hello,
 
I am trying to automate Excel and I cant seem to find out much relating to it's object model (in relation to Python)..seems as if its mostly covered by C and VB. Can anyone point me in the right direction? I am able to open excel, add information to cells, and then save and close the book opened. I was looking to get into formatting of cells, formulas, etc.

 
Below is the code i have now...any responces would help.
 

import PAMimport timefrom win32com.client import Dispatch    #this is needed to open an Excel fileexecfile('c:\\Python24\\scripts\\PAM.py')f = open('c:\python24\scripts\urls.txt','r')  #opens list of urls to be tested
xlApp = Dispatch("Excel.Application")xlApp.Visible = 0xlApp.Workbooks.Add()Row = 1
for x in f:  #run this for every url in txt file. ie = IE_Invoke(x) starttime = time.clock()   #get timestamp at IE startup wait(ie) #wait for IE to completetly load page stoptime = time.clock()#get timestamp at IE completion
 elapsed = stoptime-starttime   #calculate the runtime ie.QUIT() xlApp.ActiveSheet.Cells(Row,1).Value = x  xlApp.ActiveWorkbook.ActiveSheet.Cells(Row,2).Value = elapsed Row = Row+1
xlApp.ActiveWorkbook.ActiveSheet.SaveAs('c:\\test_results\dave.xls') #save results to excel bookxlApp.Quit()  
-- 
http://mail.python.org/mailman/listinfo/python-list

PAMIE syntax

2006-03-09 Thread david brochu jr
Hi everyone,
 
I am trying to automate Internet Explorer and am trying to use the PAMIE module for Python2.4. So far I have been unable to find any documentation online which provides syntax for using thie module. For instance, does anyone know how to use PAMIE to close a browser instance?

 
 
Any info you have would be great!
-- 
http://mail.python.org/mailman/listinfo/python-list