Beispiel #1
0
def invite(id, user):
    options = {1: "外研社", 2: "互帮互助群"}
    name = options[id]
    group = bot.groups().search(name)
    if (len(group)):
        print(len(user))
        try:
            group[0].add_members(user, use_invitation=True)
            logger = get_wechat_logger()
            logger.error(name)
        except Exception as e:
            logger = get_wechat_logger()
            logger.warning(str(e))
    else:
        user.send("哇!小小虾米没找到你想进的群")
Beispiel #2
0
def t_log():

    # 获得 Logger
    logger = get_wechat_logger()

    # 发送警告
    logger.warning('这是一条 WARNING 等级的日志!')

    # 捕获可能发生的异常,并发送
    try:
        1 / 0
    except:
        logger.exception('又出错啦!')
Beispiel #3
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)
    app.error_logger = get_wechat_logger()

    bootstrap.init_app(app)
    mail.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    celery.conf.update(app.config)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    return app
from wxpy import get_wechat_logger
logger.warning('this is a warnning')
logger = get_wechat_logger()
try:
    4/0
excepIntelliSenset:
    logger.exception('something is wrong')



print('hihi')



print('hello')



#%%
import pandas as  pd

pd.DataFrame()




# %%
Beispiel #5
0
import wxpy
bot = wxpy.Bot(console_qr=True)
logger = wxpy.get_wechat_logger(receiver=bot, name='word2vec')
logger.warning('这是一条 WARNING 等级的日志,你收到了吗?')
Beispiel #6
0
# -*-coding:utf-8 -*-
from wxpy import *
from wxpy import get_wechat_logger

from wxpy import *

bot = Bot()

group_receiver = ensure_one(bot.groups().search('XX业务-告警通知'))

logger = get_wechat_logger(group_receiver)

logger.error('打扰大家了,但这是一条重要的错误日志...')
Beispiel #7
0
# coding=utf-8
"""Status monitor on wechat, to report progress / status of project on wechat"""

from datetime import datetime
from logging import INFO
from wxpy import get_wechat_logger

wechat_logger = get_wechat_logger(name='status_monitor', level=INFO)
time_format = '%Y-%m-%d %H:%M:%S'


def status_monitor_on_wechat(func_):
    """Decorator to send wechat messages to file helper when the decorated function is called and finished"""
    def inner_func(*args, **kwargs):
        """Decorated function with general input"""
        _name = str(func_).split(' ')[1]
        _begin = datetime.now()
        wechat_logger.info('Start running function <{}> at {}'.format(
            _name, datetime.strftime(_begin, time_format)))

        try:
            _res = func_(*args, **kwargs)
            _end = datetime.now()
            _last = _end - _begin
            wechat_logger.info(
                'Finish running function <{}> at {}, lasting {} seconds\nResult: {}'
                .format(_name, datetime.strftime(_end, time_format),
                        _last.total_seconds(), str(_res)))
            return _res

        except Exception as e:
Beispiel #8
0
            r = requests.get(url=url, headers=headers, timeout=20)
            return r
        except Exception as e:
            pass

    def parse_data(self, r, param):
        jobs_list = []
        try:
            dom = html.fromstring(r.content)
            for job in dom.xpath('//div/ul[@class="sojob-list"]/li'):
                try:
                    job_name = job.xpath('.//div[@class="job-info"]//a/text()')[0].strip()
                    job_name_url = job.xpath('.//div[@class="job-info"]//a/@href')[0]
                    job_condition = job.xpath('.//div[@class="job-info"]//p[@class="condition clearfix"]/@title')[0]
                    company_name = job.xpath('.//p[@class="company-name"]/a/@title')[0]
                    company_name_url = job.xpath('.//p[@class="company-name"]/a/@href')[0]
                    company_info = job.xpath('.//a[@class="industry-link"]/text()')[0]
                    others = job.xpath('.//p[@class="temptation clearfix"]/span/text()')
                    jobs_list.append([job_name, job_condition, company_name, company_info, others, job_name_url, company_name_url])

                except Exception as e:
                    print('liepin parse job exception')
        except Exception as e:
            print('liepin parse jobs exception')
        print(str(jobs_list))

if __name__ == '__main__':
    logger_msg = get_wechat_logger()
    liepin = Liepin()
    logger_msg.warn(liepin.start_request(param={}))