Esempio n. 1
0
 def printer_getall(self):
     msg = ServerRequest(cmd=self.com.printer.getall)
     resp = ServerResponse.decode(self.send(msg.encode()))
     if not resp.err:
         assert type(resp.val) == list
         return natsorted(resp.val)
     else:
         raise Exception(resp.errmsg)
Esempio n. 2
0
 def rate_getall(self):
     msg = ServerRequest(cmd=self.com.rate.getall)
     resp = ServerResponse.decode(self.send(msg.encode()))
     if not resp.err:
         assert type(resp.val) == list
         return natsorted([PrintRate.loadjson(r) for r in resp.val], key=lambda x: x.rateid)
     else:
         raise Exception(resp.errmsg)
Esempio n. 3
0
 def printer_delete(self, printer, auth_userid, auth_passwd):
     msg = ServerRequest(cmd=self.com.printer.delete)
     msg.args["printer"] = printer
     msg.args["auth_userid"] = auth_userid
     msg.args["auth_passwd"] = auth_passwd
     resp = ServerResponse.decode(self.send(msg.encode()))
     if resp.err:
         raise Exception(resp.errmsg)
Esempio n. 4
0
 def getUsers(self):
     msg = ServerRequest(cmd=self.com.user.getall)
     c_logger.debug("getUsers: Sending request to server...")
     resp = ServerResponse.decode(self.send(msg.encode()))
     if not resp.err:
         return resp.val
     else:
         raise Exception(resp.errmsg)
Esempio n. 5
0
 def rate_add(self, rateid, lengthrate, timerate, auth_userid, auth_passwd):
     msg = ServerRequest(cmd=self.com.rate.add)
     msg.args["rateid"] = rateid
     msg.args["lengthrate"] = lengthrate
     msg.args["timerate"] = timerate
     msg.args["auth_userid"] = auth_userid
     msg.args["auth_passwd"] = auth_passwd
     resp = ServerResponse.decode(self.send(msg.encode()))
     if resp.err:
         raise Exception(resp.errmsg)
Esempio n. 6
0
 def user_issuper(self, userid, passwd):
     c_logger.debug("issuper: Checking if '{}' is an elevated user.".format(userid))
     msg = ServerRequest(cmd=self.com.user.issuper)
     msg.args["userid"] = userid
     msg.args["passwd"] = passwd
     
     c_logger.debug("issuper: Sending request to server...")
     resp = ServerResponse.decode(self.send(msg.encode()))
     if not resp.err:
         c_logger.debug("issuper: Done.")
         return resp.val
     else:
         raise Exception(resp.errmsg)
Esempio n. 7
0
 def verifyUser(self, userid, passwd):
     c_logger.info("verifyUser: Verifying user credentials...")
     
     msg = ServerRequest(cmd=self.com.user.verify)
     msg.args["userid"] = userid
     msg.args["passwd"] = passwd
     
     c_logger.debug("verifyUser: Sending request to server...")
     resp = self.send(msg.encode())
     resp = ServerResponse.decode(resp)
     if not resp.err:
         return resp.val
     else:
         raise Exception(resp.errmsg)
Esempio n. 8
0
 def print_add(self, userid, passwd, length, duration, printer, rate, paidby="", note=""):
     msg = ServerRequest(cmd=self.com.print.add)
     msg.args["userid"] = userid
     msg.args["passwd"] = passwd
     msg.args["length"] = length
     msg.args["duration"] = duration
     msg.args["printer"] = printer
     msg.args["rate"] = rate
     if paidby:
         msg.args["paidby"] = paidby
     if note:
         msg.args["note"] = note
     
     resp = ServerResponse.decode(self.send(msg.encode()))
     if not resp.err:
         return resp.val
     else:
         raise Exception(resp.errmsg)