示例#1
0
def isweatherupdate(weathertxtfilename):
    # print(weathertoday, end='\t')
    # print(datetime.datetime.now().strftime('%F'))
    weathertoday = time.strftime(
        '%F',
        time.strptime(
            readfromweathertxt(weathertxtfilename)[0].split(' :')[0],
            '%B %d, %Y at %I:%M%p'))
    if datetime.datetime.now().strftime('%F') == weathertoday:
        log.info('今天的天气信息已取回,跳过邮件轮询。')
    else:
        items = getweatherfromgmail()
        if items:
            log.info('通过邮件轮询,读取天气信息%d条。' % len(items))
            itemfromtxt = readfromtxt(weathertxtfilename)
            for itemg in itemfromtxt:
                items.append(str(itemg))
            write2txt(weathertxtfilename, items)

    items = readfromtxt(weathertxtfilename)
    print(len(items))
    if not (dycountini := getcfpoptionvalue('everlife', '天气', '统计天数')):
        dycountini = 0
示例#2
0
def fetchweatherinfo_from_gmail(weathertxtfilename):
    weatherdatalastestday = getnewestdataday('存储数据')
    today = datetime.datetime.now().strftime('%F')
    hour = int(datetime.datetime.now().strftime('%H'))
    if (today > weatherdatalastestday) and (hour > 6):
        items = getweatherfromgmail()
        if items:
            log.info('通过邮件轮询,读取天气信息%d条。' % len(items))
            itemfromtxt = readfromtxt(weathertxtfilename)
            for itemg in itemfromtxt:
                items.append(str(itemg))
            write2txt(weathertxtfilename, items)
            weathertxtlastestday = time.strftime(
                '%F',
                time.strptime(items[0].split(' :')[0], '%B %d, %Y at %I:%M%p'))
            setcfpoptionvalue('everlife', '天气', '存储数据最新日期',
                              '%s' % weathertxtlastestday)
示例#3
0
def weatherstatdo():
    weathertxtfilename = str(dirmainpath / 'data' / 'ifttt' / 'weather.txt')
    print(weathertxtfilename)
    dfgoogledrive = None
    try:
        # fetchweatherinfo_from_gmail(weathertxtfilename)
        dfgoogledrive = fetchweatherinfo_from_googledrive()
    except Exception as weathererror:
        log.critical(f'从邮箱或谷歌硬盘获取天气信息时出现错误。{weathererror}')
        raise

    weathernotelastestday = getnewestdataday('笔记')
    today = datetime.datetime.now().strftime('%F')
    weathertxtlastestday = getnewestdataday('存储数据')
    if today == weathernotelastestday:  # and False:
        print('今天的天气信息统计笔记已刷新,本次轮询跳过')
    elif today == weathertxtlastestday:  # or True:
        try:
            items = readfromtxt(weathertxtfilename)
            dftxt = items2df(items)
            # print(dftxt.dtypes)
            dfall = dftxt.append(dfgoogledrive, True)
            # print(dfall)
            # print(dfgoogledrive.dtypes)
            datenew = dfall['date'].max()
            weatherstat(dfall, '296f57a3-c660-4dd5-885a-56492deb2cee')
            log.info(f'天气信息({datenew})成功更新入天气信息统计笔记')
            setcfpoptionvalue('everlife', '天气', '统计天数', f"{len(items)}")
            setcfpoptionvalue('everlife', '天气', '笔记最新日期', today)
        except IndexError as ixe:
            log.critical('读取天气信息并更新天气统计信息笔记时出现索引错误。%s' % (str(ixe)))
        except TypeError as te:
            log.critical('读取天气信息并更新天气统计信息笔记时出现类型错误。%s' % (str(te)))
            raise
        except Exception as eeee:
            log.critical('读取天气信息笔记并更新天气统计信息笔记时出现未名错误。%s' % (str(eeee)))
    else:
        log.info('时间的花儿静悄悄!')
示例#4
0
# %%
@timethis
def chuli_datasource():
    """
    展示足迹
    """
    namestr = 'everloc'
    if (device_id := str(getcfpoptionvalue(namestr, namestr,
                                           'device_id'))) is None:
        device_id = getdeviceid()
        setcfpoptionvalue(namestr, namestr, 'device_id', device_id)

    txtfilename = str(dirmainpath / 'data' / 'ifttt' /
                      f'location_{device_id}.txt')
    print(txtfilename)
    itemread = readfromtxt(txtfilename)
    numlimit = 9  # 显示项目数
    print(itemread[:numlimit])
    itemsrc = [x.split('\t') for x in itemread if not 'False' in x]
    itemnotfine = [x for x in itemsrc if len(x) < 3]
    print(f"有问题的数据共有{len(itemnotfine)}行:{itemnotfine}")
    #     itemfine = [x for x in itemsrc if len(x) >= 3][:10000]
    itemfine = [x for x in itemsrc if len(x) >= 3]
    # print(itemfine)
    if len(itemfine) < 2:
        print('gps数据量不足,暂时无法输出移动距离信息')
        return
    timesr = list()
    dissr = list()
    outlst = list()
    # speedsr = list()
示例#5
0
    # 判断是否延时并增加提示到条目内容中
    if (humantimestr := gethumantimedelay(inputformatmsg['fmTime'])):
        inputformatmsg['fmText'] = f"[{humantimestr}]" + inputformatmsg['fmText'] 
    msgcontent = ""
    for item in inputformatmsg:
        if item == "fmId":
            continue
        msgcontent += f"{inputformatmsg[item]}\t"
    # 去除最后一个\t
    msgcontent = msgcontent[:-1]
    print(f"{msgcontent}")

    men_wc = getcfpoptionvalue('everwebchat', get_host_uuid(), 'host_nickname')
    chattxtfilename = str(getdirmain() / 'data' / 'webchat' /
                          f'chatitems({men_wc}).txt')
    chatitems = readfromtxt(chattxtfilename)
    global note_store
    # webchats.append(chatmsg)
    chatitems.insert(0, msgcontent)
    write2txt(chattxtfilename, chatitems)

    # if inputformatmsg['fmText'].startswith('收到转账'):
    # showjinzhang()

    # if inputformatmsg['fmText'].startswith('微信支付收款'):
    # showshoukuan()

    # readinifromnote()
    # cfpfromnote, cfpfromnotepath = getcfp('everinifromnote')
    if (men_wc is None) or (len(men_wc) == 0):
        log.critical(f"登录名{men_wc}为空!!!")