I try download a Left Join Query with 110 columns and 60.000 rows in a CSV. I am using GAE with python and i need that the download occurs when user click in one button of my portal, but make this is imposible because always appear the DeadLineError when I execute my code.
I try use:
rpc = urlfetch.create_rpc(deadline=10, callback=None)
urlfetch.set_default_fetch_deadline(10)
urlfetch.make_fetch_call(rpc, "url",method="POST")
But this don't function.
Please, can somebody give me a mind? It's obligatory than i use GAE with python. If it's necesary more information i can give it.
To overcome the DeadlineError, On button click create a task queue for generating CSV file and save it in Blobstore. Once the file generated, Display Blobserve URL using Channel API in your page. When user click the Download URL serve the blob.
More Info:
Serving a Blob , Channel API
Related
I am working on application where I am giving a functionality to user where they can signin from dropbox by using my application but when I am trying to get the file from Dropbox I am unable to do it. When user choose the desired file from dropbox and click on choose and then nothing happen. Can anyone please help out either is it possible to do it or not? If yes, how can we do it? I am at beginner level. Please help me out and explain the whole process to do it in detail.
Are you using public Dropbox files?
Then you just need to fetch the item by URL and download it. If this happens in a browser tool, you'll need JavaScript and not Python to download it.
Or you leave out JS and just use Python to render an HTML page where a button is for a Dropbox file and clicking the button triggers a download of the file. That is a generic HTML task you can search for.
If you need access to sign in Dropbox and view private files, consider using a Python library built around Dropbox.
See the Python Dropbox guide. Are you using a library like that? Please share as your question was vague.
https://www.dropbox.com/developers/documentation/python#
Also please share an explanation of what your logic is or a small code snippet. I can't see what you are doing yet so I don't know where you are missing something or making a mistake.
From the screenshot, I see you're using the Dropbox Chooser. That's a pre-built way to let your end-users select files from their Dropbox accounts and give them to your app.
Make sure you implement the success and cancel callback methods as documented there for the Chooser.
In the success callback, you'll get the information for the selected file(s). That occurs in JavaScript in the browser though, so if you need that on your server, you'll need to write some JavaScript to send that up to your server, e.g., via an AJAX call or a form or whatever means you use in your app.
So the issue I am having isn't that there is a link of a PDF on the web I am trying to scrape and download onto my PC (It doesn't end in .pdf). I have a download link that I want to activate, which would then lead me to download a PDF onto my computer. It looks like this:
https://***.com/files/4122109/download?download_frd=1&verifier=xxx
When I click the link, it verifies I am the user that I am, and then lets me download the file with the ID contained in the above query. The content-type for this file is "application/pdf" so I know it downloads a PDF file for me. I just need a library that "clicks" or "activates" the download for me.
Also, I am trying to do this for all the URLs I am pulling from a course on Canvas in a GET request. I am not trying to use Selenium here because I am getting these URLs from an API. Any advice in this approach would be highly appreciated.
I have tens of thousands of URLs which I want to save their webpages to my computer.
I'm trying to open and save these webpages using Chrome automated by pywinauto.
I'm able to open the webpages using the following code:
from pywinauto.application import Application
import pyautogui
chrome_dir = 'C:\Program Files\Google\Chrome\Application\chrome.exe'
start_args = ' --force-renderer-accessibility --start-maximized https://pythonexamples.org/'
app = Application(backend="uia").start(chrome_dir+start_args)
I want to further send a shortcut to the webpage to save it as a mhtml. Ctrl+Shift+Y is the shortcut of a Chrome extension (called SingleFile) that saves a webpage as mhmtl. Then I want to close the tab by typing "Ctrl + F4", before I open another one and repeat the same process.
The keys are not successfully sent to Chrome.
# Sent shortcut (Ctrl+Shift+Y)
pyautogui.press(['ctrl', 'shift', 'y'])
# Close the current tab:
pyautogui.press(['ctrl', 'f4'])
I'm stuck at this step. What's the right way to do this? Thank you!
Tried other alternatives like Selenium, but it was blocked by the remote server.
Why are you using Chrome to get the website data? Generally, using an external application directly (ie. emulating a user) is a horrible and inefficient way to do anything. If your objective is to quickly get and store the data from a website, you should be talking directly to the website, using something like the requests module, which lets you quickly and easily send an HTTP request and get all of the website data. To get MHTML data, you can try something like this.
In the google appengine datastore, there is a BlobKey (labled as csv). The key is in the following format: encoded_gs_file:we1o5o7klkllfekomvcndhs345uh5pl31l. I would like to provide a download button to save this information.
The web app is being run using dev_appserver.py and uses python 2.7 (Django) as the backend. Currently, a button exists, but when clicking on it, it returns a 404 error. The download link that the button provides is:
https://localhost:8080/data?key=encoded_gs_file:dwndjndwamwljioihkm
The interesting thing is that, when i go to localhost:8000/datastore and then navigate to the Blobstore Viewer, i can navigate to Entity Kind: GsFileInfo, and there is a key generated. The problem is that it gives a 404.
The other blob item next to is a png and if i use the key for that png, i get a download. What is wrong with the key, how can i get the write key from the datastore.
I'm still scratching my head in regards to your issue, but something that seems suspect is that size is None and finalized is False for your CSV file.
I looked back at your previous question (google cloud: downloading as an CSV) and noticed that you're not calling .close() on your GCS/blobstore file after you finish writing to it.
Maybe that will fix this.
I developed a photo gallery in python, now I want to insert a new feature, "Download Multiple Photos": a user can select some photos to download and system creates a compressed file with the photos.
In your opinion: in the frontend what is the best way to send the ids? Json? input hidden? and in the backend there is a django library that compress the selected photos and return the compressed file?
Thanks,
Marco
Once you get the IDs of all the selected image in the client, you can zip them by using the zipfile or tarfile module . The way to collect the files to compress totally depends on how did you save the image. If you save the image such as uploaded date/id/, then on the client side, you need to send those information back to the server as well to reduce the server load. Hidden fields are ok in this situation
I think the only way to do it is in the backend, because in the frontend you will only have to select which photos you want to download and send the ids or some identifiers to the server side, then retrieve those selected photos from the filesystem (based on the identifiers), compress them in a single file and return that compressed file in a response as attached content.
If you do it in the front end how would you get each file and compress them all?
Doing it in server side is the best solution in my opinion :)