import subprocess import requests import datetime import os import glob from os import listdir from os.path import isfile, join all_ids=['Jared','Hana','huai-sian','jesseng','conradlan','mike','Hong','andy','nina','CJYen','ccc','miacheng913','noodlesloves','yukyo0821','ming'] all_ids=['Jared','Hana','huai-sian','jesseng','conradlan','mike','Hong','andy','nina','CJYen','ccc','miacheng913','noodlesloves','yukyo0821','ming'] weekday_ids={1:[all_ids],2:[all_ids],3:[all_ids],4:[all_ids],5:[all_ids]} #git_ids=['Jared'] #,'Hana','huai-sian','jesseng','conradlan','mike','Hong','andy','nina','CJYen','ccc','miacheng913','noodlesloves','yukyo0821','ming'] def notify_group(msg): gid='WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD' headers = {"Authorization": "Bearer " + gid,"Content-Type": "application/x-www-form-urlencoded"} r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params={"message": msg}) #os.system("git log --author Jared --date=short --after=2021-12-20") #lines=subprocess.run(['git','log','--author','Jared'], capture_output=True) """ allids="" for gid in git_ids: ot=subprocess.run(['git','log','--author',gid,'--date=short','--after=2021-12-20'], capture_output=True) print(ot.args) otstr=ot.stdout.decode('utf-8').strip() o_len=len(otstr) print(o_len) print(otstr) if o_len <=0: allids+= gid+", " print('notify') """ pypath = __file__[0:__file__.replace("\\","/").rfind("/")] print(pypath) os.chdir(pypath + "/..") #os.system("cd " + pypath + "/..") #os.system("cd ..") os.system("git pull") nologlist = [] mylist = [f for f in glob.glob(pypath + "/../" + str(datetime.date.today().year) +"/*.md")] #print(mylist) #print(datetime.date.today().strftime("%Y/%m/%d")) for file in mylist: f = open(file, 'r' ,encoding='utf8') if not ('## ' + datetime.date.today().strftime("%Y/%m/%d")) in f.read(): #print(f.name) #print('true') #else: nologlist.append(f.name[f.name.replace('\\','/').rfind('/')+1:f.name.find('.md')]) #print(f.read()) f.close() if len(nologlist) > 0: #print(', '.join(nologlist)) print('提醒:' + ', '.join(nologlist) + ' 今天尚未填寫工作日誌喔!') notify_group('提醒:' + ', '.join(nologlist) + ' 今天尚未填寫工作日誌喔!') #onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] #print(allids+" remember to write your work journal" ) #notify_group('@yukyo test tag') #print('提醒:' + ', '.join(nologlist) + ' 今天尚未填寫工作日誌喔!') #notify_group('提醒:' + ', '.join(nologlist) + ' 今天尚未填寫工作日誌喔!') #wd=datetime.datetime.today().isoweekday() #print(mylist)