~psivaa/ubuntu-test-cases/test-touch-wifi-reboot

« back to all changes in this revision

Viewing changes to scripts/device_info.py

  • Committer: Ubuntu CI Bot
  • Author(s): Paul Larson
  • Date: 2015-06-01 18:26:32 UTC
  • mfrom: (399.1.1 improve-recovery-download)
  • Revision ID: ubuntu_ci_bot-20150601182632-vzntywrua9znr7ai
Improve recovery image download logic [r=Parameswaran Sivatharman]

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
        # For certain devices, we need to first pull an alternate
75
75
        # recovery image that has adb enabled. If it's needed, it will
76
76
        # be at that url, otherwise we don't even try to use it.
77
 
        if not os.path.exists(os.path.join('recovery', recovery_img)):
78
 
            try:
79
 
                _download(recovery_url, 'recovery')
80
 
            except:
81
 
                # Don't fail for any reason, if attempt to flash without
82
 
                pass
 
77
        try:
 
78
            _download(recovery_url, 'recovery')
 
79
        except:
 
80
            # Don't fail for any reason, if attempt to flash without
 
81
            pass
83
82
        udf_command = ['ubuntu-device-flash',
84
83
                       '--server', self.image_server,
85
84
                       'touch', '--serial', self.serial,
358
357
 
359
358
 
360
359
def _download(url, path):
361
 
    os.makedirs(path)
 
360
    try:
 
361
        os.makedirs(path)
 
362
    except OSError:
 
363
        # Don't fail if the directory already exists
 
364
        pass
362
365
    urlpath = urlparse.urlsplit(url).path
363
366
    filename = os.path.basename(urlpath)
364
367
    filename = os.path.join(path, filename)
 
368
    if os.path.exists(filename):
 
369
        # Don't re-download if it's already there
 
370
        return filename
365
371
 
366
372
    response = requests.get(url, stream=True)
367
373
    response.raise_for_status()