예제 #1
0
 def __init__(self, **kwargs):
     self.config = Config()
     intents = discord.Intents.none()
     intents.guilds = True
     intents.messages = True
     intents.reactions = True
     intents.message_content = True
     super().__init__(
         help_command=helpcommand.EmbedHelpCommand(),
         case_insensitive=True,
         command_prefix=self.config.prefix,
         owner_id=int(self.config.owner_id),
         intents=intents,
         description="Bot for following twitter users on discord",
         allowed_mentions=discord.AllowedMentions(everyone=False),
         **kwargs,
     )
     self.logger = log.get_logger("Siniara")
     self.start_time = time()
     self.twitter_blue = int("1da1f2", 16)
     self.db = maria.MariaDB(self)
     self.cogs_to_load = [
         "cogs.commands",
         "cogs.errorhandler",
         "cogs.asyncstreamer",
         "cogs.twitter",
     ]
예제 #2
0
파일: run.py 프로젝트: khanhtdk/countpy
 def run(self):
     assert self.workers, 'No worker to run'
     self.logsrv.start()
     for worker in self.workers:
         worker.start()
     self._run_event.set()
     client_configurer(self._log_queue)
     self._logger = get_logger(self.__class__.__name__)
예제 #3
0
def write_record(message,card_num):
    """
    账户记录
    :param message:
    :return:
    """
    struct_time = time.localtime()
    logger_obj = modules_logger.get_logger(card_num, struct_time)
    logger_obj.info(message)
예제 #4
0
파일: client.py 프로젝트: khanhtdk/countpy
 def __init__(self, endpoint=None, auth=None, headers=None, timeout=None):
     self._endpoint = endpoint
     self.method, self.url = get_endpoint(endpoint)
     if headers:
         self.default_headers.update(headers)
     self.timeout = timeout or DEFAULT_REQUEST_TIMEOUT
     self.auth = auth
     self.limit = GithubLimit(endpoint)
     self.logger = get_logger(__package__)
     self.__create()
예제 #5
0
def main():
    """Run application."""
    logger = get_logger('app', init=True)
    args = parse_args(sys.argv[1:])

    logger.debug('Message: %s', args.message)

    if args.message.lower() != 'hello':
        logger.error('Please say "hello".')
        exit(1)

    logger.info('Hello.')
    exit(0)
예제 #6
0
파일: worker.py 프로젝트: khanhtdk/countpy
    def run(self):
        # Configure logging
        if self._log_queue is not None:
            client_configurer(self._log_queue)
        self._logger = get_logger(self.name)

        # Run worker
        self._event.wait()
        self._logger.info('Search worker (%s) is started' % self.name)

        try:
            self.search_repos()
            self.retrieve_files()
        except AssertionError:
            pass
        except Exception as exc:
            self._logger.exception(exc)
            if self._exc_queue is not None:
                self._exc_queue.put((self.name, exc))

        self._logger.info('Search worker (%s) is stopped.' % self.name)
예제 #7
0
import math
import time

import discord
import psutil
from discord.ext import commands

from modules import logger as log
from modules import menus, queries
from modules.siniara import Siniara

logger = log.get_logger(__name__)


class Commands(commands.Cog):
    def __init__(self, bot):
        self.bot: Siniara = bot

    @commands.command()
    async def info(self, ctx: commands.Context):
        """Get information about the bot."""
        userlist = await queries.get_all_users(self.bot.db)
        followcount = len(set(userlist))
        content = discord.Embed(title="Siniara v6",
                                colour=self.bot.twitter_blue)
        content.description = (
            f"Bot for fetching new media content from twitter, "
            f"created by **Joinemm#7184** <@{self.bot.owner_id}>\n\n"
            f"use `{self.bot.command_prefix}help` for the list of commands.\n\n"
            f"Currently following **{followcount}** twitter accounts "
            f"across **{len(self.bot.guilds)}** guilds.")
예제 #8
0
import torch.nn as nn
from torchsummary import summary
import torch.optim as optim
from tqdm import tqdm
import datetime

import optuna
optuna.logging.disable_default_handler()

from config.config import cnf
from data.pet_dataloader import create_dataloader
from model.optuna_model import Net
from modules.mlflow_writer import MlflowWriter
from modules.early_stoping import EarlyStopping
from modules.logger import get_logger
logger = get_logger(__file__)


def train():
    logger.info("start train")
    os.environ["MLFLOW_TRACKING_URI"] = cnf.MLFLOW_TRACKING_URI
    study = optuna.create_study()
    study.optimize(_objective, n_trials=cnf.train.trial_size)
    logger.info(study.best_params)

    writer = MlflowWriter(cnf.experiment_name)
    writer.log_params_from_omegaconf_dict(study.best_params)

    for key, value in study.best_params:
        writer.log_param(key, value)
    writer.log_param("best_study_value", study.best_value)
예제 #9
0
import json
import logging
import os
import time
from typing import Tuple, List

from modules.logger import get_logger

SCRIPT_LOCATION = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
LOGGER = get_logger(logging.INFO, __name__)
CONFIG_CHECKED = False


def check_config(conf):
    """
    Checks the config file for errors and logs them if found.

    :param conf: The config dictionary.
    :return: Nothing.
    """

    # Test if all keys are in the file.
    keys_needed = {
        "start_scene": [str, None],
        "unknown_app_scene": [str, None],
        "delay_time": [int],
        "window_class": [dict],
        "window_name": [dict],
        "desktop_name": [dict],
    }
예제 #10
0
    pass


class GithubServerError(GithubException):
    delay = LONG_BREAK_DELAY


class LegalReasonError(GithubException):
    pass


class MaxRetriesExceeded(Exception):
    pass


_logger = get_logger(__package__)
_need_reask = (RateLimitError, )
_need_reset = (Timeout, ConnectionError, AbuseLimitError)
_default_delay = (Timeout, ConnectionError)


def handle_exception(exception, delay_multiple=1, client=None):
    def delay(s):
        _logger.info('Resume in %s second%s...' % (s, 's' if s > 1 else ''))
        time.sleep(s * delay_multiple)

    _logger.error(exception)

    seconds = None
    if hasattr(exception, 'delay'):
        seconds = exception.delay