diff --git a/call-control b/call-control index 118021e..e44e449 100644 --- a/call-control +++ b/call-control @@ -1,128 +1,122 @@ #!/usr/bin/env python # Copyright (C) 2005-2009 AG Projects. See LICENSE for details. # """Implementation of a call controller for OpenSIPS.""" def send_command(command, **kwargs): import socket import select sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect('%s/socket' % process.runtime_directory) sock.sendall('%s\r\n' % command + '\r\n'.join(['%s: %s' % (key, value) for key, value in kwargs.items()]) + '\r\n\r\n') response = '' while True: data = sock.recv(4096) response += data if not data or data.endswith('\r\n\r\n'): break sock.close() for line in response.splitlines(): if line: print line if __name__ == '__main__': import sys from optparse import OptionParser from application.process import process, ProcessError from application import log import callcontrol - + name = 'call-control' fullname = 'SIP call-control' description = 'Implementation of call-control for SIP' config_directory = '/etc/callcontrol' runtime_directory = '/var/run/callcontrol' default_pid = "%s/%s.pid" % (runtime_directory, name) parser = OptionParser(version="%%prog %s" % callcontrol.__version__) parser.add_option("--no-fork", action="store_false", dest="fork", default=True, help="run the process in the foreground") parser.add_option("--pid", dest="pid_file", default='/var/run/callcontrol/call-control.pid', help="pid file (/var/run/callcontrol/call-control.pid)", metavar="FILE") parser.add_option("--debug", dest="debug", default=None, help="get information about a currently running call-control daemon", metavar="COMMAND") parser.add_option("--terminate", dest="terminate", default=None, help="terminate an on-going session", metavar="CALLID") (options, args) = parser.parse_args() - try: - callcontrol.dependencies.check() - except Exception, e: - log.fatal(str(e)) - sys.exit(1) - pid_file = options.pid_file process.system_config_directory = config_directory try: process.runtime_directory = runtime_directory except ProcessError, e: log.fatal(str(e)) sys.exit(1) if options.debug is not None and options.terminate is not None: log.error('cannot run with both --debug and --terminate options in the same time') sys.exit(1) if options.debug is not None: if options.debug == '': log.error('must specify debug command') sys.exit(1) try: send_command('debug', show=options.debug, **dict([arg.split('=',1) for arg in args if arg.find('=') >= 0])) except Exception, e: log.error('failed to complete debug command: %s' % e) sys.exit(1) else: sys.exit(0) if options.terminate is not None: if options.terminate == '': log.error('must specify callid to terminate') sys.exit(1) try: send_command('terminate', callid=options.terminate) except Exception, e: log.error('failed to terminate session: %s' % e) else: sys.exit(0) if options.fork: try: process.daemonize(pid_file) except ProcessError, e: log.fatal(str(e)) sys.exit(1) log.start_syslog(name) log.msg("Starting %s %s" % (fullname, callcontrol.__version__)) from callcontrol.controller import CallControlServer if not options.fork: from application.debug.memory import * try: cserver = CallControlServer() except Exception, e: log.error("failed to create SIP Call Control Server: %s" % e) log.err() sys.exit(1) try: cserver.run() except Exception, e: log.error("failed to start SIP Call Control Server: %s" % e) if not options.fork: memory_dump() diff --git a/callcontrol/__init__.py b/callcontrol/__init__.py index 7a8c531..a635aff 100644 --- a/callcontrol/__init__.py +++ b/callcontrol/__init__.py @@ -1,25 +1,10 @@ # Copyright (C) 2005-2010 AG-Projects. See LICENSE for details. # """SIP Callcontrol""" __version__ = "2.1.0" configuration_filename = 'config.ini' backup_calls_file = 'calls.dat' -package_requirements = {'python-application': '1.2.8'} - -try: - from application.dependency import ApplicationDependencies -except: - class DependencyError(Exception): pass - class ApplicationDependencies(object): - def __init__(self, *args, **kwargs): - pass - def check(self): - raise DependencyError("need python-application version %s or higher but it's not installed" % package_requirements['python-application']) - -dependencies = ApplicationDependencies(**package_requirements) - -