def init(cls): pytson._setup() cls.shell = None cls.confdlg = None cls.proxies = WeakValueDictionary() cls.nwm = None cls.modules = {} cls.menus = {} cls.hotkeys = {} cls.translator = None cls.cfg = ConfigParser() cls.cfg.read(pytson.getConfigPath("pyTSon.conf")) cls.setupConfig() cls.setupTranslator() cls.verboseLog(cls._tr("Starting up"), "pyTSon.PluginHost.init") cls.reload() cls.start() cls.verboseLog(cls._tr("Init success"), "pyTSon.PluginHost.init")
def stop(self): if self.dlg: self.dlg.close() self.dlg = None with open(pytson.getConfigPath("musicbot.ini"), "w") as f: self.cp.write(f)
def init(cls): pytson._setup() cls.shell = None cls.confdlg = None cls.proxies = WeakValueDictionary() cls.nwm = None cls.modules = {} cls.menus = {} cls.hotkeys = {} cls.translator = None cls.cfg = ConfigParser() cls.cfg.read(pytson.getConfigPath("pyTSon.conf")) cls.setupConfig() cls.setupTranslator() cls.verboseLog(cls._tr("Starting up"), "pyTSon.PluginHost.init") cls.registerCallbackProxy(_PluginCommandHandler) cls.reload() cls.start() cls.verboseLog(cls._tr("Init success"), "pyTSon.PluginHost.init")
def __init__(self): global CONFIG self.dlg = None self.playing = False try: self.cfg_schema = { 'token': ('', 'Youtube API Key'), 'nick': ('musicbot', 'Bot Nickname' ), } self.cp = ConfigParser({k: v[0] for k, v in self.cfg_schema.items()}) p = pytson.getConfigPath("musicbot.ini") if os.path.isfile(p): self.cp.read(p) CONFIG = self.cp['DEFAULT'] except: debug(traceback.format_exc()) self.vlc = player.VLC(CONFIG.get('token')) id, err = me() if not err: err, self.nick = ts3lib.getClientDisplayName(schid(), id) self.nickname() debug("[musicbot] enabled")
def stop(self): if self.dlg: self.dlg.close() self.dlg = None with open(pytson.getConfigPath("autoreply.ini"), "w") as f: self.cfg.write(f)
def __init__(self): self.log = None self.cfg = ConfigParser() #set default values self.cfg.add_section("general") self.cfg.set("general", "maximumEvents", "100") self.cfg.set("general", "height", "200") self.cfg.set("general", "width", "350") cfgpath = pytson.getConfigPath("eventlog.conf") if os.path.isfile(cfgpath): self.cfg.read(cfgpath)
def __init__(self): try: self.dlg = None self.handled = [] self.cfg = ConfigParser(CONF_DEFAULTS) self.cfg.add_section("general") p = pytson.getConfigPath("autoreply.ini") if os.path.isfile(p): self.cfg.read(p) except: ct(traceback.format_exc())
def shutdown(cls): cls.verboseLog(cls._tr("Shutting down"), "pyTSon.PluginHost.shutdown") if cls.shell: cls.shell.delete() cls.shell = None if cls.confdlg: cls.confdlg.delete() cls.confdlg = None if cls.nwm: cls.nwm.delete() cls.nwm = None # store config with open(pytson.getConfigPath("pyTSon.conf"), "w") as f: cls.cfg.write(f) # stop all plugins for key, p in cls.active.items(): try: p.stop() except: print( cls._tr( "Error stopping python plugin {name}: {trace}").format( name=key, trace=traceback.format_exc())) cls.active = {} # save local menu ids for globid, (p, locid) in cls.menus.items(): # previously reloaded? if not type(p) is str: cls.menus[globid] = (p.name, locid) # save local hotkeys for keyword, (p, lockey) in cls.hotkeys.items(): if not type(p) is str: cls.hotkeys[keyword] = (p.name, lockey) if cls.translator: if not QCoreApplication.removeTranslator(cls.translator): logprint(cls._tr("Error removing translator"), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.PluginHost.shutdown")
def shutdown(cls): cls.verboseLog(cls._tr("Shutting down"), "pyTSon.PluginHost.shutdown") if cls.shell: cls.shell.delete() cls.shell = None if cls.confdlg: cls.confdlg.delete() cls.confdlg = None if cls.nwm: cls.nwm.delete() cls.nwm = None # store config with open(pytson.getConfigPath("pyTSon.conf"), "w") as f: cls.cfg.write(f) # stop all plugins for key, p in cls.active.items(): try: p.stop() except: print(cls._tr("Error stopping python plugin {name}: {trace}"). format(name=key, trace=traceback.format_exc())) cls.active = {} # save local menu ids for globid, (p, locid) in cls.menus.items(): # previously reloaded? if not type(p) is str: cls.menus[globid] = (p.name, locid) # save local hotkeys for keyword, (p, lockey) in cls.hotkeys.items(): if not type(p) is str: cls.hotkeys[keyword] = (p.name, lockey) if cls.translator: if not QCoreApplication.removeTranslator(cls.translator): logprint(cls._tr("Error removing translator"), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.PluginHost.shutdown")
def __init__(self, host, parent=None): super(QDialog, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.host = host self.pending = 0 try: with open(pytson.getConfigPath("repositorymaster.json"), "r") as f: repmaster = json.loads(f.read()) self.replist = {x["name"]: x for x in repmaster} except: ts3print(self._tr("Error opening repositorymaster"), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon.RepositoryDialog", 0) raise Exception("Error opening repositorymaster") try: setupUi(self, pytson.getPluginPath("ressources", "repository.ui")) self.updateMasterlist() movie = QMovie(pytson.getPluginPath("ressources", "loading.gif"), "", self) movie.start() self.loadingLabel.setMovie(movie) self.masterloadingLabel.setMovie(movie) self.masterloadingLabel.hide() self.nwm = QNetworkAccessManager(self) self.nwm.connect("finished(QNetworkReply*)", self.onNetworkReply) self.updateRepositories() self.connect("finished(int)", self.onClosed) except Exception as e: self.delete() raise e
#if "aaa_ts3Ext" in PluginHost.active: ts3host = PluginHost.active["aaa_ts3Ext"].ts3host #else: ts3host = ts3Ext.ts3SessionHost(next(iter(PluginHost.active.values()))) print('(pyTSon v{} on {} | Console started at: {:%Y-%m-%d %H:%M:%S})'.format( pytson.getVersion(), pytson.platformstr(), datetime.now())) print("Client curAPI: {} | LibVer: {} | LibVerNum: {}".format( pytson.getCurrentApiVersion(), ts3lib.getClientLibVersion(), ts3lib.getClientLibVersionNumber())) print("Python {} {} API: {}".format(sys.platform, sys.version, sys.api_version)) print("sys.executable: %s" % sys.executable) print("ts3lib.getAppPath(): %s" % ts3lib.getAppPath()) print("ts3lib.getConfigPath(): %s" % ts3lib.getConfigPath()) print("ts3lib.getResourcesPath(): %s" % ts3lib.getResourcesPath()) print("ts3lib.getPluginPath(): %s" % ts3lib.getPluginPath()) print("pytson.getConfigPath(): %s" % pytson.getConfigPath()) print("pytson.getPluginPath(): %s" % pytson.getPluginPath()) print("bluscream.getScriptPath(): %s" % getScriptPath("console")) i = 0 for item in sys.path: print('sys.path[{}]"{}"'.format(i, item)) i += 1 print("") print(sys.flags) print("") class testClass(object): def __init__(): pass
def stop(self): with open(pytson.getConfigPath("eventlog.conf"), "w") as f: self.cfg.write(f)
def onClosed(self): with open(pytson.getConfigPath("repositorymaster.json"), "w") as f: json.dump(list(self.replist.values()), f)