Re: Using Excel With Python
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
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
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
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
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
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 isnot 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
Automate Mozilla Firefox
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
Re: Automate Mozilla Firefox
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
PAMIE error help needed
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
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
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
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
try os.spawn() using the os module -- http://mail.python.org/mailman/listinfo/python-list
Tkinter
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
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 runAutomation 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) #createCI 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
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
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
Tail a file
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 (win)
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
search a string
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
search files in a directory
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
whitespace again
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=92005851PanelId=mayflowerPanelName=Consumer Input ToolbarCaptureType=dword:0002 CapTypOvr=dword:0001ExePath=C:\\Program Files\\Consumer Input Toolbar\\ConsumerInputToolbar.exeDcaVer=dword:0640DcaUpdateVer=dword:0640 CfgVer=dword:0640RulesVer=dword:0008UaCheck=dword:005aSurvey=dword:0001ErrWaitMin=dword:0001ErrWaitMax=dword:0002 KeepAlive=dword:0001PerfEnabled=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
ping
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 + xprint 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
re: ping
Thanks, Unfortunately substituting os.system with os.popen results in the output being: open file 'ping www.google.com', mode 'r' at 0x009C4650open file 'ping www.boston.com', mode 'r' at 0x009C4650 open file 'ping www.espn.com', mode 'r' at 0x009C4650 open file 'ping 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
Remove Whitespace
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
Regular Expressions
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
Re: Regular Expressions
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 forDcaVer and then after finding it get the numerical value associated with it. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Spawn/Kill Process
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
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
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
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 startupwait(ie)#wait for IE to completetly load pagestoptime = time.clock()#get timestamp at IE completion elapsed = stoptime-starttime#calculate the runtimeie.QUIT()xlApp.ActiveSheet.Cells(Row,1).Value = x xlApp.ActiveWorkbook.ActiveSheet.Cells(Row,2).Value = elapsedRow = 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
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