def DeleteTasks(name, group, token): con = Connection(Get_Server_Ip(), 8080) con.Send(f'D/{name}/{group}/{token}') code = con.WaitUntilRecv(format_incoming=RemoveNullTerminator) error = TokenErrorHandler(code) if error: return con.Send('Ready') con.Close()
def GetTasks(name, token, group): con = Connection(Get_Server_Ip(), 8080) con.Send(f'R/{name}/{group}/{token}') code = con.WaitUntilRecv(format_incoming=RemoveNullTerminator) error = TokenErrorHandler(code) if error: return con.Send('Ready') updated_items = con.RecvList('GO', 'END') con.Close() return updated_items
def RenameGroup(name, token, group, newname): con = Connection(Get_Server_Ip(), 8080) con.Send(f'N/{name}/{group}/{token}') code = con.WaitUntilRecv(format_incoming=RemoveNullTerminator) error = TokenErrorHandler(code) if error: return con.Send('Ready') con.WaitUntilRecv(format_incoming=RemoveNullTerminator) con.Send(newname) con.Close()
def GetGroups(name, token): con = Connection(Get_Server_Ip(), 8080) con.Send(f'G/{name}/NULL/{token}') code = con.WaitUntilRecv(format_incoming=RemoveNullTerminator) error = TokenErrorHandler(code) if error: return con.Send('Ready') groups = con.RecvList('GO', 'END') con.Close() return groups
def Login(username, password): # TODO: Add formatting error checks con = Connection(Get_Server_Ip(), 8080) con.Send(f'A/L/{username}/{password}') d = con.WaitUntilRecv() con.Close() code = str(d).split("/")[0] try: token = str(d).split("/")[1] return f'{code}/{token}' except IndexError: return code
def PushTasks(name, token, group, item, pos): if not len(item) == 0: items = ItemtoText(item) items = items.split('\n') else: items = ["NONE"] items.insert(0, str(pos)) con = Connection(Get_Server_Ip(), 8080) con.Send(f'W/{name}/{group}/{token}') code = con.WaitUntilRecv(format_incoming=RemoveNullTerminator) error = TokenErrorHandler(code) if error: return con.Send('Ready') con.SendList('GO', 'END', items, from_cpp=True) con.Close()
import os import sys from BLib.Network.Connection import Connection from manage import main if (not os.path.exists("Server.config")): print("No Server Config File Detected, Entering Setup") server_ip = input("Please enter the IP address of the main server: ") try: con = Connection(server_ip, 8080) con.Send("T/Hello") response = con.WaitUntilRecv() con.Close() except ConnectionError: print("Error: Server did not respond") sys.exit() if (not response == "Hello"): print("Error: Server did not respond correctly") sys.exit() print("Succesfully Contacted Server, saving settings now") f = open("Server.config", 'w+') f.write(server_ip) f.close() print("Wrote settings to file, starting the server") main() else: try: f = open("Server.config", 'r') server_ip = f.read() f.close() con = Connection(server_ip, 8080)