aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo.valsorda@gmail.com>2012-05-27 23:03:45 +0200
committerFilippo Valsorda <filippo.valsorda@gmail.com>2012-05-27 23:03:45 +0200
commitf36cd076850faf4b2859a168fcb740dfccb9eed6 (patch)
tree8fb6557ea3ebe199dd3d6b77702239eebaf4d57e
parent668d97503946e0f7f1a2024a650eda4b7387cc86 (diff)
fixed a couple of Windows exe update bugs
-rwxr-xr-xyoutube-dlbin40223 -> 40236 bytes
-rwxr-xr-xyoutube-dl.exebin4001031 -> 3989217 bytes
-rw-r--r--youtube_dl/__init__.py14
3 files changed, 8 insertions, 6 deletions
diff --git a/youtube-dl b/youtube-dl
index 3fc77f206..80175ed6e 100755
--- a/youtube-dl
+++ b/youtube-dl
Binary files differ
diff --git a/youtube-dl.exe b/youtube-dl.exe
index 287b78af5..6d19ef5ea 100755
--- a/youtube-dl.exe
+++ b/youtube-dl.exe
Binary files differ
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 5e500d5e0..73590ecd6 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -60,13 +60,17 @@ def updateSelf(downloader, filename):
urlv.close()
if hasattr(sys, "frozen"): #py2exe
- directory = os.path.dirname(filename)
exe = os.path.abspath(filename)
+ directory = os.path.dirname(exe)
if not os.access(directory, os.W_OK):
sys.exit('ERROR: no write permissions on %s' % directory)
try:
- urllib.urlretrieve(UPDATE_URL_EXE, exe + '.new')
+ urlh = urllib2.urlopen(UPDATE_URL_EXE)
+ newcontent = urlh.read()
+ urlh.close()
+ with open(exe + '.new', 'wb') as outf:
+ outf.write(newcontent)
except (IOError, OSError), err:
sys.exit('ERROR: unable to download latest version')
@@ -75,6 +79,7 @@ def updateSelf(downloader, filename):
b = open(bat, 'w')
print >> b, """
+echo Updating youtube-dl...
ping 127.0.0.1 -n 5 -w 1000 > NUL
move /Y "%s.new" "%s"
del "%s"
@@ -95,11 +100,8 @@ del "%s"
sys.exit('ERROR: unable to download latest version')
try:
- outf = open(filename, 'wb')
- try:
+ with open(filename, 'wb') as outf:
outf.write(newcontent)
- finally:
- outf.close()
except (IOError, OSError), err:
sys.exit('ERROR: unable to overwrite current version')