From feb8af703a70e19ca49ec0dc81d92504339de896 Mon Sep 17 00:00:00 2001 From: Lyncoln Date: Sat, 10 Oct 2026 19:18:06 -0400 Subject: [PATCH] Reestablished working state --- Containerfile | 2 + __pycache__/login.cpython-314.pyc | Bin 0 -> 339 bytes checkavailable.py | 5 +++ .../__pycache__/execute.cpython-314.pyc | Bin 726 -> 740 bytes .../__pycache__/request.cpython-314.pyc | Bin 1122 -> 1133 bytes core/apirequest/execute.py | 6 +-- core/apirequest/request.py | 2 +- .../__pycache__/createthread.cpython-314.pyc | Bin 995 -> 952 bytes .../executioncontract.cpython-314.pyc | Bin 610 -> 663 bytes .../action/__pycache__/action.cpython-314.pyc | Bin 1189 -> 800 bytes core/execution/action/action.py | 15 ++----- core/execution/createthread.py | 6 +-- core/execution/executioncontract.py | 5 +++ .../lifecyclemanager.cpython-314.pyc | Bin 1038 -> 1199 bytes .../lifecyclemanager/lifecyclemanager.py | 7 +++- .../__pycache__/__init__.cpython-314.pyc | Bin 208 -> 208 bytes .../__pycache__/operation.cpython-314.pyc | Bin 1102 -> 1018 bytes .../__pycache__/skipstep.cpython-314.pyc | Bin 800 -> 786 bytes core/execution/operation/operation.py | 38 ++++++------------ core/execution/operation/skipstep.py | 10 ++++- core/runtime/__pycache__/logs.cpython-314.pyc | Bin 470 -> 594 bytes .../__pycache__/managefailure.cpython-314.pyc | Bin 966 -> 1021 bytes .../__pycache__/outputs.cpython-314.pyc | Bin 859 -> 859 bytes .../runtimecontract.cpython-314.pyc | Bin 0 -> 895 bytes .../__pycache__/savedata.cpython-314.pyc | Bin 1368 -> 1453 bytes core/runtime/logs.py | 26 +++++++----- core/runtime/managefailure.py | 17 ++++++-- core/runtime/outputs.py | 2 - core/runtime/runtimecontract.py | 30 ++++++++++++++ core/runtime/savedata.py | 9 +++-- .../createdispatch.cpython-314.pyc | Bin 849 -> 864 bytes .../createresponse.cpython-314.pyc | Bin 0 -> 461 bytes .../__pycache__/dispatcher.cpython-314.pyc | Bin 711 -> 728 bytes .../__pycache__/dispatchstate.cpython-314.pyc | Bin 1227 -> 1254 bytes .../server/__pycache__/server.cpython-314.pyc | Bin 929 -> 1610 bytes core/server/createdispatch.py | 2 +- core/server/createresponse.py | 14 +++++++ core/server/dispatcher.py | 8 ++-- core/server/dispatchstate.py | 2 +- core/server/server.py | 22 +++++++--- initialize.py | 2 + .../checkavailable.cpython-314.pyc | Bin 599 -> 653 bytes .../actions/__pycache__/login.cpython-314.pyc | Bin 841 -> 872 bytes .../refresh_tokens.cpython-314.pyc | Bin 835 -> 873 bytes .../__pycache__/setavailable.cpython-314.pyc | Bin 951 -> 1023 bytes plugins/rmass/actions/checkavailable.py | 4 ++ plugins/rmass/actions/login.py | 2 +- plugins/rmass/actions/refresh_tokens.py | 8 +++- plugins/rmass/actions/setavailable.py | 5 +++ .../__pycache__/login.cpython-314.pyc | Bin 306 -> 306 bytes .../__pycache__/setavailable.cpython-314.pyc | Bin 556 -> 554 bytes plugins/rmass/operations/setavailable.py | 4 +- tokens.json | 1 + 53 files changed, 170 insertions(+), 84 deletions(-) create mode 100644 __pycache__/login.cpython-314.pyc create mode 100644 checkavailable.py create mode 100644 core/runtime/__pycache__/runtimecontract.cpython-314.pyc create mode 100644 core/runtime/runtimecontract.py create mode 100644 core/server/__pycache__/createresponse.cpython-314.pyc create mode 100644 core/server/createresponse.py create mode 100644 tokens.json diff --git a/Containerfile b/Containerfile index 9841970..d5eb5e7 100644 --- a/Containerfile +++ b/Containerfile @@ -7,3 +7,5 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . + +ENTRYPOINT python initialize.py diff --git a/__pycache__/login.cpython-314.pyc b/__pycache__/login.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9218da82d7f5b94f809873bf6d93852e82ec6bfc GIT binary patch literal 339 zcmdPq%l$%&w3}o;nm1gFo_!p!W zC6;97=lN-}-(oMwDNWDJD=q@L=$1rseo?AkYDH>tDM*1{K1^v53rLy^&M&^jnv)OI zcZ)s0w4|W4qR;wEXksto2C4!8 Dt{PEW literal 0 HcmV?d00001 diff --git a/checkavailable.py b/checkavailable.py new file mode 100644 index 0000000..f382428 --- /dev/null +++ b/checkavailable.py @@ -0,0 +1,5 @@ +from plugins import rmass +from core import buildOperation + +outputs = buildOperation(rmass.operations.checkavailable) + diff --git a/core/apirequest/__pycache__/execute.cpython-314.pyc b/core/apirequest/__pycache__/execute.cpython-314.pyc index 8a23855220ec6ab0c4f69401fca56a5a33b6ba70..076506181d1404d4f0d6e2fca090aa2c753e1deb 100644 GIT binary patch delta 125 zcmcb{`h=BNn~#@^0SG4TKa~|ak++v|&BWP~Y~@T03`L3)w{@|E8yYiBc4CZXW=l+- zyo6Cr+CV=eKQ~oBC9y0sMZYLFH!&|UJ+(+bIlm}%@&iT#!4RNf4Gee0l^3{O7B{)b bA~IQy$&u{>x6B0=naPPv`E0U9!ayYeJm4g* delta 111 zcmaFDdX1G=n~#@^0SMMrAIb8b$lJ@fY~pN5rUIskySkXdm?wKMMzeFJq^4!&Wlmnk zs3xYZpOK%Ns-KcrmYJeol$)EFmzbVfH2FEB0iQ3>lm>=7d{Q&4F7xS6)?jjEYVe<& N&y>$5QX~wN0|0xzAshez diff --git a/core/apirequest/__pycache__/request.cpython-314.pyc b/core/apirequest/__pycache__/request.cpython-314.pyc index 3ab67a865f4d1bbc5c54c58494fc1f3d8de812c5..d4b42c7e336a7b0d994153ae523330b6583f79da 100644 GIT binary patch delta 74 zcmaFF@s@*En~#@^0SLOcoyroQ$eYM`Y-9dmM&@uuN35+LIZX#U{%z>oT67?8SV6 Rsljiu0*gDFaFGO12LLr<5U2nE diff --git a/core/apirequest/execute.py b/core/apirequest/execute.py index b451791..5bf6d96 100644 --- a/core/apirequest/execute.py +++ b/core/apirequest/execute.py @@ -4,8 +4,8 @@ from .request import buildRequest session = requests.Session() -def executeRequest(definition, outputs): - request = buildRequest(definition, outputs) +def executeRequest(action, outputs): + request, outputs = buildRequest(action, outputs) response = session.request( method=request["method"], @@ -23,4 +23,4 @@ def executeRequest(definition, outputs): # sessioncookies[cookie_name] = response[cookie_key], - return response + return response, outputs diff --git a/core/apirequest/request.py b/core/apirequest/request.py index ea1dc62..11648a6 100644 --- a/core/apirequest/request.py +++ b/core/apirequest/request.py @@ -25,4 +25,4 @@ def buildRequest(definition, outputs): request["headers"] = headers - return request + return request, outputs diff --git a/core/execution/__pycache__/createthread.cpython-314.pyc b/core/execution/__pycache__/createthread.cpython-314.pyc index daf696843859e5d64819477c578378faf6e20a17..fd899427d235af28f97ed376014d5960c5cea85b 100644 GIT binary patch delta 181 zcmaFNzJr}tn~#@^0SGqCI+;~9kyk^NF^I{N(SxakNuD8&F^Cz+W-eitXV7CPVTofX zW({HyXDDHt80E#tvvDaWBTKlUG1KN_jJ%AD6_c+p73n|!04|=Jn3tHIS~NM1SzBKQ uD8&fG#j-%+12ZEd<820kyA1kw8FU`-@;7kZ;NflH{K6u}XjvoyQ~>}(^fXog diff --git a/core/execution/__pycache__/executioncontract.cpython-314.pyc b/core/execution/__pycache__/executioncontract.cpython-314.pyc index 9d069d34d0e1c348e1d6ccb14de047f67e68bf45..db7835e3cb6016ae4e5e129efc47ff8afab5c77d 100644 GIT binary patch delta 249 zcmaFFGM$xIn~#@^0SI!op2}K1kynz@V4}LLL>xm9vnPuOYYD47LlBENLkU|Dt1^Qo z+r$7hK~2V6yt#>aiRr0siJ3X2MX4Lhlo*3~fo8A*aj_kcXkd82&f8wySUn;83cKPR zA%z8EmxVMs*gps`@CY~fec)x_66lxil%BzHg;U{q;IfjmG} zEI?dr10)(4Zm{#VS2tEq$iBj^ct=QKf!JjsjSlt?Tns$I4SpZk8Mp-cr8}i(a9rV3 zxFaMxBki(~Y6trRZlMOh&p`bQewwV4Ihd^Nia^G$WGLbVQbpWA;ueQZZhlH>PO4pz fAdt%l#Ki(Y;sY}yBja5L-Mb9NUs%`~g~2)i_xLT1 diff --git a/core/execution/action/__pycache__/action.cpython-314.pyc b/core/execution/action/__pycache__/action.c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T9}AVy^dP4G74s(JcD<@<^_ySj9el>QIK?T^W-;7UaV6pukk2O zc4W5Y;w|C@3g2SNFP_}OY*Vk0oL`ixms*jUTw0QupNC*2=jW9aB_@{?v4WH{XXcgM zVo%L0%Ph*zyTzQIT2jOh6fXi;s? FDgcLvU*`Y- delta 319 zcmZ3_*~gKh&Bx2d00g;zPh_oQVqka-;=llq4+fttfK&rR977PJCqoH{X7Xh8U@Bpf z2eFwwnLSuaSio!+PgW1M5;l2;AXagP680cQWd=>Qi5sk>lVN6o3}lAl&oPWZb0_~~ zG-7A8h+tqyiJBb1Xw7IjxrZ@8DU2Zi>@tuB1TX>W00DUh@376E7@Ziogn>MEATI8l zY{%@yJ)!KnxcWtL^=mvDlY5zM**J=LfRdB1Fx&XCB2KczG$)vibq$OTzaECwV#Ff%eT-e%x_%3yq#LH90$!WR}HMsBb^0LMN!CjbBd diff --git a/core/execution/lifecyclemanager/lifecyclemanager.py b/core/execution/lifecyclemanager/lifecyclemanager.py index d956d9e..7ccd14d 100644 --- a/core/execution/lifecyclemanager/lifecyclemanager.py +++ b/core/execution/lifecyclemanager/lifecyclemanager.py @@ -1,8 +1,11 @@ import time +import os from core.execution.operation import buildOperation from core.execution.action import buildAction -from core import executeContract +from core.execution.executioncontract import executeContract + +sleeptime = int(os.environ.get("REFRESH_INTERVAL", 180)) def manageLifecycle(module, lifecycles): #lifecycles, state): #print(lifecycles[module.name]["mode"]) @@ -15,7 +18,7 @@ def manageLifecycle(module, lifecycles): #lifecycles, state): #print(lifecycles) - time.sleep(module.sleeptime) + time.sleep(sleeptime) elif lifecycles[module.name]["mode"] == "oneshot": print(lifecycles) diff --git a/core/execution/operation/__pycache__/__init__.cpython-314.pyc b/core/execution/operation/__pycache__/__init__.cpython-314.pyc index c487459e22478356b4d34528a76294a318054d82..8c81fac1eb8ed7b468af43b15cb7ba3aae40ec1f 100644 GIT binary patch delta 19 Zcmcb>c!7~yn~#@^0SG!{Pfg@L3IHte1rGoK delta 19 Zcmcb>c!7~yn~#@^0SNvdIyRB}C;%~@1?B(% diff --git a/core/execution/operation/__pycache__/operation.cpython-314.pyc b/core/execution/operation/__pycache__/operation.cpython-314.pyc index 3fd4a505dd42bc4e313b487a3d4398507df427e0..f08d160c804b3a24e8f812a6b1fb98fc16cb3076 100644 GIT binary patch delta 386 zcmX@d@r#{Ln~#@^0SJ~IJC)_eJdy7`7aNer48)%gOlD`471CoUVA5wOU=CvxU~qG1 zU?^ajY{IBt&l1LL0#XG8>JW+{1<03S@YZBth+&5cF@!stFhSVmK)T2@j46NW@QFV###bN zEGS6LOVMPz#g&qpmYJ6ck}cu^nske^D7Cl%s5G^BvK^E3)cwGxV7%^i_hR%;eMUp!i#lR2)G64+2jZByzta2b-q~dMKz`)5M#}LG* z%%H#!!vR&sz{Zdw0n%N-8p90}iwq8d+fl$I3)EA>|p!A#K~!MhhJ<$ z)dH*Q{Cb!8_3j8u&+yv7eqGq&lCZ^15t%0n+AG{HE7)A*k?nAw81b2xL0Ia?7a;}# z$uA6yK)qth3tTstUlz0ObN~H;87T6rSO#e0R24@)rro@be8Nlz`M4boSPx3_IBK&V b)Mf>;Coykf`phtS8?z0E0HaNjEKofF`#)np diff --git a/core/execution/operation/__pycache__/skipstep.cpython-314.pyc b/core/execution/operation/__pycache__/skipstep.cpython-314.pyc index e5f87e3fa42e7f5f6b4ef808fdf428c33820b969..f071db522ab88802d293d0542db521664b4e3ba4 100644 GIT binary patch delta 215 zcmZ3$Hi?Z-n~#@^0SNq$pURrXG?CANk!hm;+sPh`Zj3CG`xzxBZ({Uiw3@^u&6!$} znp|3vnV&aVib+vO0H}u%h>Kf+L<7SICZWl`OmZS0co<|=R%BdNF~2Hf(c$}njX^+i zay64#mM8;{=8rFO3_K!V7?@Z^AMuNPUPO4pzFpvwj9pv^8%#4hTUzmg$MT&W%AVCl?W}0ln=%&nii=#L@v!J*n zwcr+OK~ZL2$t{+=#N5WHa^HWN5 cQtgUFfLyTkAnySUVr2Zn#LFmJBn;#N0BwLi_y7O^ diff --git a/core/execution/operation/operation.py b/core/execution/operation/operation.py index 864a03e..5537234 100644 --- a/core/execution/operation/operation.py +++ b/core/execution/operation/operation.py @@ -9,33 +9,19 @@ from .skipstep import skipStep def buildOperation(definition): actions = definition.actions - -# responses = [] + #print("DEBUG", actions) + responses = [] outputs = {} for action in actions: - try: - if hasattr(definition, "skipstep"): - if skipStep(definition, action, outputs): - continue + #try: + if hasattr(definition, "skipstep"): + if skipStep(definition, action, outputs): + continue - outputs, response = buildAction(action, outputs) -# responses.append(response) - - except Exception as error: - outputs = manageFailure(error, action, outputs) - -# if hasattr(action, "cookies"): -# for cookiename, cookie, in cookies: - -# session.cookies.set( -# cookiename, -# outputs[cookie], -# domain=domainname -# ) - -# print( -# {outputs[cookie]}, -# domain, -# cookiename, -# ) + outputs, response = buildAction(action, outputs) + responses.append(response) + + #except Exception as error: + #outputs = manageFailure(error, action, outputs) + return outputs diff --git a/core/execution/operation/skipstep.py b/core/execution/operation/skipstep.py index 571da5a..ce205d2 100644 --- a/core/execution/operation/skipstep.py +++ b/core/execution/operation/skipstep.py @@ -2,13 +2,19 @@ def skipStep(definition, action, outputs): try: if action in definition.skipstep: condition = definition.skipstep[action] - + + #if outputs.get([condition["output"]]) is None: + #return False + #current_value = 1 + #else: current_value = outputs[condition["output"]] + #current_value = 1 if condition["operator"] == ">=": if current_value >= condition["value"]: print(f"Skipping {action.name}") return True - except TypeError, KeyError: + except KeyError: + #outputs = manageFailure(error) return False diff --git a/core/runtime/__pycache__/logs.cpython-314.pyc b/core/runtime/__pycache__/logs.cpython-314.pyc index 64fda39411528cbd2f4510367b02cc00d0f51e76..82e7e0798b317d0a019224d1861e0cac4b64d2f6 100644 GIT binary patch delta 411 zcmcb{e2JxAn~#@^0SH+4oywZT$iVOz#DM`ODC4sTkkP;p#}LHm$xy-as8!WhJ; z%%I8q5~Rd08Kx4%V*_GlApX1vNHj1=GlVe&09oiD0HkJOesr_~gFHhFND~;uaKKo` zO!5q}Kr59QteIsQG8r|QZZTTHC3yNJc=D&cX$ME z2+K~;nUQ!wK;ee4)Ky{C3qoq&SebeGJ~A_?S$`B^VCDYtfti6-p~quN<|Q8an=D+v ziaCMCHd)#-?B#RhV+OjBJtsdsJu@%82xRd}29wV~ilK-PNZjJE$<0qG%}KQ@5(aXC cq0Lat3nV@;Gcq#XX5jn6!pF#6Bm@)z0Mkxbx&QzG delta 260 zcmcb_a*a7yn~#@^0SJ1Z9n0cmWMFs<;=llq4+fukfK&rR5Q8{F2}2O0GJ_^lG80q| zM6m%eGZ25S01^!olgs5anQk#!`DrrWVk;=h%quCr#hO`?nhT`B+{vblS@j?@K^7F7 zgETQbP*h(oyHNJJqRB-?lWU4*7dd1*xbAT9-r$$)$eE#dfk);Bzt~lN#S45&-&mPB zxjr*9D4Bl-YGv@#WGn(1wvwTU7f2Ox1BqK4Ho5sJr8%i~Mf^Z6*dCBSKQJ>gGJauV KW8`85D+T}{R5y$O diff --git a/core/runtime/__pycache__/managefailure.cpython-314.pyc b/core/runtime/__pycache__/managefailure.cpython-314.pyc index b65f5ebc0012c254efdb586cf53922e2c43fb85b..a12bc84777fa7ce8439bb064081307ea38d943e6 100644 GIT binary patch delta 381 zcmX@c{+FFkn~#@^0SM-AK9#kMc_LpC7dw#048)(UCU&VX)=pe+;YlV;5Oz6`E>aI;DrJ&qP-fs{kYk7eISvfM7E zx`Tj*YqH+rElN$!FH0>7$j`}4u5|O8yp7Rd@^i*(j8iA?V^XXCz`?*Hc7h2Gk=!R5#v9x&Yq(q#QJvuaKwNGT-$zLXX{9ex46Ixop&jnm dSVTXA-0BB(nMiVe(PV$-d=7C&u_7^`AOJySS|k7f delta 282 zcmey%evF+@n~#@^0SMe4AImCan#fng#RlXt1Mz2xiCrp;ITP0#P1a;IWn`Qj&nOwe zWW-{^2vX0$AkPr)Yzd@O6d4#~7{X0-q`<;pqJTAwRe-@wfPtZaEru5+9-d^v1Yws0 z=^}M+AqECc204Z>CgsVi7^Os*l^HZyZt)hSCg+!>76s(zWF}WmzQt(3=r@^*=^A6> zIDI{3u@*&*!FYpSGeVG zh{;?P)97%2ETuSs?T(862DZy84i^O!C$P_y_{hv4t@MG7K}5R4?+y#+cp3`{bm0#JnpZl!lGkzrq zHqE-jao|4n_AE_ihB79sjQh)qY_cQtK#E|%YB<7DcxFcdlCU$vm(oRLHH>P?C9Luv zb~3=qeu0$Y!;IABuIli7)OCPFBjl)d3W~6Shvyg8(4K(3Ec+GJjey{bJL&CyTiXV( zZv+#GodzOm#fJWcodiR_rLKm&q@a|ztqQuwIPwCDDaTaMYn#mE<26!o8QnUJq^WON z4yCXC{T$|~Y*LdkLL^s2yfYBV1D~K}?=58}^C^!E>`TkD9X=Km;<{^A9r2{&ro}3r zOC$vx6NlD3mpW8dTU=b^ck*Sg>f~*+Ua|9}S~XpB&mnosBTk<9E~|*k&|03$h^V$w zJK*u)Ll}dE2XefGC@724BcYDqH;NtC8wXvKX`@UpG1n}AMyH9jV{{$|d{tZ>cF}wr z&G+zBW2uAZ2l?;1DBVWs9*#GrJ2-Qe037S0nG-bAd~}M^AGf>N!b!I9WwVpL-^0B+vB0iFq>C*>k5;R63q7>xW0$Tg8mri9}7Zq>8> eedivT7NLAL8W-wJQxxR~6i%RUuFooS0pc$Rd%bZ0 literal 0 HcmV?d00001 diff --git a/core/runtime/__pycache__/savedata.cpython-314.pyc b/core/runtime/__pycache__/savedata.cpython-314.pyc index 7c5945a64427e2b6b0443adfa3b90c2badfabae9..07ae161a74775595d46cdf2dd1d0be07c64ce06c 100644 GIT binary patch delta 442 zcmcb?wU(P#n~#@^0SNqep33?#kvEjlXkxMwqxZzNDMsGD3=EtMattxtAO#>0#1zID zzyo0;lROMT%s?5I$?KU#xmZjXA#(DQuQ4mDdbcw$SToBqWHM^9++r;EtKxG>EJ;)- zPAp4JQAny(sA5ql$)7xtaVKN-WN#){kBhuIAK4kiRKM^suyS?y%`ls9J=1!I?t+pP zZtMM5`d`qtxxi(6g~jd$w@`!McWwqg-RrzM7kG7k6@#3)Til72{SYg+li1{QOyZ1s zlbsQua(6hh5<#2_?5#k*|1}@F(oEi|n eED(2MVLimc?Ibdpo7IV1_=^-Lqi~Tl(3b$IhiLr( delta 367 zcmZ3>eS?cvn~#@^0SG=kJ(g84kvEi4YGSeyW9r1VDZDYMIotj@@B@JjD?eP znOwuZurYA*O^}?xJ;Q22+Vbp$*$ZMX@EKp@F!{*KAg203fPqK!0*lCZZU#Qx>%2O@ zib3}87I(B_KWN46#KoP=1hE@TvI9wGApR^dS%`TSqsHX5%u>iMW&yic7{$d}U>8r$ zW>l8)@j^Ja$ghf9AtygE1>)XBmNLft$v0S>?Jjai-QnN`JJ@R5ce(+ceG?ZXvyuwIXQvViCgrG6bGYlku=by0B)yN Ap8x;= diff --git a/core/runtime/logs.py b/core/runtime/logs.py index aca56c0..a7b2539 100644 --- a/core/runtime/logs.py +++ b/core/runtime/logs.py @@ -1,11 +1,17 @@ -def buildLog (action, outputs): -# try: - for print_name, print_key in action.prints.items(): - print( - f"{print_name}:", - f"{outputs[print_key]}", - ) +import logging - # except KeyError: - #outputs[print_key] = "N/A" - # return +def buildLog (action, outputs): + #if response.status_code == 200: + #print(f"{action.name} successful") + try: + for print_name, print_key in action.prints.items(): + print( + f"{print_name}:", + f"{outputs[print_key]}", + ) + + + #else: + #print(f"{action.name} failed") + except: KeyError, TypeError + return diff --git a/core/runtime/managefailure.py b/core/runtime/managefailure.py index ff94b43..3b7d082 100644 --- a/core/runtime/managefailure.py +++ b/core/runtime/managefailure.py @@ -7,13 +7,22 @@ def manageFailure(error, action, outputs): errors = action.recoverPolicy error_type = type(error) - print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.") + #print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.") if error_type in errors: repairs = errors[error_type] - + for repair in repairs: - outputs, response = buildAction(repair, outputs) + if repair == False: + return False - return outputs + elif repair is None: + return + + else: + print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.") + + outputs, response = buildAction(repair, outputs) + + return outputs print(f"{error}") diff --git a/core/runtime/outputs.py b/core/runtime/outputs.py index a64740a..ac21762 100644 --- a/core/runtime/outputs.py +++ b/core/runtime/outputs.py @@ -17,5 +17,3 @@ def buildOutput(response, action, outputs): return outputs - - diff --git a/core/runtime/runtimecontract.py b/core/runtime/runtimecontract.py new file mode 100644 index 0000000..cc2ef8d --- /dev/null +++ b/core/runtime/runtimecontract.py @@ -0,0 +1,30 @@ +from core.runtime import buildOutput, buildSave, buildLog + +def buildRuntimeAttr(action, outputs, response): + #print("BEFORE buildOutput:", type(outputs)) + if hasattr(action, "outputs"): + outputs = buildOutput(response, action, outputs) + + #print("AFTER buildOutput:", type(outputs)) + #print("DEBUG buildSave") + #print("outputs type:", type(outputs)) + #print("action type:", type(action)) + #print("outputs keys:", list(outputs) if isinstance(outputs, dict) else "NOT A DICT") + + if hasattr(action, "savedata"): + buildSave(outputs, action) + + if hasattr(action, "prints"): + buildLog(action, outputs) + + #if hasattr(action, "conversion"): + #conversions = action.conversion.items() + #for key in action.conversion.items(): + #print(f"{action.conversion.items[key]}") + #convertedoutput = conversions[key] + #outputs[conversions[key]] = convertedoutput + + if action.showstatus is True and response.status_code == 200: + print(f"{action.name} successful") + + return outputs, response diff --git a/core/runtime/savedata.py b/core/runtime/savedata.py index 44998b6..269f92d 100644 --- a/core/runtime/savedata.py +++ b/core/runtime/savedata.py @@ -9,9 +9,9 @@ def buildSave(outputs, action): with open(f"{action.savepath}", "w") as save_file: json.dump(save_data, save_file) - print(f"{save_name} saved by {action.name}") - - return save_file + #print(f"{save_name} saved by {action.name}") + print(f"Data saved by {action.name} to {action.savepath}") + return outputs def loadSave(outputs, action): with open(f"{action.savepath}", "r") as save_file: @@ -19,6 +19,7 @@ def loadSave(outputs, action): for load_name in action.loaddata: outputs[load_name] = load_data[load_name] - print(f"{load_name} loaded by {action.name}") + #print(f"{load_name} loaded by {action.name}") + print(f"Data loaded by {action.name} from {action.savepath}") return outputs diff --git a/core/server/__pycache__/createdispatch.cpython-314.pyc b/core/server/__pycache__/createdispatch.cpython-314.pyc index b93cbeaee5f88c848777bbc0d7b24bed609c4f9b..ee082d63588a85b51d879fceee25c5418bf12417 100644 GIT binary patch delta 58 zcmcb}_JEC7n~#@^0SNX@I+?X%BkxTn0r}+oqEx-qiqz!NlFa-(y~)p+V)(4@GN^uG M;bD|05(O#-03jO@t^fc4 delta 43 wcmaFBc9D%&n~#@^0SG>rpUj%Mk@qGOqrl{EOfh^qcNtW_u<$TS6o~?50T8wee*gdg diff --git a/core/server/__pycache__/createresponse.cpython-314.pyc b/core/server/__pycache__/createresponse.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5cfecc163fe118458ae4418aa412e0bd5a472ecd GIT binary patch literal 461 zcmZ8eO-sW-5S>lZG_`4Iwcxd&1VX`pAK*be*Ne&?a#M)OYQK_{-K3zW{DgS&;=!vw z#hc)ztVd7Y0`&(tsqMvqee>Qj^Ja(bH5(g%@$vjN+9d#ArC5iuB8v`^46cEaGf03c z+mH}ScEDD@%aU_nT~(IJz*FkQF+v6uyQt#AC93~n0#)}Fs<{MN#Z^pjw5jT<=&Va! zBwmsVSrw`8Gl3*T^zPV0y&DY0)JyyU3#6V5IP(Ijg>k@aBDKg1nXO43bvj|ZibHw% zCTVacrg0>g&`?^I)s+X%AP$)mc(Y;P@G$fu^yiKrbLI%fXC+7XgsofmruVXOlMW{V zU77I)nw9&CBZLeJ9ct~|o*V7__G$b$&aYm2?^}Cwqm{dPe{MAM!`v!rm6o3Mi%l>) x*~J1I!B(U;5^=Qjdj;OaJ8mLKfE7qH1M%maiR+U%figvo z;f~?TlVup?7+EJ?qYP~;s-K0fVkLY@-0RKIXTT0VwYuY zE^H22HNXx=cR0e91sFN>YoUZYW{{O5Ngwn4FoHUIa36 uB}0(_kSgMvJdsIUNfOBXz|6?Vc$Y!*E`#b_24f)OF@wMt79K_eutEU6t3v_+ delta 264 zcmcb?dYqL{n~#@^0SNY6oXj$0n#d=?XfaV;OPC>u#gnasEr?Z|p@cn%MVUd9ZDN73 zgkLffNHG+!0%>L-{+u`QOcFN>14EH(kyyBExY%TKMma|I$zhBt+MFdBMX8A?d8N6x zxS-6$+*BAlC$qSum>p<@nwo;b;f#2o=hs|f8G6qeK$!bhK5>RV0^U{kzCah#A5(H93{FCQ1iOY)tnID)L a85!>~Xx?Q|y~|+ym_gtR3qPYRSQP-2mp}Oc diff --git a/core/server/__pycache__/dispatchstate.cpython-314.pyc b/core/server/__pycache__/dispatchstate.cpython-314.pyc index 70708a9aa78d834a0ed63affdd9a9bd88f229d14..d2f6b325f30fb9168d9ca937cccdb2dd2e5fb72a 100644 GIT binary patch delta 77 zcmX@j`HYiSn~#@^0SHnipUj%MkvE$~K|VRZC{-`DA~m_RBr`uxFDElCHMuf5Cp9-Q eFEKr}XmTx!t)T5E78XV)#xFc_jIu?%K>Yx-;}=W- delta 50 zcmaFHd76_~n~#@^0SIdBPG;3@iIY!wcUZ5fX DORo$A diff --git a/core/server/__pycache__/server.cpython-314.pyc b/core/server/__pycache__/server.cpython-314.pyc index 1060bc383c810e911fad3edb4067f13cde0c1b93..664b11cf93567516a02ae74689cd25f00b2fabc3 100644 GIT binary patch literal 1610 zcmah}%}*Og6rZ(sy=MIpgZU6eV4R?~mLW!oi&E4Wp#}mW1b0F1#RP432Uu$Fy0Zf$ zoSdpsoLp#gA!#FpBaw3Gv6ubd~c^)g;pIdoQ<_nY@-fA4E% zlHrg9==kC7uWP?}0r=Biu;DugXB7&{;4YB4X@DKcVXnURU{76ovG*<~d#3p*0Shre zv3J@xC1NoK7X5Ls=*hM*T32Q}T+EQn%R<`YtkRq#aX|KU0UVUMOCTZsWh?I_IC4SL zt&)P(RT+N04lPVop?m9kL6f0XG7Sro!2E=qn~;~XbMk`z=`8?MhtQb?DrnB&Y=rtN zgM7o5Z6FuKo9*ZExmM6@<(u^mW*L=04rImm?J~&wnf9uOzZ9vpt&@BuN-B{^2jsB8}aQ{}vxT?Yuwsop$ z7*NGJJ)b&=0I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cc7ea..5a882c8 100644 --- a/core/server/createdispatch.py +++ b/core/server/createdispatch.py @@ -1,5 +1,5 @@ import importlib -from lifecyclemanager import manageLifecycle +from core.execution.lifecyclemanager import manageLifecycle from .dispatchstate import buildState def buildDispatch(request): diff --git a/core/server/createresponse.py b/core/server/createresponse.py new file mode 100644 index 0000000..c080cdc --- /dev/null +++ b/core/server/createresponse.py @@ -0,0 +1,14 @@ +import json + +def buildResponse(module, thread, mode): + + response = { + "status": "success", + "message": f"{module.name} dispatched", + "thread": f"{thread}", + "mode": f"{mode}", + } + + #responsedata = json.dumps(response).encode("utf-8") + + return response diff --git a/core/server/dispatcher.py b/core/server/dispatcher.py index e742605..927cc99 100644 --- a/core/server/dispatcher.py +++ b/core/server/dispatcher.py @@ -1,6 +1,7 @@ from .createdispatch import buildDispatch from .dispatchstate import buildState from core.execution.createthread import buildThread +from .createresponse import buildResponse import threading @@ -14,9 +15,6 @@ def dispatchRequest(request, lifecycles): return lifecycles else: - threadnum, threadname, lifecycles, threadlist = buildThread(module, lifecycles) + thread, lifecycles = buildThread(module, lifecycles) - #print("Active Threads") - #print(threadlist) - - return threadnum, threadname, lifecycles, threadlist + return thread, lifecycles, module, mode diff --git a/core/server/dispatchstate.py b/core/server/dispatchstate.py index 4977710..96d45d0 100644 --- a/core/server/dispatchstate.py +++ b/core/server/dispatchstate.py @@ -1,6 +1,6 @@ import requests -from core import registerLifecycle +from core.execution.lifecyclemanager import registerLifecycle def filterMode(mode): if mode in ("continuous", "oneshot", "stop"): diff --git a/core/server/server.py b/core/server/server.py index 700cc55..d7ce386 100644 --- a/core/server/server.py +++ b/core/server/server.py @@ -1,19 +1,25 @@ import socket import json +import os +import logging + +from .dispatcher import dispatchRequest +from .createresponse import buildResponse + +port = int(os.environ.get("SERVER_PORT", 19001)) def startServer(): - from .dispatcher import dispatchRequest - server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server.bind(("127.0.0.1", 19002)) + server.bind(("0.0.0.0", port)) lifecycles = {} server.listen() - + logging.info(f"Server listening on port {port}") while True: connection, address = server.accept() + logging.info("Accepting connections") while True: data = connection.recv(4096) @@ -23,7 +29,13 @@ def startServer(): # if not data: # break - dispatch = dispatchRequest(request, lifecycles) + thread, lifecycles, module, mode = dispatchRequest(request, lifecycles) + + response = buildResponse(module, thread, mode) + + connection.sendall( + json.dumps(response).encode("utf-8"), + ) connection.close() diff --git a/initialize.py b/initialize.py index cb33b6a..5336a91 100644 --- a/initialize.py +++ b/initialize.py @@ -1,3 +1,5 @@ from core.server.server import startServer +import login +#login startServer() diff --git a/plugins/rmass/actions/__pycache__/checkavailable.cpython-314.pyc b/plugins/rmass/actions/__pycache__/checkavailable.cpython-314.pyc index b9b9da0d7ef99e0c2bd6dc8dfef5e94b0c5de3c8..222438bcdb742dd2932579589c28be1e291c3a57 100644 GIT binary patch delta 158 zcmcc4(#y)L&Bx2d00iE_C$sKM^@ddF4 z@dvT#GnH_}a_TVv#khh5lo>PyCzfRhGiMYPSMio5=47UXrGxBp&^-~hdGE?+R^0QO( kiuJOJ^YbP@XI#yt1k}R_#KpTO&tcllq1wbzqyXds06GpC0ssI2 diff --git a/plugins/rmass/actions/__pycache__/refresh_tokens.cpython-314.pyc b/plugins/rmass/actions/__pycache__/refresh_tokens.cpython-314.pyc index c04658f3b359255c9a1d02f22d75162cbc4fb8bb..0825c4e9693bdac15d463555f02054a835aa0bf4 100644 GIT binary patch delta 393 zcmY*TO-lk%6n*#2IHU9B2N4lPhAxuSS?4kkltAO=D$o!c&D0r~d9-MgtDsfMEcyd& z`vcLgUAS%YB691lZM&Y~qVD2c&f%PM?~5{5tX<30h#2+h^*k?4thK8L!N#No2vt%6 z1{KQa7HJWrRf$O`F&SkR!3a}OVJfODicyTAhB_KHwSmRZ6x^}_;|tven=%b8)QXhp z%WX8J!}Z18|AUGA@gJF4!fuM{q^O8D6HRE+;^IUSX@=xda}e3V|k{= f!+TnQm2gV;O@kQLZRw_TH+s{vVM;2<+amJ=T<%Jxjx25Pt7Xnx<(!+NE}|R#3qr&Fkpkeu>U~clpfr3_uO;O!L5u}!#!~wi>WyMew+O8h1-726`QjgK)7TBAQ*7s zU51=A)JR92Dp(-{4XmPxHM9g5Kvk@hiME+Nd{tJ6Wi$Ary rY6Vng&kEKW0DQ9DuWGA!;eFF(c4uy_jbgkyn!O)I{~&BC&!&;(Cm+LV67POeMlWjLHm}5*uIW zGcvnricFSds#m$i;hkFPT2z!@bc-{jvLF@0b%7 delta 71 zcmey*zMY*{n~#@^0SJ1yk7sS2$ScXXXQKLUwjf4j22Jse-}D)oGzBMXFx5{!&E(Ie W3RK4k#Krq2t1$0pZ(=J_2J!%r`w>0> diff --git a/plugins/rmass/actions/checkavailable.py b/plugins/rmass/actions/checkavailable.py index 2b6e47f..4646511 100644 --- a/plugins/rmass/actions/checkavailable.py +++ b/plugins/rmass/actions/checkavailable.py @@ -13,6 +13,10 @@ outputs = { "validTo": "validTo", } +conversion = { + "hrs": "validTo // 60", +} + headers = { "Authorization": { "output": "access_token", diff --git a/plugins/rmass/actions/login.py b/plugins/rmass/actions/login.py index b27da35..025ca3e 100644 --- a/plugins/rmass/actions/login.py +++ b/plugins/rmass/actions/login.py @@ -44,4 +44,4 @@ savedata = [ "refresh_token", ] -savepath = "/home/david/tokens.json" +savepath = os.environ["TOKEN_STORE"] diff --git a/plugins/rmass/actions/refresh_tokens.py b/plugins/rmass/actions/refresh_tokens.py index fca4ce6..8158305 100644 --- a/plugins/rmass/actions/refresh_tokens.py +++ b/plugins/rmass/actions/refresh_tokens.py @@ -1,7 +1,10 @@ from . import getcsrf, login +import os name = "Token refresh" +kind = "action" + showstatus = True method = "GET" @@ -15,7 +18,7 @@ headers = { }, } -domainname="rentmasseur.com" +#domainname="rentmasseur.com" cookies = { "accessToken": { @@ -36,7 +39,8 @@ savedata = [ "refresh_token", ] -savepath = "/home/david/tokens.json" +#savepath = "/rmmanager/tokens.json" +savepath = os.environ["TOKEN_STORE"] outputs = { "access_token": "accessToken", diff --git a/plugins/rmass/actions/setavailable.py b/plugins/rmass/actions/setavailable.py index a081abe..94a3f33 100644 --- a/plugins/rmass/actions/setavailable.py +++ b/plugins/rmass/actions/setavailable.py @@ -45,3 +45,8 @@ outputs = { prints = { "Available until": "available_until" } + +recoverPolicy = { + KeyError:[False], + TypeError: [], +} diff --git a/plugins/rmass/operations/__pycache__/login.cpython-314.pyc b/plugins/rmass/operations/__pycache__/login.cpython-314.pyc index e3130a966936f7e1ba5613df5fa6d970c1401c2a..d543ed80e7dfdf24798ef721e721cf789a25af35 100644 GIT binary patch delta 20 acmdnQw26sZn~#@^0SG1^I<=8ooe=;pnFPlG delta 20 acmdnQw26sZn~#@^0SLD89N);T&IkZ3Gz2gJ diff --git a/plugins/rmass/operations/__pycache__/setavailable.cpython-314.pyc b/plugins/rmass/operations/__pycache__/setavailable.cpython-314.pyc index f6c08b2ba36be8876710f3b7476ad31e090403de..28a66e3d6ae288f96bcea5dc33e3736300a73c7f 100644 GIT binary patch delta 106 zcmZ3(vWkUQn~#@^0SMdc$015&fzW@LL delta 108 zcmZ3*vWA6Mn~#@^0SNB>J&~0^k=Iu$j;n+-mN|$eh&6~Uh&_lSh*O_gpRt51h-+fW zQ%TO^oYd5UlFZ!HTO7sNnFYlqsRg%Kit=+N7cs^#hE6`usLjE{z{}sj`GIZnZ$@SI KCYB;Gpz#22!ye%P diff --git a/plugins/rmass/operations/setavailable.py b/plugins/rmass/operations/setavailable.py index 3d23329..511d059 100644 --- a/plugins/rmass/operations/setavailable.py +++ b/plugins/rmass/operations/setavailable.py @@ -10,7 +10,7 @@ actions = [ setavailable, ] -sleeptime = 10 +#sleeptime = 10 skipstep = { setavailable: { @@ -21,3 +21,5 @@ skipstep = { } role = "activate" + +sleeptime = 180 diff --git a/tokens.json b/tokens.json new file mode 100644 index 0000000..4d2c043 --- /dev/null +++ b/tokens.json @@ -0,0 +1 @@ +{"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTE2NzQzMzAsIm5iZiI6MTc5MTY3NDE1MCwic3ViIjoiMjM4MzAyIiwidXNlcm5hbWUiOiJYeHhvdGlxIiwidXNlclR5cGUiOjEsInN0YWdlTmFtZSI6Ilh4eG90aXEiLCJhcHByb3ZlZCI6MSwibG9jYXRpb25JZCI6NDcyLCJzZWFyY2hDaXR5IjoiYXRsYW50YSIsImNvdW50cnlTaG9ydCI6IlVTIiwic2Vzc2lvbkNvdW50cnlDb250aW5lbnQiOiJOQSIsImlzRnJvemVuIjowLCJsb2NhdGlvbkxhYmVsIjoiQXRsYW50YSwgR0EiLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTY3NDIxMH0.HcqR4crgZkqdaSKpY3EiC8aejvlgQppKZbV_El8MeCPzoRSHssJcDtj5dmDXjP3VhjseIbgPvCqDxKC2jb3Qdg", "refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3OTQyNjYyMTAsIm5iZiI6MTc5MTY3NDE1MCwianRpIjoiZTJRY3FUYnNBSjRpZWNSQ0JEWUdXY2pvYkxDREkrS05mRUwzQUU1OEk3az0iLCJpc3MiOiJodHRwczovL3JlbnRtYXNzZXVyLmNvbSIsImlhdCI6MTc5MTY3NDIxMCwic3ViIjoiMjM4MzAyIn0.ExbPr-h99AVPpB0RTZs_3h15rY1clue95tGb0Cq0qrqkhaWloB8G6v7vmCFqJcpVyW1YHLrw45zOjPv9uZ25oA"} \ No newline at end of file