Exemple #1
0
    def post(self):
        logger.info('提交数据进行修改密码')
        old_password = self.get_argument("old_password", '')
        new_password = self.get_argument("new_password", '')
        if not old_password.strip() or not new_password.strip():
            logger.info('密码不能为空')
            self.render('change_pass.html', error = 1)
            return

        md = hashlib.md5()
        md.update(old_password.encode('utf-8'))
        sql = 'SELECT password FROM tb_userinfo WHERE username = ? LIMIT 1;'
        result = self.db_select(sql, [self.current_user.decode()])

        if md.hexdigest() == result[0]['password']:
            md = hashlib.md5()
            md.update(new_password.encode('utf-8'))
            sql = 'UPDATE tb_userinfo SET password = ? WHERE username = ?'
            result = self.db_update_insert(sql, [md.hexdigest(), self.current_user.decode()])
            if not result:
                logger.warning('数据库更新失败,密码更改失败')
                self.render('change_pass.html', error = 2)
                return
        else :
            logger.info('原来密码错误')
            self.render('change_pass.html', error = 3)
            return
        logger.info('密码修改成功!')
        self.render('change_pass.html', error = 0)
Exemple #2
0
def get_order_code(order_name):
    raw_params = order_name.split(' ')
    try:
        return raw_params[3]
    except IndexError as e:
        logger.warning('wrong zip name format %s', e)
        return ''
Exemple #3
0
def _get_token_(url, file_path):
    _, ext = os.path.splitext(file_path)
    tmp_file_name = get_tmp_file_path(str(uuid.uuid1()) + ext.lower())

    shutil.copy(file_path, tmp_file_name)

    assert filecmp.cmp(file_path, tmp_file_name) is True

    token = []
    with open(tmp_file_name, 'rb') as f:
        logger.info(
            f"call get tokens from document service started. url is {url} ")
        response = requests.post(url, files={'file': f})

        logger.info(
            f"call get tokens from document service ended. result status code is {response.status_code}")

        if response.status_code == 200:
            result = json.loads(response.text)
            token = result['text_tokens']
            if isinstance(result, str):
                logger.exception(f"{tmp_file_name}文件可能损坏,请将订单文件另存为正确的格式后,重新上传。")
        else:
            logger.warning(response.status_code)
            logger.info(f"get tokens from windows server error. {response.content}")
            # os.remove(tmp_file_name)

    # os.remove(tmp_file_name)

    return token
Exemple #4
0
def check_shop(url, keywords):
    global browser
    browser.get(url)
    time.sleep(5)
    find_flag = False
    for keyword in keywords:
        if keyword in browser.page_source:
            find_flag = keyword
            break
    if not find_flag and '出错啦' not in browser.title:
        log.warning("FIND!!!")
        log.warning(url)
        log.warning(keywords)
        #     "发现口罩有货!!",
        fo = open("../data.txt", "r")
        lines = fo.readlines()
        fo.close()
        fo = open("../data.txt", "w")
        str_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        lines.append(str_time + " " + browser.title + " url:" + url + "\n")
        fo.writelines(lines)
        fo.close()
        print("发现口罩有货!!" + url)
        browser.save_screenshot("imgs/" + str_time + ".png")
        time.sleep(5)
def get_images_from_file(filename, dest_path):
    ext = filename.split('.')[-1].lower()

    function_mapper = {
        # 'xls': get_images_from_excel,
        # 'xlsx': get_images_from_excel,
        # 'xlsm': get_images_from_excel,
        # 'doc': get_images_from_word,
        # 'docx': get_images_from_word,
        # 'pdf': get_image_from_pdf
    }

    if ext in function_mapper:
        text = function_mapper[ext](filename, dest_path)
        if text:
            logger.info(f'get_images_from_file result is {text}')
            return text
        else:
            return {'img_count': 0, 'paths': []}
    else:
        logger.warning(
            f'get_images_from_file file type out of range. file_type is {ext}')
        return {'img_count': 0, 'paths': []}
Exemple #6
0
def check_shop(url, keywords):
    browser.get(url)
    time.sleep(3)
    find_flag = False
    for keyword in keywords:
        if keyword in browser.page_source:
            find_flag = keyword
            break
    if not find_flag:
        log.warning("FIND!!!")
        log.warning(url)
        log.warning(keywords)
        # send_mail(
        #     "发现口罩有货!!",
        #     url,
        #     mail_config.get("to")
        # )
        send_msg(url)
Exemple #7
0
#! coding=utf-8
# 初始化docker模块,直接提供三个控制借口,可以直接操作docker镜像和容器。
import docker

from log.logger import logger
from docker_lib.docker_add import Dokcers_Add
from docker_lib.docker_del import Dokcers_Del
from docker_lib.docker_get import Dokcers_Get

try:
    client = docker.from_env()
    client.images.list()
    logger.info('连接到Docker进程。')
except Exception as e:
    logger.warning('连接本地Docker进程失败,可能是Docker进程未开启!')
    exit()

Dockers_Start = Dokcers_Add(client)
Dockers_Stop = Dokcers_Del(client)
Dockers_Info = Dokcers_Get(client)
Exemple #8
0
def remove_file(file_path):
    if os.path.isfile(file_path):
        os.remove(file_path)
    else:
        logger.warning(f'It is not a file. path is {file_path}')
readers = nfc_reader_manager.get_readers()
readers.append('lolo')
if len(readers) > 1:
    selected_reader = None
    print(u'We found more than one NFC reader connected to your computer :')
    for reader_id, reader_name in enumerate(readers):
        print('%d : %s' % (reader_id, reader_name))
    print(u'Please choose the NFC reader you want to use by entering its id')

    while not isinstance(selected_reader, int):
        try:
            selected_reader = int(input())
        except ValueError:
            selected_reader = None
            logger.warning(
                u'It\'s not a valid input. Please choose a number in list')
        if selected_reader and selected_reader > len(readers) - 1:
            selected_reader = None
            logger.warning(
                u'It\'s not a valid input cause your entry is greater than the size of the list'
                u'. Please choose a number in list.')
else:
    selected_reader = 0
user_input = None
while user_input != 'EXIT':
    nfc_reader_manager.set_connection(selected_reader)
    nfc_reader = nfc_reader_manager.get_reader()
    print(u'If your badge is on your NFC reader, press enter to continue')
    input()

    card_is_connected = False