Beispiel #1
0
#-*-encoding:utf-8-*-
__author__ = 'jmpews'
import requests
from logger import initLogging
import re
import time
import json
loggg = initLogging('utils.log')
from bs4 import BeautifulSoup


def quote_url(url):
    quotes = {
        '>': '>',
        '&lt;': '<',
        '&amp;': '&',
        '&quot;': '\"',
        '&#39;': '\'',
        '&nbsp;': ' '
    }
    for k in quotes:
        url = url.replace(k, quotes[k])
    return url


def getinfo(nickname, area):
    # 测试发现beautifulsoup比re要快,前提是已经格式化完毕
    pre_url = 'http://lolbox.duowan.com/'
    url = pre_url + 'playerDetail.php?serverName=' + area + '&playerName=' + nickname
    id_info = {'nickname': nickname, 'area': area}
    r = requests.get(url)
Beispiel #2
0
import os
import sys
import time

import logger
from DB.db import initDB


def _initDB():
    _path = os.path.realpath(__file__)
    _dir = os.path.split(_path)[0]
    _dbname = os.path.join(_dir, "DB", "sqlite.db")
    if 1 == 1:
        initDB(_dbname)
    else:
        initDB(":memory:")


if __name__ == "__main__":
    _initDB()
    logger.initLogging([sys.stdout, file("error.log", "w")])
    import app
    _app = app.AppRoot()
    from gui import gui, main
    _gui = gui.initGui(_app)
    _gui.MainLoop()
    print "=======END======="

# vim: set et sts=4 sw=4 :
Beispiel #3
0
import os
import sys
import time

import logger
from DB.db import initDB

def _initDB():
    _path = os.path.realpath(__file__)
    _dir = os.path.split(_path)[0]
    _dbname = os.path.join(_dir, "DB", "sqlite.db")
    if 1 == 1:
        initDB(_dbname)
    else:
        initDB(":memory:")

if __name__ == "__main__":
    _initDB()
    logger.initLogging([sys.stdout, file("error.log", "w")])
    import app
    _app = app.AppRoot()
    from gui import gui, main
    _gui = gui.initGui(_app)
    _gui.MainLoop()
    print "=======END======="

# vim: set et sts=4 sw=4 :
Beispiel #4
0
__author__ = 'jmpews'
import threading
from logger import initLogging

# log file
loggg = initLogging('threadpool.log')


# 初始化工作函数和线程数
class ThreadPool(object):
    def __init__(self, func=None, thread_num=5):
        self.threads = []
        if func == None:
            self.func = None
            print('Error : func is None...')
            return
        self.func = func
        self.__init_threads(thread_num)

    def __init_threads(self, thread_num=5):
        for i in range(thread_num):
            self.threads.append(Worker(self.func))

    def start(self):
        if self.func == None:
            print('func is None...')
            return
        for one in self.threads:
            one.start()

Beispiel #5
0
import json
from io import BytesIO
from traceback import format_exc
from gevent import idle
from progress import setCallback, initialETA, saveOps, loadOps
from config import config
from logger import initLogging

def context(): pass
context.root = None
context.getFile = lambda size: BytesIO(context.sharedView[:size])
log = initLogging(config.logPath).getLogger('Moe') # pylint: disable=E1101
opsPath = config.opsPath # pylint: disable=E1101

def filterOpt(item):
  if type(item) == dict and 'opt' in item:
    res = item.copy()
    del res['opt']
    return res
  else:
    return item

def begin(root, nodes=[], setAllCallback=True):
  context.root = root
  root.nodes = []
  for n in nodes:
    root.append(n)
  if setAllCallback:
    if not setAllCallback < 0:
      setCallback(root, onProgress, True)
  else:
Beispiel #6
0
__author__ = 'jmpews'
import threading
from logger import initLogging

# log file
loggg=initLogging('threadpool.log')

# 初始化工作函数和线程数
class ThreadPool(object):
    def __init__(self,func=None,thread_num=5):
        self.threads=[]
        if func==None:
            self.func=None
            print('Error : func is None...')
            return
        self.func=func
        self.__init_threads(thread_num)

    def __init_threads(self,thread_num=5):
        for i in range(thread_num):
            self.threads.append(Worker(self.func))

    def start(self):
        if self.func==None:
            print('func is None...')
            return
        for one in self.threads:
            one.start()

# 线程实例
class Worker(threading.Thread):
Beispiel #7
0
import machine, ntptime
import binascii
import logging, logger
logger.initLogging()


def decode_mac(mac_bytes):
    return ':'.join('{:02x}'.format(b) for b in mac_bytes)


def encode_mac(mac_string):
    # return mac_string.replace(':', '').decode('hex')
    return binascii.unhexlify(mac_string.replace(b':', b''))


def timestamp(type='timestamp'):
    yy, mm, dd, dy, hh, MM, ss, ms = machine.RTC().datetime()
    if type == 'day':
        return dd
    elif type == 'hour':
        return hh
    elif type == 'date':
        return '{:04d}{:02d}{:02d}'.format(yy, mm, dd)
    else:
        return '{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}'.format(
            yy, mm, dd, hh, MM, ss)


def log_error_to_file(message, fname='ble.log'):
    try:
        f = open(timestamp(type='date') + fname, 'a')
Beispiel #8
0
#-*-encoding:utf-8-*-
__author__ = 'jmpews'
import requests
from logger import initLogging
import re
import time
import json
loggg=initLogging('utils.log')
from bs4 import BeautifulSoup

def quote_url(url):
    quotes={'&gt;':'>','&lt;':'<','&amp;':'&','&quot;':'\"','&#39;':'\'','&nbsp;':' '}
    for k in quotes:
        url=url.replace(k,quotes[k])
    return url


def getinfo(nickname,area):
    # 测试发现beautifulsoup比re要快,前提是已经格式化完毕
    pre_url='http://lolbox.duowan.com/'
    url=pre_url+'playerDetail.php?serverName='+area+'&playerName='+nickname
    id_info={'nickname':nickname,'area':area}
    r=requests.get(url)
    soup=BeautifulSoup(r.text,"html.parser")
    avatar=soup.find('div',attrs={'class':'avatar'})
    # 角色长时间不玩
    if avatar is None:
        loggg.error('DATA:'+nickname+area)
        # print('================长时间未登录======================')
        return None
    # 角色登记太低
Beispiel #9
0
import json
import time

from bs4 import BeautifulSoup
import requests

from redisq import RedisQueue
from threadpools import ThreadPool

from logger import initLogging
import utils

rq_girl=RedisQueue('dwgirl')
rq_info=RedisQueue('girlinfo')

loggg=initLogging('dwtaskpp.log')

# 重视模块化
# 重视模块重用
def func():
    # 找到第一篇帖子内容
    # 多玩帖子内需要特别判断的函数,比如是否存在ID关键字,以及是否存在图片.
    def duowanfunc():
        girlurl=rq_girl.get()
        r=requests.get(girlurl)
        soup=BeautifulSoup(r.text,"html.parser")
        # girlpage=soup.find('td',id=re.compile('postmessage.*'),attrs={'class':'t_f'})
        girlpage=soup.find('div',attrs={'class':'t_fsz'})
        if not girlpage:
            return
        IDkeys=['ID','id']