# -*- 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'):
Example #2
0
 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
Example #3
0
define("service_name", type=str, default="shadowsocks",
       help="shadowsocks's service name in supervisor")
define("cookie_secret", type=str, default=None,
       help="You must specify the cookie_secret option. It should be a long "
            "random sequence of bytes to be used as the HMAC secret for the "
            "signature. You can create this HMAC string with --hmac option.")
define("hmac", type=None, default=False, help="create a HMAC string")
define("make-config", type=None, default=False,
       help="create a shadowsocks-web config template")
define("make-shadowsocks-config", type=None, default=False,
       help="create a shadowsocks config template")
define("config", type=str, metavar="path", help="path to config file")
define("theme", type=str, default="default", help="name of theme")


if common.is_python2():
    PermissionError = IOError


class BaseHandler(tornado.web.RequestHandler):

    def initialize(self):
        # make the variable name shorter
        self.user = self.application.settings["user"]

    @property
    def config(self):
        """Make the variable name shorter."""
        return self.application.config

    @property
Example #4
0
# -*- 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.')
Example #5
0
 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
Example #6
0
       help="You must specify the cookie_secret option. It should be a long "
       "random sequence of bytes to be used as the HMAC secret for the "
       "signature. You can create this HMAC string with --hmac option.")
define("hmac", type=None, default=False, help="create a HMAC string")
define("make-config",
       type=None,
       default=False,
       help="create a shadowsocks-web config template")
define("make-shadowsocks-config",
       type=None,
       default=False,
       help="create a shadowsocks config template")
define("config", type=str, metavar="path", help="path to config file")
define("theme", type=str, default="default", help="name of theme")

if common.is_python2():
    PermissionError = IOError


class BaseHandler(tornado.web.RequestHandler):
    def initialize(self):
        # make the variable name shorter
        self.user = self.application.settings["user"]

    @property
    def config(self):
        """Make the variable name shorter."""
        return self.application.config

    @property
    def config_filename(self):