mirror of https://github.com/ARMmbed/mbed-os.git
Added 'firefox' as one of the ways to copy binary to target device (other options are cp, copy, xcopy, shutil.copy()
parent
80bb5b6f6d
commit
dcf1ef2130
|
@ -510,16 +510,35 @@ class SingleTestRunner(object):
|
||||||
result = self.TEST_LOOPS_DICT[test_id]
|
result = self.TEST_LOOPS_DICT[test_id]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def file_store_firefox(self, file_path, dest_disk):
|
||||||
|
try:
|
||||||
|
from selenium import webdriver
|
||||||
|
except ImportError, e:
|
||||||
|
print "Error: firefox copy method requires selenium library. %s"% e
|
||||||
|
exit(-1)
|
||||||
|
profile = webdriver.FirefoxProfile()
|
||||||
|
profile.set_preference('browser.download.folderList', 2) # custom location
|
||||||
|
profile.set_preference('browser.download.manager.showWhenStarting', False)
|
||||||
|
profile.set_preference('browser.download.dir', dest_disk)
|
||||||
|
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/octet-stream')
|
||||||
|
|
||||||
|
# Launch browser with profile and get file
|
||||||
|
browser = webdriver.Firefox(profile)
|
||||||
|
browser.get(file_path)
|
||||||
|
browser.close()
|
||||||
|
|
||||||
def file_copy_method_selector(self, image_path, disk, copy_method):
|
def file_copy_method_selector(self, image_path, disk, copy_method):
|
||||||
""" Copy file depending on method you want to use. Handles exception
|
""" Copy file depending on method you want to use. Handles exception
|
||||||
and return code from shell copy commands. """
|
and return code from shell copy commands. """
|
||||||
result = True
|
result = True
|
||||||
resutl_msg = ""
|
resutl_msg = ""
|
||||||
if copy_method == "cp" or copy_method == "copy" or copy_method == "xcopy":
|
if copy_method == 'cp' or copy_method == 'copy' or copy_method == 'xcopy':
|
||||||
cmd = [copy_method,
|
source_path = image_path.encode('ascii', 'ignore')
|
||||||
image_path.encode('ascii', 'ignore'),
|
destination_path = os.path.join(disk.encode('ascii', 'ignore'), basename(image_path).encode('ascii', 'ignore'))
|
||||||
disk.encode('ascii', 'ignore') + basename(image_path).encode('ascii', 'ignore')]
|
|
||||||
|
cmd = [copy_method, source_path, destination_path]
|
||||||
try:
|
try:
|
||||||
|
print cmd
|
||||||
ret = call(cmd, shell=True)
|
ret = call(cmd, shell=True)
|
||||||
if ret:
|
if ret:
|
||||||
resutl_msg = "Return code: %d. Command: "% ret + " ".join(cmd)
|
resutl_msg = "Return code: %d. Command: "% ret + " ".join(cmd)
|
||||||
|
@ -527,6 +546,14 @@ class SingleTestRunner(object):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
resutl_msg = e
|
resutl_msg = e
|
||||||
result = False
|
result = False
|
||||||
|
if copy_method == 'firefox':
|
||||||
|
try:
|
||||||
|
source_path = image_path.encode('ascii', 'ignore')
|
||||||
|
destination_path = disk.encode('ascii', 'ignore')
|
||||||
|
self.file_store_firefox(source_path, destination_path)
|
||||||
|
except Exception, e:
|
||||||
|
resutl_msg = e
|
||||||
|
result = False
|
||||||
else:
|
else:
|
||||||
copy_method = "shutils.copy()"
|
copy_method = "shutils.copy()"
|
||||||
# Default python method
|
# Default python method
|
||||||
|
|
Loading…
Reference in New Issue