473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using PAMIE to upload and download files...is it possible?

Ive been using PAMIE 1.4 to try to automate web page processes. The one
thing I cannot do with it is upload files and download files.

With uploading files, the file input box does not allow PAMIE to enter
in a path to a file.

With downloading files, I can click on the link to download the file,
but thats where I get stuck at. It brings up that download window and
then it brings up the where to save window.

Theres no errors that I encounter when I get stuck at these spots it
justs sits there not knowing what to do.

If anyone has had success in both uploading or downloading or even some
insight, I would greatly appreciate your help. Thanks!

Jul 19 '05 #1
10 3196
As I understand it, newer versions of IE have uploading and downloading
via script disabled as a security measure. You might be able to do some
low-level API calls to deal with the download window.

Roger

"scrimp" <sc*******@yahoo.com> wrote in message news:11*********************@g44g2000cwa.googlegro ups.com...
Ive been using PAMIE 1.4 to try to automate web page processes. The one
thing I cannot do with it is upload files and download files.

With uploading files, the file input box does not allow PAMIE to enter
in a path to a file.

With downloading files, I can click on the link to download the file,
but thats where I get stuck at. It brings up that download window and
then it brings up the where to save window.

Theres no errors that I encounter when I get stuck at these spots it
justs sits there not knowing what to do.

If anyone has had success in both uploading or downloading or even some
insight, I would greatly appreciate your help. Thanks!


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 19 '05 #2
You are opening up the file open dialog when you are trying to do this
right?
If so you will need to use winguiauto. To find the dialog and the use
it to enter the info you want.

I included some code that shows how to do this. One other problem you
are going to have is that these dialogs are called by ie. pamie uses
com to control ie. So the button click will not return antell after
you have delt with the dialog box. Best way to deal with this is to
span a new thred befoe you click the button to deal with the dialog.

def useSaveASDialog(filePath=None):
....."""
.....This function sets the file path if it is spesified then
.....saves the file to the location listed it will return the
.....file path of the saved file.
.....or None if the file didn't get saved for some reason.
....."""
.....rVal = None
.....handle = winGuiAuto.findTopWindow("save as")
.....sButton = winGuiAuto.findControl(handle,"&Save","Button")
.....sEdit = winGuiAuto.findControl(handle, None, "Edit")
.....if filePath != None:
.........winGuiAuto.setEditText(sEdit, filePath)
.....rVal = winGuiAuto.getEditText(sEdit)
.....winGuiAuto.clickButton(sButton)
.....return rVal
def useChooseFileDialog(filePath=None):
....."""
.....This function sets the file path if it is spesified then
.....saves the file to the location listed it will return the
.....file path of the saved file.
.....or None if the file didn't get saved for some reason.
....."""
.....rVal = None
.....sButton = None
.....handle = winGuiAuto.findTopWindow("Choose file")

.....sButton = winGuiAuto.findControls(handle,"&Open","Button")
.....print sButton
.....sEdit = winGuiAuto.findControl(handle, None, "Edit")
.....if filePath != None:
.........winGuiAuto.setEditText(sEdit, filePath)
.....rVal = winGuiAuto.getEditText(sEdit)
.....winGuiAuto.clickButton(sButton[1])
.....return rVal

Hope this was of help to you.

Erin.

Jul 19 '05 #3
Thank you. I will try to come up with something I will post more if I
have any other questions. Thanks

Jul 19 '05 #4
Yes, you should be able uploads and downloads, but you have to import
modaltest which uses WinGuiAuto to do this. This also handles pop-ups
ModalTest.py is in the files section of the Pamie Users Group
http://pamie.sourceforge.net.

You have to sign up as a member to access the file. Membership is free.

It uses threading to allow you to upload and download and then continue
on with your test. I will be incorporated into PAMIE 1.6

Let me know if you runn into any problems!
RL Marchetti
scrimp wrote:
Thank you. I will try to come up with something I will post more if I
have any other questions. Thanks


Jul 19 '05 #5
This is your code I used...I didnt change anything from it

def useSaveASDialog(filePath=None):
from watsup.winGuiAuto import findTopWindow,findControl,setEditText
from time import sleep

rVal = None
handle = winGuiAuto.findTopWindow("Save As")
sButton = winGuiAuto.findControl(handle,"&Save","Button")
sEdit = winGuiAuto.findControl(handle, None, "Edit")
if filePath != None:
winGuiAuto.setEditText(sEdit, filePath)
rVal = winGuiAuto.getEditText(sEdit)
winGuiAuto.clickButton(sButton)
return rVal

So, in the interactive window I make an instantiation of it and this is
what I get

r = useSaveASDialog("C:\Downloads")
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\My Documents\python scripts\mytest1.py", line 6, in
useSaveASDialog
handle = winGuiAuto.findTopWindow("Save As")
File "C:\PYTHON23\lib\site-packages\watsup\winGuiAuto.py", line 158,
in findTopWindow
raise WinGuiAutoError("No top level window found for wantedText=" +
WinGuiAutoError: No top level window found for wantedText='Save As',
wantedClass=None, selectionFunction=None, maxWait=1, retryInterval=0.1

So, I fire up IE manually and find a link to click on that brings up
the download window and the first window I run into is the File
Download window with an Open, Save, Cancel, and More Info buttons. I
click on Save and that brings up the Save As window, so from there I go
back to PythonIDE and do the same command in the window and it
PythonIDE crashes. The weird thing is though it puts the path inside
the Filename text box. Just the path without the file. Ill be testing
this more next week, so ill get back with you then. Thanks for the
start though!!

--Barry

Jul 19 '05 #6
I dont see the modaltest.py would u please send me a link to it. I
still have not been able to gets winGuiAuto to work. I have pamie
logging into a site, navigating to the downloads section, and clicking
the link of the file to download and it stops right there.

I am downloading a zip file and there are two windows that come up. The
first one is the File download window in which it asks to either Open,
Save, Cancel, or More Info and then after clicking Save it brings up
another window Save As and asks where you want the file This is my
code:

rVal = None
dnldpath = "C:\\"
dnld = findTopWindow("File Download")
btnSave = findControl(dnld, "&Save", "Button")
clickButton(btnSave)

save = findTopWindow("Save As")
btnSave2 = findControl(save, "&Save", "Button")
editPath = findControl(save, None, "Edit")
if dnldPath != None:
setEditText(editPath, dnldPath)
rVal = getEditText(editPath)
clickButton(btnSave2)

and then I just quit IE right after that. Thanks again!

Jul 19 '05 #7
So here is a class that should do what you want. I don't use pamie we
use a in house python ie driver. But it has the same problem. Here is
a class that should do what you want.

import winGuiAuto
import threading
class SaveAsDocDialog (threading.Thread):
.....'''Some Internet Explorer dialog windows will halt all other
.....IE functionality until they are populated. This class is
.....used to handle these dialog windows.
.....This little class saves a document to the pc'''
.....def __init__(self, docPath):
.........'''The constructor method.'''
.........threading.Thread.__init__(self)
.........self.windowName = "Save As"
.........self.hwnd = None
.........self.document = docPath

.....def fetchWindow (self,attempts=20):
.........'''Grab the handle of the dialog window'''
.........tries = 0
.........while tries<attempts:
.........tries = tries + 1
.........try:
.............self.hwnd = winGuiAuto.findTopWindow(self.windowName)
.............return
.........except:
.............print 'Checking for window named "'+ self.windowName + '"',
.............print 'Attempt #',tries
.............time.sleep(1)
.....def run (self):
.........'''Overriding the "run" method for threading.'''
.........self.fetchWindow()
.........oButtons = winGuiAuto.findControls(self.hwnd,"&Save","Button" )
.........fText = winGuiAuto.findControl(self.hwnd,None,"Edit")
.........winGuiAuto.setEditText(fText,self.documen t)
.........time.sleep(0.5)
.........for oButton in oButtons:
.............winGuiAuto.clickButton(oButton)
#usage
saveAS = SaveAsDocDialog("c:\\test.txt")
saveAS.start()
#here you put the action that opens up the save as dlg
#have no clue what the pamie call would be.
saveAS.join()
Hope this was of help to you.

Jul 19 '05 #8
Theres one problem with the code that I saw off the bat. My PAMIE
script takes IE all the way up the window thats called "File Download".
It has 4 buttons Open, Save, Cancel, More Info. The code u gave to me
is for the next window I reach AFTER I click manually on Save. It
brings up the Save As window.

Anyways, I did the PAMIE part manually and the Save As window was open
waiting for the SaveAsDocDialog to click Save. It never did, in fact
all it did was freeze up python and crash it. So, im still at a stand
still here.

I know for sure my PAMIE part of the code works. It gets me to where I
need to use winGuiAuto. winGuiAuto just sits there and does nothing for
me. The window name "File Download" does NOT work for me. I have no
idea where or how to find the className of the window.

Again, thanx for all the help. Ill keep on trying it though

Jul 19 '05 #9
Well, thanx to Erin I got everything I needed to do to work.

I basically used 2 classes and wrote a driver using PAMIE
1 for the two File Download windows and 1 for the Save As window

Here are the classes I used. I took out the comments, but its really
not too hard to understand
class FileDownloadDialog (threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.windowName = "File Download"
self.hwnd = None

def fetchWindows (self,attempts=20):
tries = 0
while tries<attempts:
tries = tries + 1
try:
self.hwnd = winGuiAuto.findTopWindows(self.windowName)
return
except:
print 'Checking for window named "'+ self.windowName + '"',
print 'Attempt #',tries
time.sleep(1)

def run (self):
self.fetchWindows()
oButton = []
for hw in self.hwnd:
tButton = winGuiAuto.findControls(hw,"&Save","Button")
if len(tButton) <> 0:
wHwnd = hw
self.hwnd = wHwnd
oButtons = winGuiAuto.findControls(self.hwnd,"&Save","Button" )

time.sleep(0.5)
for oButton in oButtons:
winGuiAuto.clickButton(oButton)

Heres the 2nd class I used
class SaveAsZipDialog (threading.Thread):
def __init__(self, docPath):
threading.Thread.__init__(self)
self.windowName = "Save As"
self.hwnd = None
self.document = docPath

def fetchWindow (self,attempts=20):
tries = 0
while tries < attempts:
tries = tries + 1
try:
self.hwnd = winGuiAuto.findTopWindow(self.windowName)
return
except:
print 'Checking for window named "'+ self.windowName +
'"',
print 'Attempt ',tries
time.sleep(1)
def run (self):
self.fetchWindow()
fText = winGuiAuto.findControl(self.hwnd, None, "Edit")
winGuiAuto.setEditText(fText,self.document)
oButtons = winGuiAuto.findControls(self.hwnd,"Save")
time.sleep(0.5)
for oButton in oButtons:
winGuiAuto.clickButton(oButton)

I used PAMIE to get me through the web stuff and when it clicked on the
link to download the zip file I wanted these two classes would kick in
and take over from there. If anyone needs help feel free to email me or
post up on here. Thanks again Erin!

--Barry

Jul 19 '05 #10
If you go into the PAMIE users group
and go to the files Section you will see
modalPopupTest.py this will handles Uploads, pop-ups, alerts using
PAMIE

PAMIE will include this feature in the next release

http://groups.yahoo.com/group/Pamie_UsersGroup/files/

RLM

scrimp wrote:
Well, thanx to Erin I got everything I needed to do to work.

I basically used 2 classes and wrote a driver using PAMIE
1 for the two File Download windows and 1 for the Save As window

Here are the classes I used. I took out the comments, but its really
not too hard to understand
class FileDownloadDialog (threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.windowName = "File Download"
self.hwnd = None

def fetchWindows (self,attempts=20):
tries = 0
while tries<attempts:
tries = tries + 1
try:
self.hwnd = winGuiAuto.findTopWindows(self.windowName)
return
except:
print 'Checking for window named "'+ self.windowName + '"',
print 'Attempt #',tries
time.sleep(1)

def run (self):
self.fetchWindows()
oButton = []
for hw in self.hwnd:
tButton = winGuiAuto.findControls(hw,"&Save","Button")
if len(tButton) <> 0:
wHwnd = hw
self.hwnd = wHwnd
oButtons = winGuiAuto.findControls(self.hwnd,"&Save","Button" )

time.sleep(0.5)
for oButton in oButtons:
winGuiAuto.clickButton(oButton)

Heres the 2nd class I used
class SaveAsZipDialog (threading.Thread):
def __init__(self, docPath):
threading.Thread.__init__(self)
self.windowName = "Save As"
self.hwnd = None
self.document = docPath

def fetchWindow (self,attempts=20):
tries = 0
while tries < attempts:
tries = tries + 1
try:
self.hwnd = winGuiAuto.findTopWindow(self.windowName)
return
except:
print 'Checking for window named "'+ self.windowName +
'"',
print 'Attempt ',tries
time.sleep(1)
def run (self):
self.fetchWindow()
fText = winGuiAuto.findControl(self.hwnd, None, "Edit")
winGuiAuto.setEditText(fText,self.document)
oButtons = winGuiAuto.findControls(self.hwnd,"Save")
time.sleep(0.5)
for oButton in oButtons:
winGuiAuto.clickButton(oButton)

I used PAMIE to get me through the web stuff and when it clicked on the
link to download the zip file I wanted these two classes would kick in
and take over from there. If anyone needs help feel free to email me or
post up on here. Thanks again Erin!

--Barry


Jul 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eivind Lie Nitter | last post by:
Hello, I'm currently making a CMS for my company, and in the CMS, the user has the possibility to upload any file to a documents folder - both for having a document archive and uploading pdf /...
2
by: Ivo Tcholakov | last post by:
Hello, I created an application where the users need to download files. I have the list of the files stored in a database and I present the list to download in a Datagrid. Here comes my question....
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
7
by: Visitor No 3 | last post by:
My local Crinkles group(U3A), of which I am one, want me to develop a noddy database and web site for their members. Some are computer literate, others not so. I thought an Access 2000 .mdb on a...
6
by: vbnewbie | last post by:
Hi all, I need to include an upload/download feature to my VB 2005 application. Files will be uploaded and downloaded to and from a web site. Can someone guide me towards some articles or...
221
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application...
7
by: Rozzy | last post by:
Hi, I need some recommendations for uploading files to the server. Right now I have a php script that uses ftp to upload, download, and delete files, and everything works fine for small files. ...
3
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.