|
13 | 13 | from urllib2 import urlopen |
14 | 14 | from urllib import urlretrieve |
15 | 15 |
|
16 | | -try: |
17 | | - from PIL import Image |
18 | | -except ImportError: |
19 | | - if compas.is_windows(): |
20 | | - compas.raise_if_not_ironpython() |
21 | | - elif not compas.is_mono(): |
22 | | - raise |
| 16 | +# try: |
| 17 | +# from PIL import Image |
| 18 | +# except ImportError: |
| 19 | +# if compas.is_windows(): |
| 20 | +# compas.raise_if_not_ironpython() |
| 21 | +# elif not compas.is_mono(): |
| 22 | +# raise |
23 | 23 |
|
24 | 24 |
|
25 | | -__all__ = ['download_file_from_remote', 'download_image_from_remote'] |
| 25 | +__all__ = ['download_file_from_remote'] |
26 | 26 |
|
27 | 27 |
|
28 | 28 | def download_file_from_remote(source, target, overwrite=True): |
@@ -67,42 +67,42 @@ def download_file_from_remote(source, target, overwrite=True): |
67 | 67 | urlretrieve(source, target) |
68 | 68 |
|
69 | 69 |
|
70 | | -def download_image_from_remote(source, target, show=False): |
71 | | - """Download an image from a remote source and save it to a local destination. |
| 70 | +# def download_image_from_remote(source, target, show=False): |
| 71 | +# """Download an image from a remote source and save it to a local destination. |
72 | 72 |
|
73 | | - Parameters |
74 | | - ---------- |
75 | | - source : str |
76 | | - The url of the source file. |
77 | | - target : str |
78 | | - The path of the local destination. |
79 | | - show : bool, optional |
80 | | - Show the downloaded image. |
81 | | - Default is ``False`` |
| 73 | +# Parameters |
| 74 | +# ---------- |
| 75 | +# source : str |
| 76 | +# The url of the source file. |
| 77 | +# target : str |
| 78 | +# The path of the local destination. |
| 79 | +# show : bool, optional |
| 80 | +# Show the downloaded image. |
| 81 | +# Default is ``False`` |
82 | 82 |
|
83 | | - Examples |
84 | | - -------- |
85 | | - .. code-block:: python |
| 83 | +# Examples |
| 84 | +# -------- |
| 85 | +# .. code-block:: python |
86 | 86 |
|
87 | | - import os |
88 | | - import compas |
89 | | - from compas.utilities.remote import download_image_from_remote |
| 87 | +# import os |
| 88 | +# import compas |
| 89 | +# from compas.utilities.remote import download_image_from_remote |
90 | 90 |
|
91 | | - source = 'http://block.arch.ethz.ch/brg/images/cache/dsc02360_ni-2_cropped_1528706473_624x351.jpg' |
92 | | - target = os.path.join(compas.APPDATA, 'data', 'theblock.jpg') |
| 91 | +# source = 'http://block.arch.ethz.ch/brg/images/cache/dsc02360_ni-2_cropped_1528706473_624x351.jpg' |
| 92 | +# target = os.path.join(compas.APPDATA, 'data', 'theblock.jpg') |
93 | 93 |
|
94 | | - download_image_from_remote(source, target, show=True) |
| 94 | +# download_image_from_remote(source, target, show=True) |
95 | 95 |
|
96 | | - """ |
97 | | - # response = requests.get(source) |
98 | | - # response.raise_for_status() |
| 96 | +# """ |
| 97 | +# # response = requests.get(source) |
| 98 | +# # response.raise_for_status() |
99 | 99 |
|
100 | | - response = urlopen(source) |
101 | | - image = Image.open(io.BytesIO(response.read())) |
| 100 | +# response = urlopen(source) |
| 101 | +# image = Image.open(io.BytesIO(response.read())) |
102 | 102 |
|
103 | | - if show: |
104 | | - image.show() |
105 | | - image.save(target) |
| 103 | +# if show: |
| 104 | +# image.show() |
| 105 | +# image.save(target) |
106 | 106 |
|
107 | 107 |
|
108 | 108 | # ============================================================================== |
|
0 commit comments