使用python脚本的兼容性问题

时间:2014-11-08 14:17:06

标签: python compatibility

我必须下载McAfee病毒定义更新文件然后执行它。如果我使用Windows下载/保存从网站直接下载它...它工作正常。 就我而言,我使用来自http://download.nai.com/products/licensed/superdat/english/intel/的python脚本来做 当我尝试执行使用脚本下载的文件时,它失败并显示以下错误:

>7615xdat.exe
This version of N:\DeleteMe\deleteMePlease\7615xdat.exe is not compatible with the version of
Windows you're running. Check your computer's system information to see whether you need a x86
 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher.

我注意到虽然两个文件的名称相同,但它们的大小不同(使用脚本下载的文件稍大),它们在Windows资源管理器中也有不同的图标。 我认为python脚本不能确保'确切'来自网络的文件副本导致错误。 知道怎么解决吗? 我将附上我正在使用的脚本:

import urllib
import lxml.html
import os
import shutil

# index page
pattern_files_url = "http://download.nai.com/products/licensed/superdat/english/intel"
# relative url references based here
pattern_files_base = '/'.join(pattern_files_url.split('/')[:-1])

# scrape the index page for latest file list
doc = lxml.html.parse(pattern_files_url)
pattern_files = [ref for ref in doc.xpath("//a/@href") if ref.endswith('xdat.exe')]
if pattern_files:
    pattern_files.sort()
    newest = pattern_files[-1]
    local_name = newest.split('/')[-1]
    # grab it if we don't already have it
    if not os.path.exists(local_name):
        url = pattern_files_base + '/' + newest
        remote = urllib.urlopen(url)
        with open(local_name, 'w') as local:
            shutil.copyfileobj(remote, local, length=65536)

0 个答案:

没有答案