1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 15:57:14 +03:00

Added a config to use the new file based shipyard

This also reverts commenting out the old solution for long URLs
This commit is contained in:
A_D 2020-07-23 13:27:38 +02:00 committed by Athanasius
parent b818922193
commit 99014dd970
2 changed files with 33 additions and 29 deletions

View File

@ -671,6 +671,10 @@ class AppWindow(object):
hotkeymgr.play_bad()
def shipyard_url(self, shipname):
if not bool(config.getint("use_alt_shipyard_open")):
return plug.invoke(config.get('shipyard_provider'), 'EDSY', 'shipyard_url', monitor.ship(), monitor.is_beta)
# Avoid file length limits if possible
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")

View File

@ -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)