added a webserver to linspector to play a bit building an interface to the joblist. needs tornado via pip installed. totally ugly code but it's just playing around.
This commit is contained in:
parent
360e1d68d0
commit
07c72dc86b
1 changed files with 26 additions and 0 deletions
26
linspector
26
linspector
|
|
@ -13,6 +13,9 @@ from lib.config.parser import FullConfigParser
|
|||
from apscheduler.scheduler import Scheduler
|
||||
from lib.core.job import JobInfo
|
||||
|
||||
import tornado.ioloop
|
||||
import tornado.web
|
||||
|
||||
|
||||
def parseArgs():
|
||||
parser = argparse.ArgumentParser(
|
||||
|
|
@ -47,6 +50,21 @@ def handleJob(jobInfo):
|
|||
jobInfo.handle_call()
|
||||
|
||||
|
||||
class MainHandler(tornado.web.RequestHandler):
|
||||
def get(self):
|
||||
self.write("Linspector: (<a href='/jobs'>jobs</a>)")
|
||||
|
||||
|
||||
class JoblistHandler(tornado.web.RequestHandler):
|
||||
def initialize(self, jobs):
|
||||
self.jobs = jobs
|
||||
|
||||
def get(self):
|
||||
self.write("Linspector Job List:<br/>")
|
||||
for job in self.jobs:
|
||||
self.write("JOB<br/>")
|
||||
|
||||
|
||||
def main():
|
||||
args = parseArgs()
|
||||
log = Logger(args.logfile, args.loglevel)
|
||||
|
|
@ -73,6 +91,14 @@ def main():
|
|||
jobInfo.set_logger(log)
|
||||
jobs.append(jobInfo)
|
||||
|
||||
application = tornado.web.Application([
|
||||
(r"/", MainHandler),
|
||||
(r"/jobs", JoblistHandler, dict(jobs=scheduler.get_jobs()))
|
||||
])
|
||||
|
||||
application.listen(8888)
|
||||
tornado.ioloop.IOLoop.instance().start()
|
||||
|
||||
while True:
|
||||
#Todo: implement user handle
|
||||
time.sleep(10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue