align Py SDK with permission model

This commit is contained in:
Kenneth Bingham
2024-03-11 15:36:24 -04:00
parent de1ebdc333
commit e6fc45b2ce
4 changed files with 33 additions and 33 deletions

View File

@ -12,14 +12,16 @@ import threading
exit_signal = threading.Event()
def signal_handler(signum, frame):
print("\nCtrl-C detected. Next connection will close server")
exit_signal.set()
class copyto:
def handle(self, *args, **kwargs):
root = zrok.environment.root.Load()
try:
shr = zrok.share.CreateShare(root=root, request=ShareRequest(
BackendMode=zrok.model.TCP_TUNNEL_BACKEND_MODE,
@ -48,7 +50,6 @@ class copyto:
conn.sendall(data.encode('utf-8'))
print("Server stopped.")
def loadData(self):
if not os.isatty(sys.stdin.fileno()):
@ -56,6 +57,7 @@ class copyto:
else:
raise Exception("'copyto' requires input from stdin; direct your paste buffer into stdin")
def pastefrom(options):
root = zrok.environment.root.Load()
@ -66,7 +68,7 @@ def pastefrom(options):
except Exception as e:
print("unable to create access", e)
sys.exit(1)
def removeAccess():
try:
zrok.access.DeleteAccess(root, acc)
@ -79,6 +81,7 @@ def pastefrom(options):
data = client.recv(1024)
print(data.decode('utf-8'))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()