How to use removeloghandler method in pyatom

Best Python code snippet using pyatom_python

LogBot.py

Source:LogBot.py Github

copy

Full Screen

...75 else:76 self.setlevel(user, level)77 78 elif command == 'stop':79 self.removeloghandler(user)80 elif command.startswith('level'):81 try:82 level = int(command[6:])83 except ValueError:84 pass85 else:86 self.setlevel(user, level)87 88 def removeloghandler(self, user):89 '''Remove logging handlers for ops that have left the hub'''90 if user.nick in self.handlers and user.loggedin:91 self.hub.log.removeHandler(self.handlers[user.nick])92 del self.handlers[user.nick]93 94 def setlevel(self, user, level):95 '''Change the verbosity of the log messages sent to a user'''96 if user.nick in self.handlers and user.loggedin:...

Full Screen

Full Screen

scheduler.py

Source:scheduler.py Github

copy

Full Screen

1'''2Task Coach - Your friendly task manager3Copyright (C) 2004-2013 Task Coach developers <developers@taskcoach.org>4Task Coach is free software: you can redistribute it and/or modify5it under the terms of the GNU General Public License as published by6the Free Software Foundation, either version 3 of the License, or7(at your option) any later version.8Task Coach is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.12You should have received a copy of the GNU General Public License13along with this program. If not, see <http://www.gnu.org/licenses/>.14'''15from taskcoachlib import patterns16from taskcoachlib.thirdparty import apscheduler17import dateandtime18import logging19import timedelta20import wx21import weakref22class ScheduledMethod(object):23 def __init__(self, method):24 self.__func = method.im_func25 self.__self = weakref.ref(method.im_self)26 def __eq__(self, other):27 return self.__func is other.__func and self.__self() is other.__self()28 def __hash__(self):29 return hash(self.__dict__['_ScheduledMethod__func'])30 def __call__(self, *args, **kwargs):31 obj = self.__self()32 if obj is None:33 try:34 Scheduler().unschedule(self)35 except KeyError:36 pass37 else:38 self.__func(obj, *args, **kwargs)39class Scheduler(apscheduler.scheduler.Scheduler):40 __metaclass__ = patterns.Singleton41 42 def __init__(self, *args, **kwargs):43 self.__handler = self.createLogHandler()44 super(Scheduler, self).__init__(*args, **kwargs)45 self.__jobs = {}46 self.start()47 48 def createLogHandler(self):49 # apscheduler logs, but doesn't provide a default handler itself, make it happy:50 schedulerLogger = logging.getLogger('taskcoachlib.thirdparty.apscheduler.scheduler')51 try:52 handler = logging.NullHandler()53 except AttributeError:54 # NullHandler is new in Python 2.7, log to stderr if not available55 handler = logging.StreamHandler()56 schedulerLogger.addHandler(handler)57 return handler58 def removeLogHandler(self):59 # accumulation of handlers in the unit/language/etc tests makes them *slow*60 schedulerLogger = logging.getLogger('taskcoachlib.thirdparty.apscheduler.scheduler')61 schedulerLogger.removeHandler(self.__handler)62 def shutdown(self, wait=True, shutdown_threadpool=True):63 super(Scheduler, self).shutdown(wait=wait, 64 shutdown_threadpool=shutdown_threadpool)65 self.removeLogHandler()66 def schedule(self, function, dateTime):67 proxy = ScheduledMethod(function)68 def callback():69 if proxy in self.__jobs:70 del self.__jobs[proxy]71 wx.CallAfter(proxy)72 if dateTime <= dateandtime.Now() + timedelta.TimeDelta(milliseconds=500):73 callback()74 else:75 self.__jobs[proxy] = job = self.add_date_job(callback, dateTime, misfire_grace_time=0)76 return job77 def schedule_interval(self, function, days=0, minutes=0, seconds=0):78 proxy = ScheduledMethod(function)79 def callback():80 wx.CallAfter(proxy)81 82 if proxy not in self.__jobs:83 start_date = dateandtime.Now().endOfDay() if days > 0 else None84 self.__jobs[proxy] = job = self.add_interval_job(callback, days=days, 85 minutes=minutes, seconds=seconds, start_date=start_date, misfire_grace_time=0,86 coalesce=True)87 return job88 def unschedule(self, function):89 proxy = function if isinstance(function, ScheduledMethod) else ScheduledMethod(function)90 if proxy in self.__jobs:91 try:92 self.unschedule_job(self.__jobs[proxy])93 except KeyError:94 pass95 del self.__jobs[proxy]96 def is_scheduled(self, function):...

Full Screen

Full Screen

log.py

Source:log.py Github

copy

Full Screen

1import wx2import logging3from angel_app.log import getLogger4from angel_app.log import enableHandler as enableLogHandler5from angel_app.log import removeHandler as removeLogHandler6log = getLogger(__name__)7_ = wx.GetTranslation8class WxLog(logging.Handler):9 def __init__(self, ctrl):10 logging.Handler.__init__(self)11 self.ctrl = ctrl12 def emit(self, record):13 '''here we jut take the string formatted with the declared Formatter and add a new line14 alternatively you could take the record object and extract the information you need from it15 '''16 self.ctrl.AppendText(self.format(record)+"\n")17class RawWxLog(object):18 def fileno(self):19 120 def __init__(self, ctrl = None):21 #self.fileno = 022 if ctrl is None:23 self.doit = False24 else:25 self.ctrl = ctrl26 self.doit = True27 def startLogging(self):28 self.doit = True29 def stopLogging(self):30 self.doit = True31 def setCtrl(self, ctrl):32 self.ctrl = ctrl33 def write(self, buf):34 log.debug(buf)35 if self.doit:36 self.ctrl.AppendText(buf+"\n")37class AutoLoggingButton(wx.Button):38 def __init__(self, parent, label, level):39 wx.Button.__init__(self, parent, label = label)40 self.level = level41 self.Bind(wx.EVT_BUTTON, self.OnButton)42 def OnButton(self, event):43 log.log(self.level, self.GetLabel())44class LogFrame(wx.Frame):45 def __init__(self, parent):46 wx.Frame.__init__(self, parent, title=_("log console"), size = (800, 200))47 sizer = wx.BoxSizer(wx.VERTICAL)48 closeButton = wx.Button(self, wx.ID_CLOSE, _("Close"))49 self.Bind(wx.EVT_BUTTON, self.OnClose, closeButton)50 #debug = AutoLoggingButton(self, "Close", logging.DEBUG)51 error = AutoLoggingButton(self, _("Press for ERROR logging event"), logging.ERROR)52 logCtrl = wx.TextCtrl(self, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.ALL | wx.EXPAND)53 sizer.Add(logCtrl, 1, wx.EXPAND|wx.ALL, 10)54 #sizer.Add(debug, 1, wx.ALIGN_CENTER|wx.ALL, 5)55 sizer.Add(error, 0, wx.ALIGN_CENTER|wx.ALL, 5)56 sizer.Add(closeButton, 0, wx.ALIGN_CENTER|wx.ALL, 5)57 self.SetSizer(sizer)58 self.Bind(wx.EVT_CLOSE, self.OnClose)59 # here is where the magic begins60 self.loghandler = WxLog(logCtrl)61 self.loghandler.setFormatter(logging.Formatter('%(levelname)-6s %(name)-20s - %(message)s'))62 enableLogHandler('wx', self.loghandler)63 # now for some message formating.64 log.debug("wxLogger initialized")65 def OnClose(self, event):66 removeLogHandler(self.loghandler)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyatom automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful