Python script compatibility issue

November 8, 2014 at 06:25:14
Specs: Windows 7, 8 Gb
I have to download McAfee virus definition update file and then execute it. If I download it directrly from site using Windows download/save ... it works fine. In my case I do it using python script from When I try to execute the file downloaded using script it failed with this error:
7615xdat.exe This version of X:\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.
I noticed that while both files have the same name they are different in size ( the one downloaded using script is slightly bigger), they have also different icon in windows explorer. I assume that python script does not make 'exact' copy of the file from web which result into the error. Any idea how to fix it? I will attach the script I am using:

import urllib
import lxml.html
import os
import shutil

# index page
pattern_files_url = ""
# 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:
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)

See More: Python script compatibility issue

Report •

December 16, 2014 at 04:51:53
Well ... I resolved the issue by replacing open(local_name,'w') with open(local_name,'wb')
Ticket could be closed

Report •
Related Solutions

Ask Question