diff --git a/EDMarketConnector.py b/EDMarketConnector.py
index 666574ae..47258ae0 100755
--- a/EDMarketConnector.py
+++ b/EDMarketConnector.py
@@ -11,6 +11,7 @@ import json
from os import chdir, environ
from os.path import dirname, expanduser, isdir, join
import re
+import html
import requests
from time import gmtime, time, localtime, strftime, strptime
import _strptime # Workaround for http://bugs.python.org/issue7980
@@ -58,6 +59,21 @@ from theme import theme
SERVER_RETRY = 5 # retry pause for Companion servers [s]
+SHIPYARD_HTML_TEMPLATE = """
+
+
+
+
+ Redirecting you to your {ship_name} at {provider_name}...
+
+
+
+ You should be redirected to your {ship_name} at {provider_name} shortly...
+
+
+
+"""
+
class AppWindow(object):
@@ -655,7 +671,18 @@ class AppWindow(object):
hotkeymgr.play_bad()
def shipyard_url(self, shipname):
- return plug.invoke(config.get('shipyard_provider'), 'EDSY', 'shipyard_url', monitor.ship(), monitor.is_beta)
+ provider = config.get('shipyard_provider') or 'EDSY'
+ target = plug.invoke(config.get('shipyard_provider'), 'EDSY', 'shipyard_url', monitor.ship(), monitor.is_beta)
+ file_name = join(config.app_dir, "last_shipyard.html")
+
+ with open(file_name, 'w') as f:
+ print(SHIPYARD_HTML_TEMPLATE.format(
+ link=html.escape(str(target)),
+ provider_name=html.escape(str(provider)),
+ ship_name=html.escape(str(shipname))
+ ), file=f)
+
+ return f'file://localhost/{file_name}'
def system_url(self, system):
return plug.invoke(config.get('system_provider'), 'EDSM', 'system_url', monitor.system)
diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py
index 627a987f..43fa7d29 100644
--- a/ttkHyperlinkLabel.py
+++ b/ttkHyperlinkLabel.py
@@ -112,36 +112,36 @@ class HyperlinkLabel(platform == 'darwin' and tk.Label or ttk.Label, object):
def openurl(url):
- if platform == 'win32':
- # On Windows webbrowser.open calls os.startfile which calls ShellExecute which can't handle long arguments,
- # so discover and launch the browser directly.
- # https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553
+ # if platform == 'win32':
+ # # On Windows webbrowser.open calls os.startfile which calls ShellExecute which can't handle long arguments,
+ # # so discover and launch the browser directly.
+ # # https://blogs.msdn.microsoft.com/oldnewthing/20031210-00/?p=41553
- try:
- hkey = OpenKeyEx(HKEY_CURRENT_USER, r'Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice')
- (value, typ) = QueryValueEx(hkey, 'ProgId')
- CloseKey(hkey)
- if value in ['IE.HTTP', 'AppXq0fevzme2pys62n3e0fbqa7peapykr8v']:
- # IE and Edge can't handle long arguments so just use webbrowser.open and hope
- # https://blogs.msdn.microsoft.com/ieinternals/2014/08/13/url-length-limits/
- cls = None
- else:
- cls = value
- except:
- cls = 'https'
+ # try:
+ # hkey = OpenKeyEx(HKEY_CURRENT_USER, r'Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice')
+ # (value, typ) = QueryValueEx(hkey, 'ProgId')
+ # CloseKey(hkey)
+ # if value in ['IE.HTTP', 'AppXq0fevzme2pys62n3e0fbqa7peapykr8v']:
+ # # IE and Edge can't handle long arguments so just use webbrowser.open and hope
+ # # https://blogs.msdn.microsoft.com/ieinternals/2014/08/13/url-length-limits/
+ # cls = None
+ # else:
+ # cls = value
+ # except:
+ # cls = 'https'
- if cls:
- try:
- hkey = OpenKeyEx(HKEY_CLASSES_ROOT, r'%s\shell\open\command' % cls)
- (value, typ) = QueryValueEx(hkey, None)
- CloseKey(hkey)
- if 'iexplore' not in value.lower():
- if '%1' in value:
- subprocess.Popen(buf.value.replace('%1', url))
- else:
- subprocess.Popen('%s "%s"' % (buf.value, url))
- return
- except:
- pass
+ # if cls:
+ # try:
+ # hkey = OpenKeyEx(HKEY_CLASSES_ROOT, r'%s\shell\open\command' % cls)
+ # (value, typ) = QueryValueEx(hkey, None)
+ # CloseKey(hkey)
+ # if 'iexplore' not in value.lower():
+ # if '%1' in value:
+ # subprocess.Popen(buf.value.replace('%1', url))
+ # else:
+ # subprocess.Popen('%s "%s"' % (buf.value, url))
+ # return
+ # except:
+ # pass
webbrowser.open(url)