ugly workaround for ssl on windows

This commit is contained in:
Jeena Paradies 2013-04-03 00:32:43 +02:00
parent ce9900559d
commit 9019c95f75
3 changed files with 22 additions and 8 deletions

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python2
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:
import Windows, Helper
@ -13,6 +13,7 @@ else:
class Bungloo:
def __init__(self):
self.app = QtGui.QApplication(sys.argv)
self.new_message_windows = []
self.controller = Controller(self)
@ -30,7 +31,7 @@ class Bungloo:
def resources_path(self):
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:
return Helper.Helper.get_resource_path()

View file

@ -12,7 +12,7 @@ import array
class Helper:
@classmethod
def get_resource_path(cls):
return os.path.dirname(__file__)
return os.path.dirname(sys.argv[0])
class WebPage(QtWebKit.QWebPage):
def __init__(self, parent=0, app=None):
@ -43,6 +43,8 @@ class WebViewCreator(QtWebKit.QWebView):
self.customContextMenuRequested.connect(self.context_menu_requested)
self.actions = []
self.page().networkAccessManager().sslErrors.connect(lambda reply, errors: self.handleSslErrors(reply, errors))
def copy_link():
self.page().triggerAction(QtWebKit.QWebPage.CopyLinkToClipboard)
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):
frame = self.page().mainFrame()
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')
if os.access(js_plugin_path, os.R_OK):
@ -100,6 +105,11 @@ class WebViewCreator(QtWebKit.QWebView):
if callback:
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):

View file

@ -129,7 +129,10 @@ define(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) {