ugly workaround for ssl on windows
This commit is contained in:
parent
ce9900559d
commit
9019c95f75
3 changed files with 22 additions and 8 deletions
|
@ -1,9 +1,9 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
import os, sys, pickle, subprocess, shutil
|
import os, sys, pickle, subprocess, shutil
|
||||||
from PyQt4 import QtCore, QtGui, QtWebKit
|
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
|
||||||
|
|
||||||
RUNNING_LOCAL = os.path.basename(__file__) == "Bungloo.py"
|
RUNNING_LOCAL = os.path.basename(sys.argv[0]) == "Bungloo.py"
|
||||||
|
|
||||||
if RUNNING_LOCAL:
|
if RUNNING_LOCAL:
|
||||||
import Windows, Helper
|
import Windows, Helper
|
||||||
|
@ -13,6 +13,7 @@ else:
|
||||||
class Bungloo:
|
class Bungloo:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.app = QtGui.QApplication(sys.argv)
|
self.app = QtGui.QApplication(sys.argv)
|
||||||
self.new_message_windows = []
|
self.new_message_windows = []
|
||||||
self.controller = Controller(self)
|
self.controller = Controller(self)
|
||||||
|
@ -30,7 +31,7 @@ class Bungloo:
|
||||||
|
|
||||||
def resources_path(self):
|
def resources_path(self):
|
||||||
if RUNNING_LOCAL:
|
if RUNNING_LOCAL:
|
||||||
return os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
return os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..'))
|
||||||
else:
|
else:
|
||||||
return Helper.Helper.get_resource_path()
|
return Helper.Helper.get_resource_path()
|
||||||
|
|
||||||
|
|
18
Qt/Helper.py
18
Qt/Helper.py
|
@ -10,9 +10,9 @@ import os
|
||||||
import array
|
import array
|
||||||
|
|
||||||
class Helper:
|
class Helper:
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_resource_path(cls):
|
def get_resource_path(cls):
|
||||||
return os.path.dirname(__file__)
|
return os.path.dirname(sys.argv[0])
|
||||||
|
|
||||||
class WebPage(QtWebKit.QWebPage):
|
class WebPage(QtWebKit.QWebPage):
|
||||||
def __init__(self, parent=0, app=None):
|
def __init__(self, parent=0, app=None):
|
||||||
|
@ -43,6 +43,8 @@ class WebViewCreator(QtWebKit.QWebView):
|
||||||
self.customContextMenuRequested.connect(self.context_menu_requested)
|
self.customContextMenuRequested.connect(self.context_menu_requested)
|
||||||
self.actions = []
|
self.actions = []
|
||||||
|
|
||||||
|
self.page().networkAccessManager().sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors))
|
||||||
|
|
||||||
def copy_link():
|
def copy_link():
|
||||||
self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard)
|
self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard)
|
||||||
self.action_copy_link = QtGui.QAction('Copy Lin&k', self, triggered=copy_link)
|
self.action_copy_link = QtGui.QAction('Copy Lin&k', self, triggered=copy_link)
|
||||||
|
@ -85,7 +87,10 @@ class WebViewCreator(QtWebKit.QWebView):
|
||||||
def load_finished(self, ok, callback=None):
|
def load_finished(self, ok, callback=None):
|
||||||
frame = self.page().mainFrame()
|
frame = self.page().mainFrame()
|
||||||
if self.is_local:
|
if self.is_local:
|
||||||
frame.evaluateJavaScript("var OS_TYPE = 'linux';")
|
os_type = "linux"
|
||||||
|
if os.name == "nt":
|
||||||
|
os_type = "windows"
|
||||||
|
frame.evaluateJavaScript("var OS_TYPE = '" + os_type + "';")
|
||||||
|
|
||||||
js_plugin_path = os.path.expanduser('~/.bungloo/Plugin.js')
|
js_plugin_path = os.path.expanduser('~/.bungloo/Plugin.js')
|
||||||
if os.access(js_plugin_path, os.R_OK):
|
if os.access(js_plugin_path, os.R_OK):
|
||||||
|
@ -100,6 +105,11 @@ class WebViewCreator(QtWebKit.QWebView):
|
||||||
if callback:
|
if callback:
|
||||||
callback(ok)
|
callback(ok)
|
||||||
|
|
||||||
|
def handleSslErrors(self, reply, errors):
|
||||||
|
if os.name == "nt": # ignore SSL errors on Windows (yes a uggly workaround, don't know how to fix it yet)
|
||||||
|
reply.ignoreSslErrors()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NetworkAccessManager(QNetworkAccessManager):
|
class NetworkAccessManager(QNetworkAccessManager):
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,10 @@ define(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HostApp.osType = function() {
|
HostApp.osType = function() {
|
||||||
return OS_TYPE == "mac" ? "OS X" : "Linux";
|
var os_name = "OS X";
|
||||||
|
if (OS_TYPE == "windows") os_name = "Windows";
|
||||||
|
if (OS_TYPE == "linux") os_name = "Linux"
|
||||||
|
return os_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
HostApp.notificateViewsAboutDeletedPost = function(postId, entity) {
|
HostApp.notificateViewsAboutDeletedPost = function(postId, entity) {
|
||||||
|
|
Reference in a new issue