How to find if a file has been downloaded completely using python?
up vote
-1
down vote
favorite
We are having a python script which automates the batch processing of time-series image data downloaded from the internet. The current script requires all data to be downloaded before execution. This consumes more time. We want to modify the script by writing a scheduler which will call the script whenever a single data is completely downloaded. How to find that a file has been downloaded completely using python?
python image image-processing scheduler
add a comment |
up vote
-1
down vote
favorite
We are having a python script which automates the batch processing of time-series image data downloaded from the internet. The current script requires all data to be downloaded before execution. This consumes more time. We want to modify the script by writing a scheduler which will call the script whenever a single data is completely downloaded. How to find that a file has been downloaded completely using python?
python image image-processing scheduler
Welcome to Stackoverflow. Could you show us what you've done so far? Any specific problems/errors you've come across?
– Charles Landau
Nov 11 at 6:36
The normal way to do this is to download the file with a temporary, sentinel extension, e.g.image.png.download
and then rename toimage.png
when it is complete. That way you can identify downloads that are in progress, complete, or stalled.
– Mark Setchell
Nov 11 at 9:31
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
We are having a python script which automates the batch processing of time-series image data downloaded from the internet. The current script requires all data to be downloaded before execution. This consumes more time. We want to modify the script by writing a scheduler which will call the script whenever a single data is completely downloaded. How to find that a file has been downloaded completely using python?
python image image-processing scheduler
We are having a python script which automates the batch processing of time-series image data downloaded from the internet. The current script requires all data to be downloaded before execution. This consumes more time. We want to modify the script by writing a scheduler which will call the script whenever a single data is completely downloaded. How to find that a file has been downloaded completely using python?
python image image-processing scheduler
python image image-processing scheduler
edited Nov 11 at 7:08
Sniffer
6321721
6321721
asked Nov 11 at 5:21
Girish Kumar
34
34
Welcome to Stackoverflow. Could you show us what you've done so far? Any specific problems/errors you've come across?
– Charles Landau
Nov 11 at 6:36
The normal way to do this is to download the file with a temporary, sentinel extension, e.g.image.png.download
and then rename toimage.png
when it is complete. That way you can identify downloads that are in progress, complete, or stalled.
– Mark Setchell
Nov 11 at 9:31
add a comment |
Welcome to Stackoverflow. Could you show us what you've done so far? Any specific problems/errors you've come across?
– Charles Landau
Nov 11 at 6:36
The normal way to do this is to download the file with a temporary, sentinel extension, e.g.image.png.download
and then rename toimage.png
when it is complete. That way you can identify downloads that are in progress, complete, or stalled.
– Mark Setchell
Nov 11 at 9:31
Welcome to Stackoverflow. Could you show us what you've done so far? Any specific problems/errors you've come across?
– Charles Landau
Nov 11 at 6:36
Welcome to Stackoverflow. Could you show us what you've done so far? Any specific problems/errors you've come across?
– Charles Landau
Nov 11 at 6:36
The normal way to do this is to download the file with a temporary, sentinel extension, e.g.
image.png.download
and then rename to image.png
when it is complete. That way you can identify downloads that are in progress, complete, or stalled.– Mark Setchell
Nov 11 at 9:31
The normal way to do this is to download the file with a temporary, sentinel extension, e.g.
image.png.download
and then rename to image.png
when it is complete. That way you can identify downloads that are in progress, complete, or stalled.– Mark Setchell
Nov 11 at 9:31
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
If you download the file with Python, then you can just do the image processing operation after the file download operation finishes. An example using requests:
import requests
import mymodule # The module containing your custom image-processing function
for img in ("foo.png", "bar.png", "baz.png"):
response = requests.get("http://www.example.com/" + img)
image_bytes = response.content
mymodule.process_image(image_bytes)
However, with the sequential approach above you will be spending a lot of time waiting for responses from the remote server. To make this faster, you can download and process multiple files at once using aysncio and aiohttp. There's a good introduction to downloading files this way in Paweł Miech's blog post Making 1 million requests with python-aiohttp. The code you need will look something like the example at the bottom of that blog post (the one with the semaphore).
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
If you download the file with Python, then you can just do the image processing operation after the file download operation finishes. An example using requests:
import requests
import mymodule # The module containing your custom image-processing function
for img in ("foo.png", "bar.png", "baz.png"):
response = requests.get("http://www.example.com/" + img)
image_bytes = response.content
mymodule.process_image(image_bytes)
However, with the sequential approach above you will be spending a lot of time waiting for responses from the remote server. To make this faster, you can download and process multiple files at once using aysncio and aiohttp. There's a good introduction to downloading files this way in Paweł Miech's blog post Making 1 million requests with python-aiohttp. The code you need will look something like the example at the bottom of that blog post (the one with the semaphore).
add a comment |
up vote
0
down vote
accepted
If you download the file with Python, then you can just do the image processing operation after the file download operation finishes. An example using requests:
import requests
import mymodule # The module containing your custom image-processing function
for img in ("foo.png", "bar.png", "baz.png"):
response = requests.get("http://www.example.com/" + img)
image_bytes = response.content
mymodule.process_image(image_bytes)
However, with the sequential approach above you will be spending a lot of time waiting for responses from the remote server. To make this faster, you can download and process multiple files at once using aysncio and aiohttp. There's a good introduction to downloading files this way in Paweł Miech's blog post Making 1 million requests with python-aiohttp. The code you need will look something like the example at the bottom of that blog post (the one with the semaphore).
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
If you download the file with Python, then you can just do the image processing operation after the file download operation finishes. An example using requests:
import requests
import mymodule # The module containing your custom image-processing function
for img in ("foo.png", "bar.png", "baz.png"):
response = requests.get("http://www.example.com/" + img)
image_bytes = response.content
mymodule.process_image(image_bytes)
However, with the sequential approach above you will be spending a lot of time waiting for responses from the remote server. To make this faster, you can download and process multiple files at once using aysncio and aiohttp. There's a good introduction to downloading files this way in Paweł Miech's blog post Making 1 million requests with python-aiohttp. The code you need will look something like the example at the bottom of that blog post (the one with the semaphore).
If you download the file with Python, then you can just do the image processing operation after the file download operation finishes. An example using requests:
import requests
import mymodule # The module containing your custom image-processing function
for img in ("foo.png", "bar.png", "baz.png"):
response = requests.get("http://www.example.com/" + img)
image_bytes = response.content
mymodule.process_image(image_bytes)
However, with the sequential approach above you will be spending a lot of time waiting for responses from the remote server. To make this faster, you can download and process multiple files at once using aysncio and aiohttp. There's a good introduction to downloading files this way in Paweł Miech's blog post Making 1 million requests with python-aiohttp. The code you need will look something like the example at the bottom of that blog post (the one with the semaphore).
edited Nov 22 at 5:50
answered Nov 11 at 6:47
Jack Taylor
2,020621
2,020621
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246062%2fhow-to-find-if-a-file-has-been-downloaded-completely-using-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to Stackoverflow. Could you show us what you've done so far? Any specific problems/errors you've come across?
– Charles Landau
Nov 11 at 6:36
The normal way to do this is to download the file with a temporary, sentinel extension, e.g.
image.png.download
and then rename toimage.png
when it is complete. That way you can identify downloads that are in progress, complete, or stalled.– Mark Setchell
Nov 11 at 9:31