Ejemplo n.º 1
0
 def __init__(self):
     try:
         import unidecode
     except ImportError:
         PluginInstaller().installPackages(['unidecode'])
     try:
         from discoIPC import ipc
     except ImportError:
         PluginInstaller().installPackages(['discoIPC'])
         from discoIPC import ipc
     self.discord = ipc.DiscordIPC(
         "504997049226362891")  # 450824928841957386
     try:
         self.discord.connect()
     except:
         ts3lib.logMessage("Discord not running!",
                           ts3defines.LogLevel.LogLevel_WARNING,
                           "pyTSon Discord Rich Presence", 0)
     self.timer.timeout.connect(self.tick)
     self.timer.setTimerType(2)
     schid = ts3lib.getCurrentServerConnectionHandlerID()
     self.onTabChangedEvent(schid)
     self.timer.start(1000)
     """
     (err, status) = ts3lib.getConnectionStatus(schid)
     if status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         self.updateServer(schid); self.updateChannel(schid); self.updateVoice(schid);self.updateClient(schid)
     """
     if PluginHost.cfg.getboolean("general", "verbose"):
         ts3lib.printMessageToCurrentTab(
             "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded."
             .format(timestamp(), self.name, self.author))
Ejemplo n.º 2
0
 def deleteChan(self):
     try: import ts3
     except ImportError:
         from devtools import PluginInstaller
         PluginInstaller().installPackages(['ts3'])
         import ts3
     host=self.cfg.get("serverquery","host")
     qport=self.cfg.getint("serverquery","qport")
     client_login_name=self.cfg.get("serverquery","name")
     client_login_password=self.cfg.get("serverquery","pw")
     port=self.cfg.getint("serverquery","port")
     client_nickname=self.cfg.get("serverquery","nick")
     if hasattr(ts3.query, "TS3ServerConnection"):
         with ts3.query.TS3ServerConnection(host, qport) as ts3conn:
             ts3conn.query("login", client_login_name=client_login_name, client_login_password=client_login_password).fetch()
             ts3conn.query("use", port=port).fetch()
             ts3conn.query("clientupdate", client_nickname=client_nickname).fetch()
             ts3conn.query("channeldelete", cid=self.supchan, force=1).fetch()
     else:
         with ts3.query.TS3Connection(host, qport) as ts3conn:
             ts3conn.login(client_login_name=client_login_name, client_login_password=client_login_password)
             ts3conn.use(port=port)
             ts3conn.clientupdate(client_nickname=client_nickname)
             ts3conn.channeldelete(cid=self.supchan, force=True)
     self.supchan = 0
Ejemplo n.º 3
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())
Ejemplo n.º 4
0
 def __init__(self):
     self.installer = PluginInstaller(self.print_msg)
     # if self.auto_update_pip: self.to_install.append("--upgrade pip")
     _installed = installedPackages()
     installed = []
     for package in _installed:
         name = package["name"]
         if not name in installed: installed.append(name)
     """
     dir = listdir(getPluginPath("scripts"))
     print(dir)
     """
     # noinspection PyTypeChecker
     for subdir, dirs, files in walklevel(getPluginPath("scripts"), 1):
         for file in files:
             file_lower = file.lower()
             if not file_lower.endswith(".txt"): continue
             if file_lower == "requirements.txt":
                 requirements = []
                 # noinspection PyArgumentList
                 with open(path.join(subdir, file), encoding="utf-8") as f:
                     requirements = [line.strip() for line in f.readlines()]
                 if len(requirements) < 1: continue
                 for requirement in requirements:
                     requirement_stripped = self.strip(requirement)
                     if requirement in self.to_install: continue
                     if requirement_stripped in installed: continue
                     try:
                         __import__(requirement_stripped)
                     except ImportError:
                         self.to_install.append(requirement)
                 break
     if len(self.to_install) > 0:
         ts3lib.printMessageToCurrentTab(
             "[color=red]Found missing dependencies %s in \"requirements.txt\" files from scrips, installing..."
             % self.to_install)
         QTimer.singleShot(0, self.install)
     if PluginHost.cfg.getboolean("general", "verbose"):
         ts3lib.printMessageToCurrentTab(
             "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded."
             .format(timestamp(), self.name, self.author))
Ejemplo n.º 5
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())
Ejemplo n.º 6
0
from __future__ import division
try:
    from pyparsing import (Literal, CaselessLiteral, Word, Combine, Group,
                           Optional, ZeroOrMore, Forward, nums, alphas, oneOf)
except ImportError:
    from devtools import PluginInstaller
    PluginInstaller().installPackages(['pyparsing'])
    from pyparsing import (Literal, CaselessLiteral, Word, Combine, Group,
                           Optional, ZeroOrMore, Forward, nums, alphas, oneOf)
import math
import operator

__author__ = 'Paul McGuire'
__version__ = '$Revision: 0.0 $'
__date__ = '$Date: 2009-03-20 $'
__source__ = '''http://pyparsing.wikispaces.com/file/view/fourFn.py
http://pyparsing.wikispaces.com/message/view/home/15549426
'''
__note__ = '''
All I've done is rewrap Paul McGuire's fourFn.py as a class, so I can use it
more easily in other places.
'''


class NumericStringParser(object):
    '''
    Most of this code comes from the fourFn.py pyparsing example

    '''
    def pushFirst(self, strg, loc, toks):
        self.exprStack.append(toks[0])
Ejemplo n.º 7
0
from PythonQt.QtGui import QInputDialog, QMessageBox, QWidget, QLineEdit  #, QObject
from PythonQt.QtCore import Qt, QFile, QByteArray, QIODevice, QDataStream, QUrl  # , QApplication # QDir
from PythonQt.QtSql import QSqlQuery
from PythonQt.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
from ts3plugin import PluginHost
# from configparser import ConfigParser
from urllib.parse import quote_plus
from gc import get_objects
from base64 import b64encode
from pytson import getPluginPath
from re import match, sub, compile, escape, search, IGNORECASE, MULTILINE
try:
    from psutil import Process
except ImportError:
    from devtools import PluginInstaller
    PluginInstaller().installPackages(['psutil'])
    from psutil import Process
import ts3lib, ts3defines, os.path, string, random, ts3client, time, sys, codecs
from ts3enums import *


#endregion
#region GENERAL FUNCTIONS
def timestamp():
    return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())


def date():
    return '{:%Y-%m-%d}'.format(datetime.now())

Ejemplo n.º 8
0
from ts3plugin import ts3plugin
import ts3lib, ts3defines, json, subprocess
try:
    from websocket import create_connection
except ImportError:
    ts3lib.printMessageToCurrentTab("Installing websocket-client")
    from devtools import PluginInstaller
    try:
        PluginInstaller.installPackages(PluginInstaller, ['websocket-client'])
    except TypeError as e:
        pass
    from websocket import create_connection
from os import path
from os import name as osName


class tshelp:
    @staticmethod
    def getChannelName(serverConnectionHandlerID, channelID):
        return ts3lib.getChannelVariableAsString(
            serverConnectionHandlerID, channelID,
            ts3defines.ChannelProperties.CHANNEL_NAME)[1]

    @staticmethod
    def getChannelID(serverConnectionHandlerID):
        return ts3lib.getChannelOfClient(
            serverConnectionHandlerID,
            ts3lib.getClientID(serverConnectionHandlerID)[1])[1]

    @staticmethod
    def getNearbyClients(serverConnectionHandlerID):
Ejemplo n.º 9
0
class aaa_requirements(ts3plugin):
    name = "aaa_requirements"
    try: apiVersion = getCurrentApiVersion()
    except: apiVersion = 22
    requestAutoload = False
    version = "1.0"
    author = "Bluscream"
    description = "Auto-installs requirements.txt from script directories"
    offersConfigure = False
    commandKeyword = ""
    infoTitle = None
    menuItems = []
    hotkeys = []
    to_install = []
    installer = None
    auto_update_pip = True

    def __init__(self):
        self.installer = PluginInstaller(self.print_msg)
        # if self.auto_update_pip: self.to_install.append("--upgrade pip")
        _installed = installedPackages()
        installed = []
        for package in _installed:
            name = package["name"]
            if not name in installed: installed.append(name)
        """
        dir = listdir(getPluginPath("scripts"))
        print(dir)
        """
        # noinspection PyTypeChecker
        for subdir, dirs, files in walklevel(getPluginPath("scripts"), 1):
            for file in files:
                file_lower = file.lower()
                if not file_lower.endswith(".txt"): continue
                if file_lower == "requirements.txt":
                    requirements = []
                    # noinspection PyArgumentList
                    with open(path.join(subdir, file), encoding="utf-8") as f:
                        requirements = [line.strip() for line in f.readlines()]
                    if len(requirements) < 1: continue
                    for requirement in requirements:
                        requirement_stripped = self.strip(requirement)
                        if requirement in self.to_install: continue
                        if requirement_stripped in installed: continue
                        try: __import__(requirement_stripped)
                        except ImportError:
                            self.to_install.append(requirement)
                    break
        if len(self.to_install) > 0:
            ts3lib.printMessageToCurrentTab("[color=red]Found missing dependencies %s in \"requirements.txt\" files from scrips, installing..."%self.to_install)
            QTimer.singleShot(0, self.install)
        if PluginHost.cfg.getboolean("general", "verbose"):
            ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(), self.name, self.author))

    def strip(self, requirement):
        if requirement.startswith("-e "): requirement = requirement.replace("-e ", "", 1)
        if requirement.endswith(".git"): requirement = requirement.replace(".git", "", 1)
        for prefix in ["hg", "svn", "bzr", "git"]:
            if requirement.startswith("%s+"%prefix):
                requirement = requirement.rsplit('/',1)[1]
        return requirement

    def install(self, to_install=to_install):
        result = self.installer.installPackages(to_install)
        if not result: ts3lib.printMessageToCurrentTab("[color=red]Failed to install %s!" % to_install)
        self.to_install = []

    def stop(self):
        if hasattr(self, "installer"): del self.installer

    def print_msg(self, msg):
        ts3lib.printMessageToCurrentTab(str(msg.decode('ascii')))