diff --git a/bin/jsonrpc-client b/bin/jsonrpc-client index 8ffab08..8554ac4 100755 --- a/bin/jsonrpc-client +++ b/bin/jsonrpc-client @@ -30,3 +30,5 @@ print c.call.get_job_list() print c.call.get_job_info_by_id("3950d44b") print c.call.set_job_enabled("3950d44b", False) + +print c.call.get_job_count() diff --git a/linspector/backends/jsonrpc.py b/linspector/backends/jsonrpc.py index e04a39a..68bc0c0 100644 --- a/linspector/backends/jsonrpc.py +++ b/linspector/backends/jsonrpc.py @@ -60,6 +60,10 @@ class ServerHandler(BaseHandler): job_list = ServerHandler.interface.get_job_list() return json.dumps(job_list, ensure_ascii=False) + def get_job_count(self): + job_count = ServerHandler.interface.get_job_count() + return json.dumps(job_count, ensure_ascii=False) + def get_job_info_by_id(self, job_hex): job = ServerHandler.interface.find_job_by_hex_string(job_hex) job_dict = ServerHandler.interface.get_job_info_dict(job) diff --git a/linspector/core/interface.py b/linspector/core/interface.py index 826979d..0b5e604 100644 --- a/linspector/core/interface.py +++ b/linspector/core/interface.py @@ -67,6 +67,10 @@ class LinspectorInterface(object): job_list.append(d) return job_list + def get_job_count(self): + count = len(self.jobs) + return count + def get_enabled_layouts(self): self._config.get_enabled_layouts() diff --git a/linspector/frontends/lish.py b/linspector/frontends/lish.py index 3ed1c5e..fe3802c 100644 --- a/linspector/frontends/lish.py +++ b/linspector/frontends/lish.py @@ -176,6 +176,8 @@ class LishCommander(Exit): PURPLE + " Service" + END + ": " + job_dict["Service"] + \ PURPLE + " Next run" + END + ": " + job_dict["Next run"] + \ PURPLE + " Enabled" + END + ": " + job_dict["Enabled"] + elif text == "count": + print GREEN + "Job Count" + END + ":\t" + str(self.interface.get_job_count()) else: self.print_color(RED, "Invalid or missing parameter") self.help_jobs()