def __init__(self): self.port = config.global_option('port').value self.privmsg = config.global_option('privmsg').value self._path = config.global_option('sectionspath').value try: self._data = pickle.load(open(self._path)) except IOError: self._data = {} logger = log.getPluginLogger('irccat.config') logger.warning("Can't find stored config, creating empty.") self._dump() except Exception: # Unpickle throws just anything. self._data = {} logger = log.getPluginLogger('irccat.config') logger.warning("Bad stored config, creating empty.") self._dump()
def __init__(self): self.port = config.global_option('port').value self.privmsg = config.global_option('privmsg').value self._path = config.global_option('sectionspath').value try: self._data = pickle.load(open(self._path, 'rb')) except IOError: self._data = {} logger = log.getPluginLogger('irccat.config') logger.warning("Can't find stored config, creating empty.") self._dump() except Exception: # Unpickle throws just anything. self._data = {} logger = log.getPluginLogger('irccat.config') logger.warning("Bad stored config, creating empty.") self._dump()
def _poll_all_repos(repolist, throw = False): '''Find and store new commits in repo.new_commits_by_branch. ''' def poll_repository(repository, targets): ''' Perform poll of a repo, determine changes. ''' with repository.lock: new_commits_by_branch = repository.get_new_commits() for irc, channel in targets: ctx = _DisplayCtx(irc, channel, repository) ctx.display_commits(new_commits_by_branch) for branch in new_commits_by_branch: repository.commit_by_branch[branch] = \ repository.get_commit(branch) start = time.time() _log = log.getPluginLogger('git.pollAllRepos') for repository in repolist: # Find the IRC/channel pairs to notify targets = [] for irc in world.ircs: for channel in repository.options.channels: if channel in irc.state.channels: targets.append((irc, channel)) if not targets: _log.info("Skipping %s: not in configured channel(s)." % repository.name) continue try: poll_repository(repository, targets) except Exception as e: # pylint: disable=W0703 _log.error('Exception in _poll():' + str(e), exc_info=True) if throw: raise(e) _log.debug("Exiting poll_all_repos, elapsed: " + str(time.time() - start))
def io_process(port, pipe): ''' Run the twisted-governed data flow from port -> irc. ''' # pylint: disable=E1101 logger = log.getPluginLogger('irccat.io') logger.debug("Starting IO process on %d" % port) reactor.listenTCP(port, IrccatFactory(pipe)) try: reactor.run() except Exception as ex: # pylint: disable=W0703 logger.error("Exception in io_process: " + str(ex), exc_info = True) logger.info(" io_process: exiting")
def __init__(self, reponame): """ Initialize a repository with the given name. Setup data is read from supybot registry. """ self.log = log.getPluginLogger('git.repository') self.options = self.Options(reponame) self.name = reponame self.commit_by_branch = {} self.lock = threading.Lock() self.repo = None self.path = os.path.join(self.options.repo_dir, self.name) if world.testing: self._clone() self.init()
def __init__(self, irc): callbacks.Plugin.__init__(self, irc) self.log = log.getPluginLogger('irccat.irccat') self.config = _Config() self.pipe = multiprocessing.Pipe() self.pipe[1].send(self.config) self.process = multiprocessing.Process( target = io_process, args = (self.config.port, self.pipe)) self.process.start() self.listen_abort = False self.thread = threading.Thread(target = self.listener_thread) self.thread.start()
def __init__(self, irc): callbacks.Plugin.__init__(self, irc) self.irc = irc self.log = log.getPluginLogger('irccat.irccat') self.config = _Config() self.pipe = multiprocessing.Pipe() self.pipe[1].send(self.config) self.process = multiprocessing.Process( target = io_process, args = (self.config.port, self.pipe)) self.process.start() self.listen_abort = False self.thread = threading.Thread(target = self.listener_thread) self.thread.start()
def _get_branches(option_val, repo): ''' Return list of branches in repo matching users's option_val. ''' log_ = log.getPluginLogger('git.get_branches') opt_branches = [b.strip() for b in option_val.split()] repo.remote().update() repo_branches = \ [r.name.split('/')[1] for r in repo.remote().refs if r.is_detached] branches = [] for opt in opt_branches: matched = fnmatch.filter(repo_branches, opt) if not matched: log_.warning("No branch in repository matches " + opt) else: branches.extend(matched) if not branches: log_.error("No branch in repository matches: " + option_val) return branches
def __init__(self, watchname): """ Initialize a watch with the given name. Setup data is read from supybot registry. """ self.log = log.getPluginLogger('bz.watch') self.name = watchname self.lock = threading.Lock() self.bugs = None self.bugzilla = None url = config.watch_option(watchname, 'url').value if not url.startswith('file://'): try: self.bugzilla = bugzilla.Bugzilla(url=url) except IOError: self.log.error("Cannot create Bugzilla for " + str(url)) self._load(url)
def __init__(self, irc): self.__parent = super(Cynthia, self) self.__parent.__init__(irc) self.log = log.getPluginLogger('Cynthia') dir_path = os.path.dirname(os.path.realpath(__file__)) with open(dir_path + '/config.json', 'r') as f: config = json.load(f) scoring_handler = ScoringHandler(config) logging.getLogger('mwapi').setLevel(logging.ERROR) self.re_edit = re.compile( r'^\x0314\[\[\x0307([^\]]+)\x0314\]\]\x034 ([!NBM]*)\x0310 \x0302https?:\/\/([a-z0-9-.]+)\.(fandom\.com|wikia\.(?:com|org)|(?:wikia|fandom)-dev\.(?:com|us|pl))\/(?:([a-z-]+)\/)?index\.php\?(\S+)\x03 \x035\*\x03 \x0303([^\x03]+)\x03 \x035\*\x03 \(\x02?(\+|-)(\d+)\x02?\) \x0310(.*)$' ) # page, flags, wiki, domain, language, params, user, sign, num, summary requests.post(config['discord'][0]['webhook'], data={'content': 'Reloaded Cynthia'}) self.executor = cfutures.ProcessPoolExecutor(max_workers=4)
def __init__(self, repos, fetch_done_cb): self.log = log.getPluginLogger('git.fetcher') threading.Thread.__init__(self) self._shutdown = False self._repos = repos self._callback = fetch_done_cb
def __init__(self, plugin): self.log = log.getPluginLogger('Gitlab') self.gitlab = GitlabHandler(plugin) self.plugin = plugin
def __init__(self, plugin, irc): self.log = log.getPluginLogger('Gogs') self.gogs = GogsHandler(plugin, irc) self.plugin = plugin self.irc = irc
def __init__(self, config_, blacklist, msg_conn): self.config = config_ self.blacklist = blacklist self.msg_conn = msg_conn self.peer = None self.log = log.getPluginLogger('irccat.protocol')
def __init__(self): self.filename = conf.supybot.directories.data.dirize("Weather.db") self.log = log.getPluginLogger('Weather') self._conn = sqlite3.connect(self.filename, check_same_thread=False) self._conn.text_factory = str self.makeDb()
def __init__(self): self._state = {} self.log = log.getPluginLogger('irccat.blacklist')
def __init__(self, plugin, irc): self.log = log.getPluginLogger('Taiga') self.taiga = TaigaHandler(plugin, irc) self.plugin = plugin self.irc = irc
def __init__(self): self.log = log.getPluginLogger('WebHooks')
def __init__(self, plugin, irc): self.irc = irc self.plugin = plugin self.log = log.getPluginLogger('Gitlab')
def __init__(self, repos, fetch_done_cb): self._fetch_done_cb = fetch_done_cb self._repos = repos self.log = log.getPluginLogger('git.conf') self.fetcher = None self.reset()
def __init__(self, irc): callbacks.Privmsg.__init__(self, irc) self.log = log.getPluginLogger('regexrelay')
import supybot.log as log from include import plugin_name logger = log.getPluginLogger(plugin_name) def debug(*args): logger.debug(*args, exc_info=True) def info(*args): logger.info(*args, exc_info=False) def warn(*args): logger.warning(*args, exc_info=False) def error(*args): logger.error(*args, exc_info=True) def critical(*args): logger.critical(*args, exc_info=True) def exception(*args): logger.exception(*args, exc_info=True)
def __init__(self, plugin, irc): self.log = log.getPluginLogger('Gitlab') self.gitlab = GitlabHandler(plugin, irc) self.plugin = plugin self.irc = irc
def __init__(self, watches, fetch_done_cb): self.watches = watches self.log = log.getPluginLogger('bz.fetcher') threading.Thread.__init__(self) self._shutdown = False self._callback = fetch_done_cb
def __init__(self, plugin): self.log = log.getPluginLogger('WebHooks') self.username = plugin.registryValue('username') self.password = plugin.registryValue('password')
def __init__(self, watches, fetch_done_cb): self.watches = watches self._fetch_done_cb = fetch_done_cb self.log = log.getPluginLogger('bz.scheduler') self.fetcher = None self.reset()
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. ### import supybot.utils as utils from supybot.commands import * import supybot.plugins as plugins import supybot.ircutils as ircutils import supybot.callbacks as callbacks from supybot import ircmsgs from supybot import log log = log.getPluginLogger("Ticker") from decimal import Decimal import time, threading, json, urllib2 CURRENCYCOLORMAP = dict(BTC="green", LTC="orange", NMC="orange", NVC="orange", PPC="orange") def currencycolor(cur): if cur in CURRENCYCOLORMAP: return ircutils.mircColor(cur, CURRENCYCOLORMAP[cur]) else: return cur
def __init__(self, plugin): self.log = log.getPluginLogger('Gogs') self.gogs = GogsHandler(plugin) self.plugin = plugin
def __init__(self, plugin): # HACK: instead of refactoring everything, I can just replace this with each handle_payload() call. self.irc = None self.plugin = plugin self.log = log.getPluginLogger('Gogs')
def __init__(self, plugin): self.log = log.getPluginLogger('Wekan') self.wekan = WekanHandler(plugin) self.plugin = plugin