Пример #1
0
 def __init__(self,
              host=None,
              port=0,
              user=None,
              pipe=None,
              mailbox=None,
              home=None):
     if not home:
         self.home = ave.config.load_etc()['home']
     else:
         self.home = home
     # load the default configuration file
     config = ave.gerrit.config.load(self.home)
     # override configuration file entries
     if host is not None:
         config['host'] = host
     if port != 0:
         config['port'] = port
     if user is not None:
         config['user'] = user
     if pipe and type(pipe) != Pipe:
         raise Exception('pipe must be an ave.networking.pipe.Pipe')
     if mailbox and (type(mailbox) != tuple or len(mailbox) != 2):
         raise Exception('mailbox must be a (host,port) tuple')
     # validate the final configuration
     ave.gerrit.config.validate(config)
     self.config = config
     self.pipe = pipe
     if mailbox:
         self.mailbox = RemoteControl(mailbox, None, None)
     # superclass initialization
     Process.__init__(self,
                      target=self._run,
                      proc_name='ave-gerrit-event-stream')
Пример #2
0
    def __init__(self, pid_path, log_file, stdin=None,stdout=None,stderr=None):
        if not stdin:
            stdin = open('/dev/null', 'r')
        if not stdout:
            stdout = open('/dev/null', 'a+')
        if not stderr:
            stderr = open('/dev/null', 'a+', 0)

        if type(pid_path) not in [str, unicode]:
            raise Exception(
                'pid_path is not a string: %s' % type(pid_path).__name__
            )
        if type(log_file) != file:
            raise Exception(
                'log_file is not a file: %s' % type(log_file).__name__
            )
        if type(stdin) != file:
            raise Exception('stdin is not a file: %s' % type(stdin).__name__)
        if type(stdout) != file:
            raise Exception('stdout is not a file: %s' % type(stdout).__name__)
        if type(stderr) != file:
            raise Exception('stderr is not a file: %s' % type(stderr).__name__)

        self.pid_path = pid_path
        self.log_file = log_file
        self.stdin    = stdin
        self.stdout   = stdout
        self.stderr   = stderr

        Process.__init__(self, target=self.run, args=None, logging=True)
Пример #3
0
 def __init__(self,
              port,
              authkey=None,
              socket=None,
              alt_keys={},
              interval=None,
              home=None,
              proc_name=None,
              logging=False):
     if (not socket) and (type(port) != int or port < 1):
         raise Exception('client port must be integer >= 1')
     # authkey is used in hmac computation, which doesn't understand unicode
     if authkey and type(authkey) != str:
         raise Exception('authkey must be a regular string')
     Process.__init__(self, self.run, (), logging, proc_name)
     self.socket = socket
     self.port = port  # listening port for all connections
     self.fds = {}
     if type(authkey) not in [str, types.NoneType]:
         raise Exception('authkey must be a regular string or None')
     self.keys = {0: authkey}  # primary authentication key (may be None)
     if alt_keys:
         if type(alt_keys) != dict:
             raise Exception('alt_keys must be a dictionary')
         for k in alt_keys:
             if type(alt_keys[k]) not in [str, types.NoneType]:
                 raise Exception('alt keys must be regular strings or None')
             self.keys[k] = alt_keys[k]
     if type(interval) not in [int, float, types.NoneType]:
         raise Exception(
             'the interval (seconds) must be expressed as in integer, a '
             'float, or None')
     if not home:
         home = ave.config.load_etc()['home']
     self.home = home
     self.interval = to_milliseconds(interval)
     self.unpend = []  # fd's to ignore in pending events handling
     self.rejecting = False
     self.accepting = []  # connections
     self.authenticating = {}  # connection -> salt
     self.established = {}  # connection -> authkey or None
     self.keepwatching = {}
     self.listener = None
     self.outgoing = {}  # connection -> message
     self.buf_sizes = (1024 * 16, 1024 * 16)  # setsockopt() parameters
     self.deferred_joins = None
Пример #4
0
 def __init__(self, guid, json_data, home, logging):
     Process.__init__(
         self, self.run, (guid, json_data, home), logging,
         'ave-panotti-shouter'
     )
Пример #5
0
 def __init__(self, home, logging, profiles, timeout):
     self.home     = home
     self.profiles = profiles
     self.timeout  = timeout
     Process.__init__(self, None, None, logging, 'ave-relay-reporter')