Repository: sunpy/sunpy

Issue:
Download of sample data is repeated for each server
Why do we have `sunpy.data.download_sample_data()` download all of the sample data files twice, once for each of the two servers (data.sunpy.org and hesperia.gsfc.nasa.gov)?  This seems silly.

Lines 60–61 in `sunpy/data/_sample.py`:

``` python
    for base_url in _base_urls:
        for file_name in _files.itervalues():
```

Output:

```
>>> import sunpy.data
>>> sunpy.data.download_sample_data()
Downloading sample files to c:/Users/Albert\sunpy\data/sample_data
Downloading http://data.sunpy.org/sample-data/BIR_20110922_103000_01.fit
|===========================================| 760k/760k (100.00%)         4s
Downloading http://data.sunpy.org/sample-data/swap_lv1_20120101_001607.fits
|===========================================| 2.1M/2.1M (100.00%)         4s
Downloading http://data.sunpy.org/sample-data/eit_l1_20020625_100011.fits
|===========================================| 8.3M/8.3M (100.00%)        10s
Downloading http://data.sunpy.org/sample-data/aia.lev1.193A_2013-09-21T16_00_06.84Z.image_
lev1.fits.zip
|===========================================|  12M/ 12M (100.00%)        22s
Unpacking: aia.lev1.193A_2013-09-21T16_00_06.84Z.image_lev1.fits
Downloading http://data.sunpy.org/sample-data/hsi_calib_ev_20020220_1106_20020220_1106_25_
40.fits
|===========================================| 207k/207k (100.00%)         0s
Downloading http://data.sunpy.org/sample-data/AIA20110319_105400_0171.fits
|===========================================| 4.2M/4.2M (100.00%)         6s
Downloading http://data.sunpy.org/sample-data/hsi_image_20101016_191218.fits
|===========================================|  95k/ 95k (100.00%)         0s
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/BIR_20110922_103000_
01.fit
|===========================================| 760k/760k (100.00%)         0s
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/swap_lv1_20120101_00
1607.fits
|===========================================| 2.1M/2.1M (100.00%)         2s
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/eit_l1_20020625_1000
11.fits
|===========================================| 8.3M/8.3M (100.00%)         6s
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/aia.lev1.193A_2013-0
9-21T16_00_06.84Z.image_lev1.fits.zip
|===========================================|  12M/ 12M (100.00%)        10s
Unpacking: aia.lev1.193A_2013-09-21T16_00_06.84Z.image_lev1.fits
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/hsi_calib_ev_2002022
0_1106_20020220_1106_25_40.fits
|===========================================| 207k/207k (100.00%)         0s
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/AIA20110319_105400_0
171.fits
|===========================================| 4.2M/4.2M (100.00%)         3s
Downloading http://hesperia.gsfc.nasa.gov/~schriste/sunpy-sample-data/hsi_image_20101016_1
91218.fits
|===========================================|  95k/ 95k (100.00%)         0s
```



Discussion:
Ah yes! I forgot to open an issue for this when I noticed it last week. This should be fixed for 0.6.


Resolving patch:
diff --git a/sunpy/data/_sample.py b/sunpy/data/_sample.py
--- a/sunpy/data/_sample.py
+++ b/sunpy/data/_sample.py
@@ -57,8 +57,8 @@ def download_sample_data(progress=True):
     """
     number_of_files_fetched = 0
     print("Downloading sample files to " + sampledata_dir)
-    for base_url in _base_urls:
-        for file_name in _files.itervalues():
+    for file_name in _files.itervalues():
+        for base_url in _base_urls:
             full_file_name = file_name[0] + file_name[1]
             if url_exists(os.path.join(base_url, full_file_name)):
                 f = download_file(os.path.join(base_url, full_file_name))
@@ -74,6 +74,7 @@ def download_sample_data(progress=True):
                     move(f, os.path.join(sampledata_dir, file_name[0]))
                 # increment the number of files obtained to check later
                 number_of_files_fetched += 1
+                break
 
     if number_of_files_fetched < len(_files.keys()):
         raise URLError("Could not download all samples files. Problem with accessing sample data servers.")


Test patch: