Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan committed Jan 7, 2024
1 parent 3955f2b commit 8563a65
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions upsonic/remote/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 8563a65

Please sign in to comment.