# -*- coding: utf-8 -*- import os import datetime from common import is_python2, is_python3 import socket if is_python2(): from httplib import HTTPConnection from xmlrpclib import Transport, ServerProxy, Fault elif is_python3(): from http.client import HTTPConnection from xmlrpc.client import Transport, ServerProxy, Fault class SupervisorController(object): def __init__(self, servicename): class UnixStreamHTTPConnection(HTTPConnection): def connect(self): self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sock.connect(self.host) class UnixStreamTransport(Transport, object): def __init__(self, socket_path): self.socket_path = socket_path super(UnixStreamTransport, self).__init__() def make_connection(self, host): return UnixStreamHTTPConnection(self.socket_path) if not os.path.exists('/var/run/supervisor.sock'):
# -*- coding: utf-8 -*- import os import datetime from common import is_python2, is_python3 import socket if is_python2(): from httplib import HTTPConnection from xmlrpclib import Transport, ServerProxy, Fault elif is_python3(): from http.client import HTTPConnection from xmlrpc.client import Transport, ServerProxy, Fault class SupervisorController(object): def __init__(self, servicename): class UnixStreamHTTPConnection(HTTPConnection): def connect(self): self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sock.connect(self.host) class UnixStreamTransport(Transport, object): def __init__(self, socket_path): self.socket_path = socket_path super(UnixStreamTransport, self).__init__() def make_connection(self, host): return UnixStreamHTTPConnection(self.socket_path) if not os.path.exists('/var/run/supervisor.sock'): raise RuntimeError('supervisor is not running.')
def get(self): if common.is_python3() or common.is_python2(): msg = SupervisorController(self.svservname).get_info() self.render("dashboard.html", msg=msg) else: raise NotImplementedError