Esempio n. 1
0
 def addTask(self, request, context):
     logging.info(f"adding task {request.description}")
     # TODO: implement this!
     index = len(self.tasks.tasks)
     self.tasks.tasks.append(
         task_pb2.Task(id=index, description=request.description))
     return task_pb2.Id(id=index)
 def addTask(self, request, context):
     logging.info(f"adding task {request.description}")
     # TODO: implement this!
     count = len(self.tasks.tasks) + 1
     newtask = task_pb2.Task(id=count, description=request.description)
     self.tasks.tasks.append(newtask)
     print(f"adding task {newtask.id}")
     return task_pb2.Id(id=count)
Esempio n. 3
0
def guiDelete():
    logging.basicConfig(level=logging.DEBUG)
    with grpc.insecure_channel("localhost:50051") as channel:
        stub = task_pb2_grpc.TaskapiStub(channel)
        i = int(e2.get())
        response = stub.delTask(task_pb2.Id(id=i))
        response1 = stub.listTasks(task_pb2.Empty())
        l3.configure(text=str(f"Task list \n{response1.tasks}"))
Esempio n. 4
0
    def addClient(self, request, context):
        logging.info(f"adding client {request.noOfTanks}")

        length = len(self.clientlist.clients)
        newClient = task_pb2.Client(id=length,
                                    fName=request.fName,
                                    lName=request.lName,
                                    noOfTanks=request.noOfTanks)
        self.clientlist.clients.append(newClient)
        print("{} is added with {} tanks.".format(request.fName,
                                                  request.noOfTanks))
        print("\n")
        return task_pb2.Id(id=length)
Esempio n. 5
0
 def addTask(self, request, context):
     logging.info(f"adding task {request.description}")
     # TODO: implement this!
     # print(type(self.tasks.tasks))
     # response = len(self.tasks.tasks)
     # print("fwsfe",response)
     response = task_pb2.Id()
     response.id = len(self.tasks.tasks)
     temp = task_pb2.Task()
     temp.id = response.id
     temp.description = request.description
     self.tasks.tasks.append(temp)
     return response
Esempio n. 6
0
    def addTask(self, request, context):
        # TODO: implement this!
        index = len(self.tasks.tasks)
        print(
            "added id: ",
            index,
        )
        if (index == 0):
            tempTask = task_pb2.Task(id=index, description=request.description)
        else:
            tempid = self.tasks.tasks[index - 1].id + 1
            tempTask = task_pb2.Task(id=tempid,
                                     description=request.description)

        self.tasks.tasks.append(tempTask)
        return task_pb2.Id(id=tempTask.id)
    def addTask(self, request, context):
        logging.info(f"adding task {request.description}")
        # TODO: implement this!

        # get the length of tasks
        length = len(self.Tasks.tasks)

        #decide the index according to the length of tasks
        if (length == 0):
            adding_task = task_pb2.Task(id=length,
                                        description=request.description)
        else:
            #append the task with the id and recieved description
            adding_id = self.Tasks.tasks[length - 1].id + 1
            adding_task = task_pb2.Task(id=adding_id,
                                        description=request.description)

        self.Tasks.tasks.append(adding_task)
        #return id
        return task_pb2.Id(id=adding_task.id)
def test_del(stub, task_ids) -> None:
    print("Deleting Clients\n")
    for i in task_ids:
        stub.delClient(task_pb2.Id(id=i))
Esempio n. 9
0
def test_del(stub, task_ids):
    for i in task_ids:
        response = stub.delTask(task_pb2.Id(id=i))
Esempio n. 10
0
def test_del(stub, task_ids) -> None:
    for i in task_ids:
        stub.delTask(task_pb2.Id(id=i))