From 8563a65ef69594392687a9438ea06b88c29ae734 Mon Sep 17 00:00:00 2001 From: Onur Atakan ULUSOY Date: Sun, 7 Jan 2024 23:01:00 +0300 Subject: [PATCH] Fix --- upsonic/remote/controller.py | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/upsonic/remote/controller.py b/upsonic/remote/controller.py index f32acc1..9b56515 100644 --- a/upsonic/remote/controller.py +++ b/upsonic/remote/controller.py @@ -19,7 +19,7 @@ import textwrap class Upsonic_Remote: - prevent_enable = False + prevent_enable = True quiet_startup = False def _log(self, message): if not self.quiet: @@ -156,10 +156,60 @@ def enable(self, encryption_key="a", the_globals={}): key = key.split(".") message = value + + if inspect.isfunction(message): + # Create a function that will call the self.get(original_key, encryption_key=encryption_key) function and return the result + the_function = f""" +def function(*args, **kwargs): + return the_us.get('{original_key}', encryption_key='{encryption_key}')(*args, **kwargs) +message = function +""" + print(the_function) + ldict = {} + exec(the_function, globals(), ldict) + message = ldict["message"] + + + if inspect.isclass(message): + # Create a class and + + the_class = f""" +class the_class: + pass +message = the_class +""" + + + + from upsonic import interface setattr(interface, key[-1], copy.copy(message)) the_keys[key[-1]] = copy.copy(message) - + + if inspect.isclass(message): + for name, obj in inspect.getmembers(value): + if name == "__class__" or name == "__dict__": + continue + if inspect.isfunction(obj): + the_function = f""" +def function(*args, **kwargs): + print("somethink happeded") + the_data = the_us.get('{original_key}', encryption_key='{encryption_key}') + print("end") + print(the_data.{name}(*args, **kwargs)) + return the_data.{name}(*args, **kwargs) + + +message = function + """ + + ldict = {} + exec(the_function, globals(), ldict) + obj = ldict["message"] + print(name, obj) + setattr(the_keys[key[-1]], name, obj) + + except: import traceback traceback.print_exc() @@ -575,6 +625,8 @@ def get(self, key, encryption_key="a", no_cache=False, version_tag=None, no_vers try: response = self.decrypt(encryption_key, response, cloud=self, name=key) except: + import traceback + traceback.print_exc() pass return response else: