Esempio n. 1
0
    def on_addButton_clicked(self):
        (res, name, url) = MultiInputDialog.getTexts(self._tr("Add repository"),
                                                     self._tr("Name:"),
                                                     self._tr("URL:"), "", "",
                                                     self)

        if res:
            qurl = QUrl(url)
            if qurl.isValid() and not qurl.isLocalFile():
                rep = dict()
                rep["name"] = name
                rep["url"] = url
                rep["origin"] = "local"
                rep["active"] = True

                self.replist[name] = rep

                item = QListWidgetItem(name)
                item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsUserCheckable |
                              Qt.ItemIsEnabled)
                item.setCheckState(Qt.Checked)
                item.setData(Qt.UserRole, name)
                self.repositoryList.addItem(item)
            else:
                QMessageBox.critical(self._tr("Error"),
                                     self._tr("The URL {url} is not valid").
                                     format(url=url))
Esempio n. 2
0
 def on_btn_beautify_clicked(self):
     try:
         try:
             from css_html_prettify import css_prettify
         except:
             _t = QMessageBox.question(self, "Can't beautify", "Python package \"css_html_prettify\" could not be loaded.\nDo you want to try installing it now?", QMessageBox.Yes, QMessageBox.No)
             if _t == QMessageBox.Yes:
               from devtools import PluginInstaller
               PluginInstaller().installPackages(['css_html_prettify'])
               self.on_btn_beautify_clicked()
             return
             #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_()
         index = self.tabWidget.currentIndex
         _old = ""
         if index == 0:
             _old = self.qssEditor.toPlainText()
         elif index == 1: _old = self.chatEditor.toPlainText()
         _beautified = css_prettify(_old)
         if index == 0:
             QApplication.instance().styleSheet = _beautified
             self.qssEditor.setPlainText(_beautified)
         elif index == 1: self.chatEditor.setPlainText(_beautified);return
         if QMessageBox(QMessageBox.Warning, "Use minified QSS?", "Your minified QSS code has been applied.\n\nIf you encounter any issues with the minified code you should click on cancel.", QMessageBox.Ok | QMessageBox.Cancel).exec_() == QMessageBox.Cancel:
             QApplication.instance().styleSheet = _old
             self.qssEditor.setPlainText(_old)
     except:
         try:
             from traceback import format_exc
             QMessageBox(QMessageBox.Critical, "Can't beautify", format_exc()).exec_()
         except:
             print(format_exc())
Esempio n. 3
0
    def on_pluginsList_currentItemChanged(self, cur, prev):
        if cur:
            name = cur.data(Qt.UserRole)
            if name not in self.addons:
                QMessageBox.critical(self, self._tr("Internal error"),
                                     self._tr("Can't find addon {name} in "
                                              "list").format(name=name))
                return

            p = self.addons[name]
            self.nameEdit.setText(p["name"])
            self.authorEdit.setText(p["author"])
            self.versionEdit.setText(p["version"])
            self.descriptionEdit.setPlainText(p["description"])
            self.apiEdit.setText(p["apiVersion"])
            self.repositoryEdit.setText(p["repository"])

            if name in self.host.plugins:
                if p["version"] > self.host.plugins[name].version:
                    self.installButton.setEnabled(True)
                    self.installButton.setText(self._tr("Update"))
                else:
                    self.installButton.setEnabled(False)
                    self.installButton.setText(self._tr("Install"))
            else:
                self.installButton.setEnabled(True)
                self.installButton.setText(self._tr("Install"))
        else:
            self.nameEdit.clear()
            self.authorEdit.clear()
            self.versionEdit.clear()
            self.descriptionEdit.clear()
            self.apiEdit.clear()
            self.repositoryEdit.clear()
Esempio n. 4
0
	def startAuthenticationProcess(self):
		self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(False)
		self.flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect('sfacmqvdb9dn66r', 'hx8meda636xgsox')
		authorize_url = QUrl(self.flow.start())
		QDesktopServices.openUrl(authorize_url)
		try:
			code = raw_input("Enter the authorization code from the dropbox website:")
		except NameError:
			code = input("Enter the authorization code from the dropbox website:")
		if code:
			try:
				oauth2_result = self.flow.finish(code)
				self.access_token = oauth2_result.access_token
				self.client = dropbox.Dropbox(self.access_token)
				account = self.client.users_get_current_account()
				self.user_id = account.account_id
				self.display_name = account.name.display_name
			except dropbox.auth.AccessError:
				if "win" in sys.platform: #Workaround for crash on windows
					self.parentWidget.hide()
					self.settingsDialog.hide()
				QMessageBox.critical(self.settingsDialog, "Failed to authenticate", "Failed to authenticate with Dropbox. Wrong code?")
				if "win" in sys.platform:
					self.settingsDialog.show()
					self.parentWidget.show()
		self.saveSettings()
		self.updateUi()
Esempio n. 5
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if menuItemID == 0:
             error, ownid = ts3.getClientID(schid)
             if error == ERROR_ok:
                 error, meta = ts3.getClientVariableAsString(schid, ownid, ClientProperties.CLIENT_META_DATA)
                 if error == ERROR_ok:
                     x = QWidget()
                     _meta = QInputDialog.getMultiLineText(x, "Change own Meta Data", "Meta Data:", meta)
                     if _meta == meta: return
                     error = ts3.setClientSelfVariableAsString(schid, ClientProperties.CLIENT_META_DATA, _meta)
                     if not error == ERROR_ok:
                         _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error, "Unable to set own meta data!");_t.show()
         elif menuItemID == 1:
             error, ownid = ts3.getClientID(schid)
             if error == ERROR_ok:
                 error, flag = ts3.getClientVariableAsString(schid, ownid, ClientPropertiesRare.CLIENT_FLAG_AVATAR)
                 ts3.printMessageToCurrentTab("Your current avatar flag is: %s"%flag)
                 if error == ERROR_ok:
                     x = QWidget()
                     _flag = QInputDialog.getText(x, "Change own Avatar Flag", "Avatar File MD5:")
                     if _flag == "x" or _flag.strip() == flag.strip(): return
                     error = ts3.setClientSelfVariableAsString(schid, ClientPropertiesRare.CLIENT_FLAG_AVATAR, _flag)
                     error2 = ts3.flushClientSelfUpdates(schid)
                     if not error == ERROR_ok or not error2 == ERROR_ok:
                         _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own avatar flag!");_t.show()
Esempio n. 6
0
 def startAuthenticationProcess(self):
     self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(
         False)
     self.flow = dropbox.client.DropboxOAuth2FlowNoRedirect(
         'sfacmqvdb9dn66r', 'hx8meda636xgsox')
     authorize_url = QUrl(self.flow.start())
     QDesktopServices.openUrl(authorize_url)
     try:
         code = raw_input(
             "Enter the authorization code from the dropbox website:")
     except NameError:
         code = input(
             "Enter the authorization code from the dropbox website:")
     if code:
         try:
             self.access_token, self.user_id = self.flow.finish(code)
             self.client = dropbox.client.DropboxClient(self.access_token)
             self.display_name = self.client.account_info()['display_name']
         except dropbox.rest.ErrorResponse:
             if "win" in sys.platform:  #Workaround for crash on windows
                 self.parentWidget.hide()
                 self.settingsDialog.hide()
             QMessageBox.critical(
                 self.settingsDialog, "Failed to authenticate",
                 "Failed to authenticate with Dropbox. Wrong code?")
             if "win" in sys.platform:
                 self.settingsDialog.show()
                 self.parentWidget.show()
     self.saveSettings()
     self.updateUi()
Esempio n. 7
0
    def on_installButton_clicked(self):
        item = self.pluginsList.currentItem()
        if not item:
            return

        name = item.data(Qt.UserRole)
        if name not in self.addons:
            QMessageBox.critical(self, self._tr("Internal error"),
                                 self._tr("Can't find addon {name} in list").
                                 format(name=name))
            return

        p = self.addons[name]

        # update?, so remove the local one first
        if name in self.host.plugins:
            if p["version"] > self.host.plugins[name].version:
                devtools.PluginInstaller.removePlugin(name)
            else:
                # should not happen (ui restricted)
                QMessageBox.critical(self, self._tr("Internal error"),
                                     self._tr("This plugin is already "
                                              "installed"))
                return

        self.installer = InstallDialog(self.host, self)
        self.installer.show()
        self.installer.install(p)
Esempio n. 8
0
    def getList(self):
        import dynamic_graph
        from dynamic_graph.sot.core.robot_simu import RobotSimu

        chaine = "\n".join(dynamic_graph.entity.Entity.entityClassNameList)

        # Show the list of entities used with QMessageBox
        QMessageBox.information(None, "Entity list", chaine, QMessageBox.Ok,
                                QMessageBox.Ok)
Esempio n. 9
0
    def onLoadMenusButtonChanged(self, state):
        if state == Qt.Checked:
            self.cfg.set("general", "loadAllMenus", "True")
        else:
            self.cfg.set("general", "loadAllMenus", "False")

        QMessageBox.information(self, self._tr("Restart required"),
                                self._tr("Changes only take effect after a "
                                         "restart."))
Esempio n. 10
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL and menuItemID == 0:
         error, ownid = ts3lib.getClientID(schid)
         if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s" % error,"Unable to get own client ID in Tab #%s!"%schid);_t.show();return
         error, ownchan = ts3lib.getChannelOfClient(schid, ownid)
         if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s" % error,"Unable to get own channel ID in Tab #%s!"%schid);_t.show();return
         self.sendMessage(schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL, ownchan)
     elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT and menuItemID == 0:
         self.sendMessage(schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT, selectedItemID)
     elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL and menuItemID == 0:
         self.sendMessage(schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL, selectedItemID)
Esempio n. 11
0
def msgBox(text, icon=QMessageBox.Information, title=""):
    """
    :param text:
    :param icon:
    :param title:
    """
    x = QMessageBox()
    if title: x.setWindowTitle(title)
    x.setText(text)
    x.setIcon(icon)
    x.exec()
Esempio n. 12
0
	def pinEntered(self):
		pin = self.settingsDialog.group_account.input_code.text
		if pin:
			try:
				self.access_token, self.refresh_token = self.imgur.exchange_pin(pin)
			except KeyError as e:
				QMessageBox.critical(self.settingsDialog, "Imgur key error", "Failed to exchange pin. " + e.message)
				return
		self.access_token, self.username = self.imgur.refresh_access_token()
		self.saveSettings()
		self.updateUi()
Esempio n. 13
0
    def on_deleteButton_clicked(self):
        cur = self.repositoryList.currentItem()
        if cur:
            name = cur.data(Qt.UserRole)
            if name not in self.replist:
                QMessageBox.critical(self._tr("Internal error"),
                                     self._tr("Can't find repository {name} "
                                              "in list").format(name=name))
                return

            del self.replist[name]
            cur.delete()
Esempio n. 14
0
    def on_repositoryList_currentItemChanged(self, cur, prev):
        if cur:
            name = cur.data(Qt.UserRole)
            if name not in self.replist:
                self.deleteButton.setEnabled(False)
                QMessageBox.critical(self, self._tr("Internal error"),
                                     self._tr("Can't find repository {name} "
                                              "in list").format(name=name))
                return

            self.deleteButton.setEnabled(True)
        else:
            self.deleteButton.setEnabled(False)
Esempio n. 15
0
 def authorizationCodeEntered(self):
     code = self.settingsDialog.group_account.widget_authenticate.input_code.text
     if code:
         try:
             self.access_token, self.user_id = self.flow.finish(code)
         except dropbox.rest.ErrorResponse:
             QMessageBox.critical(0, "Failed to authenticate", "Failed to authenticate with Dropbox. Wrong code?")
             self.settingsDialog.group_account.widget_authenticate.input_code.setText("")
             return
         self.client = dropbox.client.DropboxClient(self.access_token)
         self.display_name = self.client.account_info()["display_name"]
     self.saveSettings()
     self.updateUi()
Esempio n. 16
0
 def sendMessage(self, schid, targetMode, toID):
     x = QWidget()
     clipboard = QApplication.clipboard().text();
     _message = QInputDialog.getMultiLineText(x, "Enter long text here", "", clipboard)
     message = [_message[i:i + self.maxsize] for i in range(0, len(_message), self.maxsize)]
     if targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL:
         for msg in message:
             error = ts3lib.requestSendChannelTextMsg(schid, "\n"+msg, toID)
             if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
     elif targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT:
         for msg in message:
             error = ts3lib.requestSendPrivateTextMsg(schid, "\n"+msg, toID)
             if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
Esempio n. 17
0
 def on_btn_beautify_clicked(self):
     try:
         try:
             from bs4 import BeautifulSoup
         except Exception:
             from traceback import format_exc
             print("Error: {0}".format(format_exc()))
             _t = QMessageBox.question(
                 self, "Can't beautify",
                 "Python package \"beautifulsoup4\" could not be loaded.\nDo you want to try installing it now?",
                 QMessageBox.Yes, QMessageBox.No)
             if _t == QMessageBox.Yes:
                 from devtools import PluginInstaller
                 PluginInstaller().installPackages(['beautifulsoup4'])
                 self.on_btn_beautify_clicked()
             return
             #import traceback; QMessageBox.Critical("Can't minify", traceback.format_exc()).exec_()
         index = self.tabWidget.currentIndex
         _old = ""
         if index == 0: _old = self.qssEditor.toPlainText()
         elif index == 1: _old = self.chatEditor.toPlainText()
         elif index == 2: _old = self.tplEditor.toPlainText()
         elif index == 3: _old = self.chatEditor_html.toPlainText()
         _beautified = BeautifulSoup(_old)
         _beautified = _beautified.prettify()
         if index == 0:
             QApplication.instance().styleSheet = _beautified
             self.qssEditor.setPlainText(_beautified)
         elif index == 1:
             self.chatEditor.setPlainText(_beautified)
             return
         elif index == 2:
             self.tplEditor.setPlainText(_beautified)
             return
         elif index == 3:
             self.chatEditor_html.setPlainText(_beautified)
             return
         if QMessageBox(
                 QMessageBox.Warning, "Use beautified code?",
                 "Your beautified code has been applied.\n\nIf you encounter any issues with the beautified code you should click on cancel.",
                 QMessageBox.Ok
                 | QMessageBox.Cancel).exec_() == QMessageBox.Cancel:
             QApplication.instance().styleSheet = _old
             self.qssEditor.setPlainText(_old)
     except:
         try:
             from traceback import format_exc
             QMessageBox(QMessageBox.Critical, "Can't beautify",
                         format_exc()).exec_()
         except:
             print(format_exc())
Esempio n. 18
0
    def on_repositoryList_itemChanged(self, item):
        if not item:
            return

        name = item.data(Qt.UserRole)

        if name not in self.replist:
            QMessageBox.critical(self, self._tr("Internal error"),
                                 self._tr("Can't find repository {name} in "
                                          "list").format(name=name))
            return
        if self.replist[name]["active"] != (item.checkState() == Qt.Checked):
            self.replist[name]["active"] = (item.checkState() == Qt.Checked)
            self.updateAddonlist()
Esempio n. 19
0
	def startAuthenticationProcess(self):
		self.saveSettings()
		self.loadSettings()
		auth_url = self.imgur.authorization_url('pin')
		QDesktopServices.openUrl(QUrl(auth_url))
		pin = raw_input("Enter PIN from imgur website:")
		if pin:
			try:
				self.access_token, self.refresh_token = self.imgur.exchange_pin(pin)
			except KeyError as e:
				QMessageBox.critical(self.settingsDialog, "Imgur key error", "Failed to exchange pin. " + e.message)
		self.access_token, self.username = self.imgur.refresh_access_token()
		self.saveSettings()
		self.updateUi()
Esempio n. 20
0
    def Logout(self):
        Settings = QSettings()

        Settings.beginGroup("uploaders")
        Settings.beginGroup("cloudup")

        Settings.remove("token")

        Settings.endGroup()
        Settings.endGroup()

        self.loadSettings()
        self.updateUi()

        QMessageBox.information(self.settingsDialog, "Success!", "You have successfully signed out of your Cloudup account.")
Esempio n. 21
0
    def showChangelog(cls):
        fname = pytson.getPluginPath("Changelog.html")
        if not os.path.isfile(fname):
            QMessageBox.critical(None, cls._tr("Error"), cls._tr("Can't find "
                                                                 "Changelog"))
            return

        with open(fname, "r") as f:
            # store it just to keep it in scope
            cls.viewer = viewer = QTextBrowser()
            viewer.setAttribute(Qt.WA_DeleteOnClose)
            viewer.openExternalLinks = True
            viewer.setHtml(f.read())

            viewer.show()
Esempio n. 22
0
 def confirm(self, title, message):
     x = QDialog()
     x.setAttribute(Qt.WA_DeleteOnClose)
     _t = QMessageBox.question(x, title, message, QMessageBox.Yes,
                               QMessageBox.No)
     if _t == QMessageBox.Yes: return True
     else: return False
Esempio n. 23
0
    def showChangelog(cls):
        fname = pytson.getPluginPath("Changelog.html")
        if not os.path.isfile(fname):
            QMessageBox.critical(None, cls._tr("Error"),
                                 cls._tr("Can't find "
                                         "Changelog"))
            return

        with open(fname, "r") as f:
            # store it just to keep it in scope
            cls.viewer = viewer = QTextBrowser()
            viewer.setAttribute(Qt.WA_DeleteOnClose)
            viewer.openExternalLinks = True
            viewer.setHtml(f.read())

            viewer.show()
Esempio n. 24
0
    def deleteFiles(self, files=None):
        if self.readonly:
            return

        if not files:
            selfiles = self.selectedFiles()
        else:
            selfiles = files

        if not selfiles:
            return

        if QMessageBox.question(
                self, self._tr("Delete files"),
                self._tr("Do you really want to delete all "
                         "selected files?")) == QMessageBox.No:
            return

        pathes = [f.fullpath for f in selfiles]
        self.delretcode = ts3lib.createReturnCode()
        err = ts3lib.requestDeleteFile(self.schid, self.cid, self.password,
                                       pathes, self.delretcode)

        if err != ERROR_ok:
            self.showError(self._tr("Error deleting files"), err)
Esempio n. 25
0
 def startAuthenticationProcess(self):
     self.saveSettings()
     self.loadSettings()
     auth_url = self.imgur.authorization_url('pin')
     QDesktopServices.openUrl(QUrl(auth_url))
     pin = raw_input("Enter PIN from imgur website:")
     if pin:
         try:
             self.access_token, self.refresh_token = self.imgur.exchange_pin(
                 pin)
         except KeyError as e:
             QMessageBox.critical(self.settingsDialog, "Imgur key error",
                                  "Failed to exchange pin. " + e.message)
     self.access_token, self.username = self.imgur.refresh_access_token()
     self.saveSettings()
     self.updateUi()
Esempio n. 26
0
 def on_btn_reset_clicked(self):
     if QMessageBox(
             QMessageBox.Warning, "Reset QSS?",
             "This will reset your changes to the initial Stylesheet! Continue?",
             QMessageBox.Ok
             | QMessageBox.Cancel).exec_() == QMessageBox.Ok:
         QApplication.instance().styleSheet = self.stylesheet
         self.qssEditor.setPlainText(self.stylesheet)
Esempio n. 27
0
    def onPluginsTableItemChanged(self, item):
        checked = item.checkState() == Qt.Checked
        name = item.data(Qt.UserRole)

        if checked and name not in self.host.active:
            if self.host.activate(name):
                if self.host.active[name].offersConfigure:
                    self.pluginsTable.cellWidget(item.row(),
                                                 1).setEnabled(True)
            else:
                item.setCheckState(Qt.Unchecked)
                QMessageBox.critical(self, self._tr("Activation failed"),
                                     self._tr("Error starting plugin, check "
                                     "your client log for more information"))
        elif not checked and name in self.host.active:
            if self.host.active[name].offersConfigure:
                self.pluginsTable.cellWidget(item.row(), 1).setEnabled(False)
            self.host.deactivate(name)
Esempio n. 28
0
    def on_siteremoveButton_clicked(self):
        ids = {it.data(Qt.UserRole) for it in self.siteTable.selectedItems()}

        if ids:
            if (QMessageBox.question(self, self._tr("Remove site packages"),
                                     self._tr("Are you sure to remove the "
                                              "selected packages? Some "
                                              "plugins might not work "
                                              "properly.")) ==
               QMessageBox.Yes):
                try:
                    for idx in ids:
                        devtools.removePackage(self.sitepkgs[idx]["name"],
                                               self.sitepkgs[idx]["version"])
                except Exception as e:
                    QMessageBox.critical(self, self._tr("Error"), str(e))

        self.reloadSite()
Esempio n. 29
0
def confirm(title, message):
    """
    :param title:
    :param message:
    :return:
    """
    x = QWidget()
    x.setAttribute(Qt.WA_DeleteOnClose)
    _x = QMessageBox.question(x, title, message, QMessageBox.Yes, QMessageBox.No)
    if _x == QMessageBox.Yes: return True if _x == QMessageBox.Yes else False
Esempio n. 30
0
    def getNodeInformation(self, e):
        signals = eval(
            self.cmd.run("[ s.name for s in dg.entity.Entity.entities['" + e +
                         "'].signals() ]"))
        chaine = "\n"
        for s in signals:
            ss = s.split("::")
            if len(ss) != 3:
                print("Cannot handle" + s)
            elif ss[1].startswith("in"):
                InfType = ss[1]
                text = InfType[InfType.find('(') + 1:InfType.find(')')]
                chaine = chaine + "input : " + ss[2] + ", type :" + text + "\n"
            elif ss[1].startswith("out"):
                InfType = ss[1]
                text = InfType[InfType.find('(') + 1:InfType.find(')')]
                chaine = chaine + "output : " + ss[2] + ", type :" + text + "\n"

        QMessageBox.information(None, "Node : " + e, chaine, QMessageBox.Ok,
                                QMessageBox.Ok)
Esempio n. 31
0
 def updateReply(self, reply):
     version = loads(reply.readAll().data().decode('utf-8'))["version"]
     if version != self.version:
         x = QDialog()
         x.setAttribute(Qt.WA_DeleteOnClose)
         _x = QMessageBox.question(
             x, "{} v{} by {}".format(self.name, self.version, self.author),
             "Noua versiune v{} la linksteam a fost gasita, dai update acum?"
             .format(version), QMessageBox.Yes, QMessageBox.No)
         if _x == QMessageBox.Yes:
             QDesktopServices.openUrl(QUrl(self.repourl))
Esempio n. 32
0
 def onDelChannelEvent(self, schid, channel, invokerID, invokerName,
                       invokerUniqueIdentifier):
     if self.schid == schid and self.channel == channel:
         msgBox = QMessageBox()
         msgBox.setText(
             "Channel \"{0}\" got deleted by \"{1}\"\n\nStopping Queue!".
             format(self.cname, invokerName))
         msgBox.setIcon(QMessageBox.Warning)
         msgBox.exec()
         self.schid = 0
         self.channel = 0
         self.password = ""
         self.name = ""
Esempio n. 33
0
    def on_repositoryList_doubleClicked(self, item):
        name = item.data(Qt.UserRole)
        try:
            rep = self.replist[name]
        except:
            QMessageBox.critical(self, self._tr("Internal error"),
                                 self._tr("Can't find repository {name} in "
                                          "list").format(name=name))
            return

        ok = BoolResult()
        newurl = QInputDialog.getText(self,
                                      self._tr("Change url of repository "
                                               "{name}").format(name=name),
                                      self._tr("Url:"), QLineEdit.Normal,
                                      rep["url"], ok)

        if ok:
            rep["url"] = newurl
            rep["origin"] = "local"
Esempio n. 34
0
    def startAuthenticationProcess(self):
        if self.settingsDialog.group_account.input_url.text and self.settingsDialog.group_account.input_username.text and self.settingsDialog.group_account.input_password.text:
            self.saveSettings()
            self.loadSettings()
            if match(self.url, "URI"):
                try:
                    request = requests.get(self.url, timeout=3);

                    if request.status_code == 200:
                        oc = owncloud.Client(self.url)
                        oc.login(self.username, self.password)
                        self.connectStatus = "true"
                        self.saveSettings()
                        self.updateUi()
                except requests.exceptions.RequestException as e:
                    QMessageBox.critical(self.settingsDialog, "OwnCloud Connection Error", "The specified Server URL is invalid!")
                    settings = QSettings()
                    settings.remove("connect-status")
                    self.saveSettings()
                    self.updateUi()
                except Exception as e:
                    errorMessage = self.formatConnectionError(e.message)

                    if errorMessage == "401":
                        self.settingsDialog.group_connection.widget_status.label_status.setText("Invalid")
                    else:
                        QMessageBox.critical(self.settingsDialog, "OwnCloud Connection Error", errorMessage)
            else:
                QMessageBox.critical(self.settingsDialog, "OwnCloud Connection Error", "The specified Server URL is invalid!")
        else:
            missingFields = ""
            fieldText = "field"

            if not self.settingsDialog.group_account.input_url.text:
                missingFields = "\"Server URL\""

            if not self.settingsDialog.group_account.input_username.text:
                if missingFields == "":
                    missingFields = "\"Username\""
                else:
                    missingFields = missingFields + " and \"Username\""
                    fieldText = "fields"

            if not self.settingsDialog.group_account.input_password.text:
                if missingFields == "":
                    missingFields = "\"Password\""
                else:
                    missingFields = missingFields.replace(" and", ",") + " and \"Password\""
                    fieldText = "fields"

            QMessageBox.critical(self.settingsDialog, "OwnCloud Connection Error", "The " + missingFields + " " + fieldText + " must be filled in!")
Esempio n. 35
0
    def Login(self):
        self.saveSettings()

        # Grab credentials from the currently available fields, not saved settings.
        if self.settingsDialog.group_account:
            Username = self.settingsDialog.group_account.input_username.text
            Password = self.settingsDialog.group_account.input_password.text

            # Headers and payload.
            Headers = {"User-Agent": "ScreenCloud-Cloudup"}

            Payload = {
                "client_id": "ah5Oa7F3hT8",
                "grant_type": "password",
                "username": Username,
                "password": Password
            }

            try:
                r = requests.post("https://cloudup.com/oauth/access_token", data = Payload, headers = Headers)
                j = json.loads(r.text)

                if r.status_code == 400:
                    QMessageBox.critical(self.settingsDialog, "Cloudup Login Error", j["error_description"])

                self.Key = j["access_token"]

                self.saveSettings()
                self.loadSettings()
                self.updateUi()

                QMessageBox.information(self.settingsDialog, "Success!", "You have successfully signed into your Cloudup account.")
            except Exception as e:
                QMessageBox.critical(self.settingsDialog, "Cloudup Login Error", "Error occurred during login. " + e.message)
Esempio n. 36
0
 def startAuthenticationProcess(self):
     self.settingsDialog.group_account.widget_authorize.button_authenticate.setEnabled(
         False)
     self.flow = client.OAuth2WebServerFlow(
         client_id=self.clientID,
         client_secret=self.clientSecret,
         scope=SCOPES,
         redirect_uri="urn:ietf:wg:oauth:2.0:oob")
     authorize_url = QUrl(self.flow.step1_get_authorize_url())
     QDesktopServices.openUrl(authorize_url)
     try:
         code = raw_input(
             "Enter the authorization code from the Google Drive website:")
     except NameError:
         code = input(
             "Enter the authorization code from the Google Drive website:")
     if code:
         try:
             oauth2_result = self.flow.step2_exchange(code)
             self.accessToken = oauth2_result.access_token
             self.refreshToken = oauth2_result.refresh_token
             self.driveService = build('drive',
                                       'v3',
                                       http=oauth2_result.authorize(Http()))
             account = self.driveService.about().get(
                 fields="user").execute()
             self.displayName = account["user"]["displayName"]
         except client.Error:
             if "win" in sys.platform:  #Workaround for crash on windows
                 self.parentWidget.hide()
                 self.settingsDialog.hide()
             QMessageBox.critical(
                 self.settingsDialog, "Failed to authenticate",
                 "Failed to authenticate with Google Drive. Wrong code?")
             if "win" in sys.platform:
                 self.settingsDialog.show()
                 self.parentWidget.show()
     self.saveSettings()
     self.updateUi()
Esempio n. 37
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if menuItemID == 0:
             schid = ts3.getCurrentServerConnectionHandlerID()
             error, ownid = ts3.getClientID(schid)
             if error == ts3defines.ERROR_ok:
                 error, meta = ts3.getClientVariableAsString(
                     schid, ownid,
                     ts3defines.ClientProperties.CLIENT_META_DATA)
                 if error == ts3defines.ERROR_ok:
                     x = QWidget()
                     meta = QInputDialog.getMultiLineText(
                         x, "Change own Meta Data", "Meta Data:", meta)
                     error = ts3.setClientSelfVariableAsString(
                         schid,
                         ts3defines.ClientProperties.CLIENT_META_DATA, meta)
                     if not error == ts3defines.ERROR_ok:
                         _t = QMessageBox(QMessageBox.Critical, "Error",
                                          "Unable to set own meta data!")
                         t.show()
Esempio n. 38
0
    def parseUpdateReply(cls, repstr):
        def platform_str():
            try:
                import platform
            except:
                raise Exception("Error importing platform module")

            if sys.platform == "linux":
                if platform.architecture()[0] == "64bit":
                    return "linux_amd64"
                else:
                    return "linux_x86"
            elif sys.platform == "win32":
                return "win%s" % platform.architecture()[0][:2]
            else:
                return "mac"

        try:
            obj = json.loads(repstr)

            if obj["tag_name"] == "v%s" % pytson.getVersion():
                QMessageBox.information(
                    None, cls._tr("pyTSon Update Check"),
                    cls._tr("You are running the latest "
                            "pyTSon release"))
            else:
                for a in obj["assets"]:
                    if a["name"] == "pyTSon_%s.ts3_plugin" % platform_str():
                        msg = cls._tr("There is an update of pyTSon for your "
                                      "platform. Get it from <a href='{url}'>"
                                      "here</a>").format(url=obj["html_url"])
                        QMessageBox.information(None,
                                                cls._tr("pyTSon Update Check"),
                                                msg)
                        return

                QMessageBox.information(
                    None, cls._tr("pyTSon Update Check"),
                    cls._tr("You are running the latest "
                            "pyTSon release (at least for "
                            "your platform)"))
        except:
            logprint(
                cls._tr("Error parsing reply from update check: {trace}"
                        ).format(trace=traceback.format_exc()),
                ts3defines.LogLevel.LogLevel_ERROR,
                "pyTSon.PluginHost.parseUpdateReply")
Esempio n. 39
0
    def parseUpdateReply(cls, repstr):
        def platform_str():
            try:
                import platform
            except:
                raise Exception("Error importing platform module")

            if sys.platform == "linux":
                if platform.architecture()[0] == "64bit":
                    return "linux_amd64"
                else:
                    return "linux_x86"
            elif sys.platform == "win32":
                return "win%s" % platform.architecture()[0][:2]
            else:
                return "mac"

        try:
            obj = json.loads(repstr)

            if obj["tag_name"] == "v%s" % pytson.getVersion():
                QMessageBox.information(None, cls._tr("pyTSon Update Check"),
                                        cls._tr("You are running the latest "
                                        "pyTSon release"))
            else:
                for a in obj["assets"]:
                    if a["name"] == "pyTSon_%s.ts3_plugin" % platform_str():
                        msg = cls._tr("There is an update of pyTSon for your "
                                      "platform. Get it from <a href='{url}'>"
                                      "here</a>").format(url=obj["html_url"])
                        QMessageBox.information(None,
                                                cls._tr("pyTSon Update Check"),
                                                msg)
                        return

                QMessageBox.information(None, cls._tr("pyTSon Update Check"),
                                        cls._tr("You are running the latest "
                                                "pyTSon release (at least for "
                                                "your platform)"))
        except:
            logprint(cls._tr("Error parsing reply from update check: {trace}").
                     format(trace=traceback.format_exc()),
                     ts3defines.LogLevel.LogLevel_ERROR,
                     "pyTSon.PluginHost.parseUpdateReply")
Esempio n. 40
0
    def deleteFiles(self, files=None):
        if self.readonly:
            return

        if not files:
            selfiles = self.selectedFiles()
        else:
            selfiles = files

        if not selfiles:
            return

        if QMessageBox.question(self, self._tr("Delete files"),
                                self._tr("Do you really want to delete all "
                                         "selected files?")) == QMessageBox.No:
            return

        pathes = [f.fullpath for f in selfiles]
        self.delretcode = ts3lib.createReturnCode()
        err = ts3lib.requestDeleteFile(self.schid, self.cid, self.password,
                                       pathes, self.delretcode)

        if err != ERROR_ok:
            self.showError(self._tr("Error deleting files"), err)
Esempio n. 41
0
 def showSettingsUI(self, parentWidget):
     QMessageBox.information(parentWidget,
                             'Vgy',
                             'This plugin has no settings.')
Esempio n. 42
0
    def startAuthenticationProcess(self):
        if self.settingsDialog.group_account.input_url.text and self.settingsDialog.group_account.input_username.text and self.settingsDialog.group_account.input_password.text:
            self.saveSettings()
            self.loadSettings()
            if match(self.url, "URI"):
                try:
                    request = requests.get(self.url, timeout=3)

                    if request.status_code == 200:
                        oc = nextcloud.Client(self.url)
                        oc.login(self.username, self.password)
                        self.connectStatus = "true"
                        self.saveSettings()
                        self.updateUi()
                except requests.exceptions.RequestException as e:
                    QMessageBox.critical(
                        self.settingsDialog, "NextCloud Connection Error",
                        "The specified Server URL is invalid!")
                    settings = QSettings()
                    settings.remove("connect-status")
                    self.saveSettings()
                    self.updateUi()
                except Exception as e:
                    errorMessage = self.formatConnectionError(e.message)

                    if errorMessage == "401":
                        self.settingsDialog.group_connection.widget_status.label_status.setText(
                            "Invalid")
                    else:
                        QMessageBox.critical(self.settingsDialog,
                                             "NextCloud Connection Error",
                                             errorMessage)
            else:
                QMessageBox.critical(self.settingsDialog,
                                     "NextCloud Connection Error",
                                     "The specified Server URL is invalid!")
        else:
            missingFields = ""
            fieldText = "field"

            if not self.settingsDialog.group_account.input_url.text:
                missingFields = "\"Server URL\""

            if not self.settingsDialog.group_account.input_username.text:
                if missingFields == "":
                    missingFields = "\"Username\""
                else:
                    missingFields = missingFields + " and \"Username\""
                    fieldText = "fields"

            if not self.settingsDialog.group_account.input_password.text:
                if missingFields == "":
                    missingFields = "\"Password\""
                else:
                    missingFields = missingFields.replace(
                        " and", ",") + " and \"Password\""
                    fieldText = "fields"

            QMessageBox.critical(
                self.settingsDialog, "NextCloud Connection Error", "The " +
                missingFields + " " + fieldText + " must be filled in!")
Esempio n. 43
0
 def showSettingsUI(self, parentWidget):
     QMessageBox.information(parentWidget, "NoelShack", "This plugin has no settings.")
Esempio n. 44
0
    def onRemoveButtonClicked(self, pluginname):
        if pluginname in self.host.plugins:
            if self.cfg.getboolean("general", "uninstallQuestion"):
                def cbox_state_changed(state):
                    if state == Qt.Checked:
                        self.cfg.set("general", "uninstallQuestion", "False")
                    else:
                        self.cfg.set("general", "uninstallQuestion", "True")

                cbox = QCheckBox(self._tr("Don't ask me again"))
                cbox.connect("stateChanged(int)", cbox_state_changed)

                msgbox = QMessageBox(self)
                msgbox.setInformativeText(self._tr("Do you really want to "
                                                   "delete plugin {name}?\n"
                                                   "This will erase all "
                                                   "script data of the "
                                                   "plugin from disk.").
                                          format(name=pluginname))
                msgbox.setIcon(4)  # QMessageBox::Icon::Question = 4
                msgbox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
                msgbox.setDefaultButton(QMessageBox.Cancel)
                msgbox.setCheckBox(cbox)

                if msgbox.exec_() != QMessageBox.Ok:
                    return

            if pluginname in self.host.active:
                self.host.deactivate(pluginname)

            devtools.PluginInstaller.removePlugin(pluginname)
            self.host.reload()
            self.host.start()
            self.setupList()
Esempio n. 45
0
 def displayMessage(self, title, msg):
     QMessageBox.information(None, title, msg)
Esempio n. 46
0
 def handleDisplayError(self, message):
     QMessageBox.information(None, "Error", message)
     pass