#545 Addressed import error and added --force flag

This commit is contained in:
Steve Barnes
2017-09-21 09:10:22 +01:00
parent f04d103bea
commit dd7bdde296
2 changed files with 12 additions and 6 deletions

View File

@@ -97,6 +97,7 @@ def download_file(url, dest=None, force=False):
return 'Aborted!'
if url:
print("Download from:", url)
try:
url_res = urllib2.urlopen(url)
keep_going = True

View File

@@ -23,6 +23,8 @@ Usage:
Will install if missing, the requested item for the current version and then
launch it.
Use: doc|demo --force to force a fresh download.
"""
from __future__ import (division, absolute_import, print_function, unicode_literals)
@@ -43,8 +45,11 @@ else:
from urllib import pathname2url
import wx
try:
import wxget
except ImportError:
from . import wxget
import wxget
print(sys.version_info, sys.version, sys.argv)
APP = None
if wx.VERSION[0] != 4:
@@ -86,17 +91,17 @@ def unpack_cached(cached, dest_dir):
dest_dir = os.listdir(dest_dir)[0]
return dest_dir
def get_item(final, url, cache, name, ext):
def get_item(final, url, cache, name, ext, forced=False):
""" Get the item """
print('Looking for', name, 'at', final)
fullpath = os.path.join(final, name)
if os.path.exists(fullpath): # Already exists
if os.path.exists(fullpath) and not forced: # Already exists
return fullpath
cached = os.path.join(cache, name)
cached = os.path.extsep.join([cached, ext])
print('Looking for cached', cached)
if not os.path.exists(cached): # No cached copy
if not os.path.exists(cached) or forced: # No cached copy
yes_no = wx.MessageBox(
"\n".join(
["%s is not yet installed." % name,
@@ -138,7 +143,7 @@ def docs_main(args=sys.argv):
print("Launch Docs for wxPython V%s" % wx.VERSION_STRING)
pd = get_paths_dict()
location = get_item(pd['wxDocs'], pd['Docs_URL'], pd['Cache'],
pd['Docs_Name'], pd['Ext'])
pd['Docs_Name'], pd['Ext'], forced="--force" in args)
if location:
location = os.path.join(location, 'docs', 'html', 'index.html')
location_url = urlparse.urljoin('file:', pathname2url(location))
@@ -156,7 +161,7 @@ def demo_main(args=sys.argv):
print("Launch Demo for wxPython V%s" % wx.VERSION_STRING)
pd = get_paths_dict()
location = get_item(pd['wxDemo'], pd['Demo_URL'], pd['Cache'],
pd['Demo_Name'], pd['Ext'])
pd['Demo_Name'], pd['Ext'], forced="--force" in args)
if location:
cmds = [sys.executable, os.path.join(location, "demo", "demo.py")]
print("Launching", cmds[1])