我具有以下脚本,可将.asm文件转换为.8080程序集的.com文件。我已经为python 3安装了硒(因为脚本需要python3),并尝试安装geckodriver。
我按如下方式安装了硒:
$ sudo pip3 install selenium
我如下安装了geckodriver(至少尝试过):
$ wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
$ tar -xvzf geckodriver*
$ chmod +x geckodriver
$ sudo mv geckodriver /usr/local/bin
(https://askubuntu.com/questions/870530/how-to-install-geckodriver-in-ubuntu)
但是它会引发以下异常: OSError:[Errno 8]执行格式错误
这是脚本:
#!/usr/bin/env python3
"""
selenium and geckodriver must be installed to use this script!
"""
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
import sys
import os
def assemble(asm_file):
path = os.getcwd()
options = Options()
options.set_preference("browser.download.folderList", 2)
options.set_preference("browser.download.dir", path)
options.set_preference("browser.download.manager.showWhenStarting", False)
options.set_preference("browser.helperApps.neverAsk.saveToDisk",
"application/octet-stream");
driver = webdriver.Firefox(firefox_options=options)
driver.get("http://sensi.org/~svo/i8080")
element = driver.find_element_by_id("source")
element.clear()
with open(asm_file) as reader:
asm = reader.read()
bin_file = asm.find(".binfile")
file_name = "test.com"
if bin_file != -1:
begin = bin_file + len(".binfile") + 1
file_name = asm[begin:].split('\n')[0]
element.send_keys(asm)
filepath = path + '/' + file_name
if os.path.exists(filepath):
os.remove(filepath)
driver.execute_script(" assemble(); load_hex2bin('translate'); ")
if os.path.exists('./geckodriver.log'):
os.remove('./geckodriver.log')
if __name__ == "__main__":
if len(sys.argv) == 2:
assemble(sys.argv[1])
else:
print("usage: ./asm.py asm_file");
这里是例外:
Traceback (most recent call last):
File "asm.py", line 44, in <module>
assemble(sys.argv[1])
File "asm.py", line 20, in assemble
driver = webdriver.Firefox(firefox_options=options)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
64位Ubuntu 14.04