<commit_before>#!/usr/bin/env python3
INSTALL_DIR = "/opt/scudcloud/"
import sys, os
sys.path.append(INSTALL_DIR+'lib')
import notify2
from cookiejar import PersistentCookieJar
from gi.repository import Unity, GObject
from os.path import expanduser
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
from PyQt4.QtCore import QUrl, QSettings
from PyQt4.QtWebKit import QWebSettings

class ScudCloud(QtGui.QMainWindow):

    APP_NAME = "ScudCloud Client"

    def __init__(self, parent=None):
        super(ScudCloud, self).__init__(parent)
        self.setWindowTitle('ScudCloud')
        notify2.init(self.APP_NAME)
        self.newMessages = 0
        self.settings = QSettings(expanduser("~")+"/.scudcloud", QSettings.IniFormat)
        self.identifier = self.settings.value("Domain")
        input = (None, False)
        while self.identifier is None:
            input = QtGui.QInputDialog.getText(self, "ScudCloud", "Enter your Company Identifier:")
            self.identifier = str(input[0]).strip().lower()
            if input[1] is False:
                sys.exit(0)
        with open (INSTALL_DIR+"resources/notifications.js", "r") as f:
             self.js=f.read()
        self.settings.setValue("Domain", self.identifier)
        self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.desktop")
        self.resize(800, 600)
        self.centralwidget = QtGui.QWidget(self)
        self.mainLayout = QtGui.QHBoxLayout(self.centralwidget)
        self.mainLayout.setSpacing(0)
        self.mainLayout.setMargin(0)
        self.frame = QtGui.QFrame(self.centralwidget)
        self.gridLayout = QtGui.QVBoxLayout(self.frame)
        self.gridLayout.setMargin(0)
        self.gridLayout.setSpacing(0)
        self.webView = QtWebKit.QWebView()
        self.webView.urlChanged.connect(self.urlChanged)
        self.webView.titleChanged.connect(self.titleChanged)
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
        self.gridLayout.addWidget(self.webView)
        self.mainLayout.addWidget(self.frame)
        self.setCentralWidget(self.centralwidget)
        self.cookiesjar = PersistentCookieJar(self)
        self.webView.page().networkAccessManager().setCookieJar(self.cookiesjar)
        self.webView.load(QtCore.QUrl(self.domain()))
        self.webView.show()

    def focusInEvent(self, event):
        self.launcher.set_property("urgent", False)

    def titleChanged(self):
        self.setWindowTitle(self.webView.title())

    def domain(self):
        return "https://"+self.identifier+".slack.com/"

    def closeEvent(self, event):
        self.cookiesjar.save()

    @QtCore.pyqtSlot(str, str) 
    def sendMessage(self, title, message):
        notice = notify2.Notification(str(title), str(message), INSTALL_DIR+"resources/scudcloud.png")
        notice.show()

    def urlChanged(self):
        if self.domain() == self.webView.url().toString():
            self.webView.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(INSTALL_DIR+"/resources/login.css"))
        else:
            self.webView.page().currentFrame().addToJavaScriptWindowObject("desktop", self)
            self.webView.page().currentFrame().evaluateJavaScript(self.js)

    @QtCore.pyqtSlot(int) 
    def count(self, value):
        if value > self.newMessages:
            if not self.isActiveWindow():
                self.launcher.set_property("urgent", True)
        elif 0 == value:
            self.launcher.set_property("urgent", False)<commit_msg>Adding linkClicked handler (#1)<commit_after>#!/usr/bin/env python3
INSTALL_DIR = "/opt/scudcloud/"
import sys, subprocess, os
sys.path.append(INSTALL_DIR+'lib')
import notify2
from cookiejar import PersistentCookieJar
from gi.repository import Unity, GObject
from os.path import expanduser
from PyQt4 import QtCore, QtGui, QtWebKit, QtNetwork
from PyQt4.QtCore import QUrl, QSettings
from PyQt4.QtWebKit import QWebSettings

class ScudCloud(QtGui.QMainWindow):

    APP_NAME = "ScudCloud Client"

    def __init__(self, parent=None):
        super(ScudCloud, self).__init__(parent)
        self.setWindowTitle('ScudCloud')
        notify2.init(self.APP_NAME)
        self.newMessages = 0
        self.settings = QSettings(expanduser("~")+"/.scudcloud", QSettings.IniFormat)
        self.identifier = self.settings.value("Domain")
        input = (None, False)
        while self.identifier is None:
            input = QtGui.QInputDialog.getText(self, "ScudCloud", "Enter your Company Identifier:")
            self.identifier = str(input[0]).strip().lower()
            if input[1] is False:
                sys.exit(0)
        with open (INSTALL_DIR+"resources/notifications.js", "r") as f:
             self.js=f.read()
        self.settings.setValue("Domain", self.identifier)
        self.launcher = Unity.LauncherEntry.get_for_desktop_id("scudcloud.desktop")
        self.resize(800, 600)
        self.centralwidget = QtGui.QWidget(self)
        self.mainLayout = QtGui.QHBoxLayout(self.centralwidget)
        self.mainLayout.setSpacing(0)
        self.mainLayout.setMargin(0)
        self.frame = QtGui.QFrame(self.centralwidget)
        self.gridLayout = QtGui.QVBoxLayout(self.frame)
        self.gridLayout.setMargin(0)
        self.gridLayout.setSpacing(0)
        self.webView = QtWebKit.QWebView()
        self.webView.urlChanged.connect(self.urlChanged)
        self.webView.titleChanged.connect(self.titleChanged)
        self.webView.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
        self.webView.linkClicked.connect(self.linkClicked)
        QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
        self.gridLayout.addWidget(self.webView)
        self.mainLayout.addWidget(self.frame)
        self.setCentralWidget(self.centralwidget)
        self.cookiesjar = PersistentCookieJar(self)
        self.webView.page().networkAccessManager().setCookieJar(self.cookiesjar)
        self.webView.load(QtCore.QUrl(self.domain()))
        self.webView.show()

    def focusInEvent(self, event):
        self.launcher.set_property("urgent", False)

    def titleChanged(self):
        self.setWindowTitle(self.webView.title())

    def domain(self):
        return "https://"+self.identifier+".slack.com/"

    def closeEvent(self, event):
        self.cookiesjar.save()

    @QtCore.pyqtSlot(str, str) 
    def sendMessage(self, title, message):
        notice = notify2.Notification(str(title), str(message), INSTALL_DIR+"resources/scudcloud.png")
        notice.show()

    def urlChanged(self):
        if self.domain() == self.webView.url().toString():
            self.webView.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(INSTALL_DIR+"/resources/login.css"))
        else:
            self.webView.page().currentFrame().addToJavaScriptWindowObject("desktop", self)
            self.webView.page().currentFrame().evaluateJavaScript(self.js)

    def linkClicked(self, url):
        subprocess.call(('xdg-open', url.toString()))

    @QtCore.pyqtSlot(int) 
    def count(self, value):
        if value > self.newMessages:
            if not self.isActiveWindow():
                self.launcher.set_property("urgent", True)
        elif 0 == value:
            self.launcher.set_property("urgent", False)
{'fraction_non_alphanumeric': 0.12174032390886631, 'fraction_numerical': 0.0061762283832006585, 'mean_word_length': 3.128611898016997, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5723534', 'n_tokens_mistral': 2287, 'n_tokens_neox': 2201, 'n_words': 354}