Files
deadswitch/__pycache__/api1.cpython-37.pyc

40 lines
4.3 KiB
Plaintext
Raw Normal View History

2020-11-09 15:38:10 -06:00
B
<00>><3E>_<EFBFBD><00>@s.ddlZddlZddlmZmZmZddlmZddlmZmZm Z ddl
Z
ddl Z dZ Gdd<07>de <0A>Zdd <09>Zd
d <0B>Zed k<02>r*e<00>e<11>Zd ejd<ej<14>e<0E><00>e<06>Ze<16>e<13>e<16><18>dd<10>Zejdd<12><00>Zejddgd<15>dd<17><00>Zejddgd<15>dd<1A><00>Zejdddgd<15>dd<1E><00>Zej d dd <20>dS)!<21>N)<03>request<73>jsonify<66>g)<01> APScheduler)<03>datetime<6D> timedelta<74>timezonezdeadswitch.sqlite3c@s eZdZddddd<05>gZdZdS)<08>Config<69>job1zapi1:expiryCheck<63>interval<61>
)<04>id<69>func<6E>trigger<65>secondsTN)<05>__name__<5F>
__module__<EFBFBD> __qualname__<5F>JOBS<42>SCHEDULER_API_ENABLED<45>rr<00>*C:\Users\Joe\Git@Kawomi\deadswitch\api1.pyr s

r cCsPtd|<01>d|<00><00><04>d}t<01>d|<02>}d}d}d|<00>d|<00>d <09>}|<03>|||<06>dS)
Nzsending mail to z for topic <20><00> localhostzdeadswitch@kawomi.comzjoerg.tretter@gmail.comz(Subject: deadSwitch not pushed on topic z1
Notification of deadSwitch not pushed on topic <20>.)<04>print<6E>smtplib<69>SMTP<54>sendmail)<07>topic<69>toAddr<64>port<72>server<65> sender_email<69>receiver_email<69>messagerrr<00>sendMails r&cCsxtddd<03>tjttjd<04>}|<00><05>}xF|<01>d<05>D]8}t|<02>t|d|d<00>|<00>d|dg<01>|<00><08>q0W|<00> <09>dS) Nr<00>)<01>end)<01> detect_typeszeselect expiry,topic,email from entries where active=True and isNotified=False and expiry < datetime()<29><00>z0update entries set isNotified=True where topic=?)
r<00>sqlite3<65>connect<63>DATABASE<53>PARSE_DECLTYPES<45>cursor<6F>executer&<00>commit<69>close)<03>dbr0<00>theRowrrr<00> expiryCheck&s  r6<00>__main__F<5F>DEBUGcCs.ttdd<00>}|dkr*tjttjd<02>}t_|S)N<> _database)r))<07>getattrrr,r-r.r/r9)r4rrr<00>get_db<s r;cCs(ttdd<00>}|dk r$|<01><02>|<01><03>dS)Nr9)r:rr2r3)<02> exceptionr4rrr<00>close_connectionBs r=<00>/<2F>GET)<01>methodscCsdS)Na[<h1>Dead-Switch web service</h1>
<hr>
<h2>2020-10-29 - j.tretter@gmail.com</h2>
<hr>
Examples:
<ul>
<li>curl "https://deadswitch.kawomi.com/api/v1?topic=sys.demo"</li>
<li>curl -d "" -X POST "https://deadswitch.kawomi.com/api/v1?topic=sys.demo&secs=60&email=demo@demo.com"</li>
</ul>rrrrr<00>homeIs
rAz/api/v1c Cs<>dtjkrtjd}ntddd<04><02>St<03><00><04>}|<01>d|g<01>|<01><06>}|dkrbtdd|<00>d<07>d<04><02>Std|t|d <00>|d
<00>d <0B>|d <00>d <0B>t|d <00>|dt|d<00>d<10><08>S)NrFzNo topic given)<02>success<73>errorzlselect active,expiry,email,isNotified,expiry<datetime('now') "isExpired",lastSeen from entries where topic=?zNo entry found for topic _<>_Trr*z%Y-%m-%d %H:%M:%S<><00>r+<00>)rBr<00>active<76>expiry<72>lastSeen<65> isExpired<65>email<69>
isNotified) r<00>argsrr;r0r1<00>fetchone<6E>bool<6F>strftime)rr0r5rrr<00>api_getByTopicVs
 
rR<00>PUT<55>POSTc
Cs dtjkrtjd}ntddd<04><02>Sdtjkr:tjd}ntddd<04><02>Sdtjkrbttjd<00>}ntddd<04><02>Stjtjd <09>t|d
<EFBFBD>}y<t <09><00>
<EFBFBD>}|<04> d |||g<03>|j d kr<>|<04> d |||g<03>Wn0t k
r<EFBFBD>}ztdt|<05>d<04><02>Sd}~XYnXtd|<03>d<0F>|d<10><03>S)NrFzNo topic given)rBrCrLzNo email given<65>secsz No secs given)<01>tz)rzgupdate entries set active=True,isNotified=False,email=?,expiry=?,lastSeen=datetime('now') where topic=?rzmInsert into entries (active,topic,expiry,email,isNotified,lastSeen) values (True,?,?,?,False,datetime('now'))Tz%Y-%m-%d %H:%M:%S)rBrIrL)rrNr<00>intr<00>nowr<00>utcrr;r0r1<00>rowcount<6E> Exception<6F>strrQ)rrLrU<00>expiryDateTimer0<00>errr<00> api_setRecordes$
 
 


 r_i)<02> use_reloaderr!)!<21>flask<73>sysrrr<00>flask_apschedulerrrrrr,rr.<00>objectr r&r6r<00>Flask<73>app<70>config<69> from_object<63> scheduler<65>init_app<70>startr;<00>teardown_appcontextr=<00>routerArRr_<00>runrrrr<00><module>s.