mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-22 10:11:52 +00:00
fixed a couple of Windows exe update bugs
This commit is contained in:
parent
668d975039
commit
f36cd07685
3 changed files with 8 additions and 6 deletions
BIN
youtube-dl
BIN
youtube-dl
Binary file not shown.
BIN
youtube-dl.exe
BIN
youtube-dl.exe
Binary file not shown.
|
@ -60,13 +60,17 @@ def updateSelf(downloader, filename):
|
||||||
urlv.close()
|
urlv.close()
|
||||||
|
|
||||||
if hasattr(sys, "frozen"): #py2exe
|
if hasattr(sys, "frozen"): #py2exe
|
||||||
directory = os.path.dirname(filename)
|
|
||||||
exe = os.path.abspath(filename)
|
exe = os.path.abspath(filename)
|
||||||
|
directory = os.path.dirname(exe)
|
||||||
if not os.access(directory, os.W_OK):
|
if not os.access(directory, os.W_OK):
|
||||||
sys.exit('ERROR: no write permissions on %s' % directory)
|
sys.exit('ERROR: no write permissions on %s' % directory)
|
||||||
|
|
||||||
try:
|
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:
|
except (IOError, OSError), err:
|
||||||
sys.exit('ERROR: unable to download latest version')
|
sys.exit('ERROR: unable to download latest version')
|
||||||
|
|
||||||
|
@ -75,6 +79,7 @@ def updateSelf(downloader, filename):
|
||||||
b = open(bat, 'w')
|
b = open(bat, 'w')
|
||||||
|
|
||||||
print >> b, """
|
print >> b, """
|
||||||
|
echo Updating youtube-dl...
|
||||||
ping 127.0.0.1 -n 5 -w 1000 > NUL
|
ping 127.0.0.1 -n 5 -w 1000 > NUL
|
||||||
move /Y "%s.new" "%s"
|
move /Y "%s.new" "%s"
|
||||||
del "%s"
|
del "%s"
|
||||||
|
@ -95,11 +100,8 @@ del "%s"
|
||||||
sys.exit('ERROR: unable to download latest version')
|
sys.exit('ERROR: unable to download latest version')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
outf = open(filename, 'wb')
|
with open(filename, 'wb') as outf:
|
||||||
try:
|
|
||||||
outf.write(newcontent)
|
outf.write(newcontent)
|
||||||
finally:
|
|
||||||
outf.close()
|
|
||||||
except (IOError, OSError), err:
|
except (IOError, OSError), err:
|
||||||
sys.exit('ERROR: unable to overwrite current version')
|
sys.exit('ERROR: unable to overwrite current version')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue