1
+ import requests
2
+ from osbot_utils .type_safe .Type_Safe import Type_Safe
3
+ from osbot_utils .utils .Dev import pprint
4
+ from osbot_aws .apis .shell .Shell_Client import Shell_Client
5
+
6
+ class Http__Remote_Shell (Type_Safe , Shell_Client ):
7
+ target_url : str = None
8
+
9
+ def _invoke (self , method_name , method_kwargs = None , return_logs = False ):
10
+ auth_key = self ._lambda_auth_key ()
11
+
12
+ payload = {'lambda_shell' : {'method_name' : method_name ,
13
+ 'method_kwargs' : method_kwargs ,
14
+ 'auth_key' : auth_key }}
15
+ response = requests .post (self .target_url , json = payload )
16
+ if response .headers .get ('Content-Type' ) == 'application/json' :
17
+ return response .json ()
18
+ return response .text .strip ()
19
+
20
+ def exec_print (self , executable , * params ):
21
+ result = self .exec (executable , params )
22
+ pprint (result )
23
+ return result
24
+
25
+ def function (self , function ):
26
+ return self .python_exec_function (function )
27
+
28
+ def function__print (self ,function ):
29
+ result = self .function (function )
30
+ pprint (result )
31
+ return result
32
+
33
+ # helper execution methods
34
+
35
+ def env_vars (self ):
36
+ def return_dict_environ ():
37
+ from os import environ
38
+ return dict (environ )
39
+ return self .function (return_dict_environ )
0 commit comments