Permalink
Browse files

Add copyright notice to all source files

  • Loading branch information...
1 parent 9179f62 commit 3ca27708bf9b367dc564d80ae0770fb273d26442 bevenky committed Apr 27, 2011
Showing with 124 additions and 75 deletions.
  1. +2 −1 src/examples/freeswitch/inbound/inbound_api.py
  2. +2 −1 src/examples/freeswitch/inbound/inbound_api_notfound.py
  3. +6 −5 src/examples/freeswitch/inbound/inbound_autoreconnect.py
  4. +2 −1 src/examples/freeswitch/inbound/inbound_bgapi.py
  5. +2 −1 src/examples/freeswitch/inbound/inbound_bgapi2.py
  6. +2 −0 src/examples/freeswitch/inbound/inbound_concurrent_bgapi.py
  7. +2 −0 src/examples/freeswitch/inbound/inbound_concurrent_dialer_server.py
  8. +2 −2 src/examples/freeswitch/inbound/inbound_connectfailure.py
  9. +2 −3 src/examples/freeswitch/inbound/inbound_filter.py
  10. +2 −1 src/examples/freeswitch/inbound/inbound_stop.py
  11. +2 −1 src/examples/freeswitch/inbound/inbound_stop_spawned.py
  12. +3 −2 src/examples/freeswitch/outbound/outbound_async_server_test.py
  13. +2 −1 src/examples/freeswitch/outbound/outbound_sync_server_test.py
  14. +4 −3 src/plivo/core/errors.py
  15. +2 −0 src/plivo/core/freeswitch/commands.py
  16. +18 −17 src/plivo/core/freeswitch/eventsocket.py
  17. +10 −11 src/plivo/core/freeswitch/eventtypes.py
  18. +5 −5 src/plivo/core/freeswitch/inboundsocket.py
  19. +2 −0 src/plivo/core/freeswitch/outboundsocket.py
  20. +3 −2 src/plivo/core/freeswitch/transport.py
  21. +2 −1 src/plivo/core/transport.py
  22. +2 −0 src/plivo/rest/freeswitch/helpers.py
  23. +2 −0 src/plivo/rest/freeswitch/inbound_socket.py
  24. +2 −0 src/plivo/rest/freeswitch/outbound_server.py
  25. +2 −0 src/plivo/rest/freeswitch/outbound_socket.py
  26. +2 −0 src/plivo/rest/freeswitch/rest_api.py
  27. +2 −0 src/plivo/rest/freeswitch/rest_server.py
  28. +2 −0 src/plivo/rest/freeswitch/restexceptions.py
  29. +2 −0 src/plivo/rest/freeswitch/verbs.py
  30. +11 −10 src/plivo/utils/daemonize.py
  31. +3 −2 src/plivo/utils/logger.py
  32. +2 −0 src/scripts/initscript/debian/plivo-myscript
  33. +2 −0 src/scripts/plivod
  34. +2 −0 src/scripts/tests.py
  35. +2 −0 src/tests.py
  36. +4 −3 src/tests/freeswitch/test_events.py
  37. +3 −2 src/tests/freeswitch/test_inboundsocket.py
  38. +2 −0 tools/profiler.sh
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -25,4 +27,3 @@
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -24,4 +26,3 @@
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
import gevent
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
@@ -6,7 +8,7 @@
class MyInboundEventSocket(InboundEventSocket):
- '''Inbound eventsocket connector that automatically reconnects
+ '''Inbound eventsocket connector that automatically reconnects
when the freeswitch eventsocket module closed the connection
'''
def __init__(self, host, port, password, filter="ALL", pool_size=500, connect_timeout=5):
@@ -23,14 +25,13 @@ def start(self):
self.serve_forever()
except ConnectError, e:
self.log.error("ConnectError: %s" % str(e))
- except (SystemExit, KeyboardInterrupt):
+ except (SystemExit, KeyboardInterrupt):
break
self.log.error("Inbound socket closed, try to reconnect ...")
gevent.sleep(1.0)
self.log.info("Inbound socket terminated")
-
+
if __name__ == '__main__':
c = MyInboundEventSocket('127.0.0.1', 8021, 'ClueCon')
- c.start()
-
+ c.start()
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -31,4 +33,3 @@
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -53,4 +55,3 @@ def wait_background_job(self):
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
from plivo.utils.logger import StdoutLogger
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
import traceback
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
@@ -34,5 +36,3 @@
log.info('#'*60 + '\n')
log.info('exit')
-
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -24,6 +26,3 @@
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
-
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -19,4 +21,3 @@
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
from plivo.core.freeswitch.inboundsocket import InboundEventSocket
from plivo.core.errors import ConnectError
@@ -27,4 +29,3 @@ def stop(inbound_event_listener, log):
except (SystemExit, KeyboardInterrupt): pass
log.info("exit")
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
"""
Outbound server example in async mode full .
@@ -44,7 +46,7 @@ def run(self):
self.answer()
self.log.info("Wait answer")
event = self._action_queue.get()
- gevent.sleep(1) # sleep 1 sec: sometimes sound is truncated after answer
+ gevent.sleep(1) # sleep 1 sec: sometimes sound is truncated after answer
self.log.info("Channel answered")
# play file
@@ -74,4 +76,3 @@ def do_handle(self, socket, address):
if __name__ == '__main__':
outboundserver = AsyncOutboundServer(('127.0.0.1', 8084), AsyncOutboundEventSocket)
outboundserver.serve_forever()
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
"""
Outbound server example in sync mode full .
@@ -68,4 +70,3 @@ def do_handle(self, socket, address):
if __name__ == '__main__':
outboundserver = SyncOutboundServer(('127.0.0.1', 8084), SyncOutboundEventSocket)
outboundserver.serve_forever()
-
View
@@ -1,14 +1,15 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
"""
Exceptions classes
"""
-class LimitExceededError(Exception):
+class LimitExceededError(Exception):
'''Exception class when MAXLINES_PER_EVENT is reached'''
pass
-class ConnectError(Exception):
+class ConnectError(Exception):
'''Exception class for connection'''
pass
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
"""
FreeSWITCH Commands class
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
"""
Event Socket class
@@ -77,7 +79,7 @@ def stop_event_handler(self):
'''
if self._handler_thread:
self._handler_thread.kill()
-
+
def handle_events(self):
'''
Gets and Dispatches events in an endless loop using gevent spawn.
@@ -96,7 +98,7 @@ def handle_events(self):
except GreenletExit, e:
self.connected = False
return
-
+
def read_event(self):
'''
Reads one Event from socket until EOL.
@@ -188,11 +190,11 @@ def _event_plain(self, event):
'''
# Gets raw data for this event
raw = self.read_raw(event)
- # If raw was found drops current event
+ # If raw was found drops current event
# and replaces with Event created from raw
if raw:
event = Event(raw)
- # Gets raw response from Event Content-Length header
+ # Gets raw response from Event Content-Length header
# and raw buffer
raw_response = self.read_raw_response(event, raw)
# If rawresponse was found, this is our Event body
@@ -218,7 +220,7 @@ def _unknown_event(self, event):
def dispatch_event(self, event):
'''
Dispatches one event with callback.
-
+
E.g. Receives Background_Job event and calls on_background_job function.
'''
method = 'on_' + event.get_header('Event-Name').lower()
@@ -228,27 +230,27 @@ def dispatch_event(self, event):
callback = self.unbound_event(event)
# Calls callback.
# On exception calls callback_failure method.
- try:
+ try:
callback(event)
- except:
+ except:
self.callback_failure(event)
-
+
def unbound_event(self, event):
'''
Catches all unbound events from FreeSWITCH.
-
+
Can be implemented by the subclass.
'''
pass
-
+
def callback_failure(self, event):
'''
Called when callback to an event fails.
-
+
Can be implemented by the subclass.
'''
pass
-
+
def disconnect(self):
'''
Disconnects from eventsocket and stops handling events.
@@ -269,7 +271,7 @@ def _send(self, cmd):
if isinstance(cmd, types.UnicodeType):
cmd = cmd.encode("utf-8")
self.transport.write(cmd + EOL*2)
-
+
def _sendmsg(self, name, arg=None, uuid="", lock=False, loops=1):
if isinstance(name, types.UnicodeType):
name = name.encode("utf-8")
@@ -285,7 +287,7 @@ def _sendmsg(self, name, arg=None, uuid="", lock=False, loops=1):
arglen = len(arg)
msg += "content-type: text/plain\ncontent-length: %d\n\n%s\n" % (arglen, arg)
self.transport.write(msg + EOL)
-
+
def _protocol_send(self, command, args=""):
with self._lock:
self._send("%s %s" % (command, args))
@@ -294,18 +296,17 @@ def _protocol_send(self, command, args=""):
# Casts to ApiResponse, if event is api
if command == 'api':
event = ApiResponse.cast(event)
- # Casts to BgapiResponse, if event is bgapi
+ # Casts to BgapiResponse, if event is bgapi
elif command == "bgapi":
event = BgapiResponse.cast(event)
# Casts to CommandResponse by default
else:
event = CommandResponse.cast(event)
return event
-
+
def _protocol_sendmsg(self, name, args=None, uuid="", lock=False, loops=1):
with self._lock:
self._sendmsg(name, args, uuid, lock, loops)
event = self._response_queue.get()
# Always casts Event to CommandResponse
return CommandResponse.cast(event)
-
@@ -1,3 +1,5 @@
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
+
# -*- coding: utf-8 -*-
"""
Event Types classes
@@ -20,7 +22,7 @@ def __init__(self, buffer=""):
try:
var, val = line.rstrip().split(': ', 1)
self.set_header(var, val)
- except ValueError:
+ except ValueError:
pass
def __getitem__(self, key):
@@ -49,12 +51,12 @@ def get_reply_text(self):
Returns None if header not found.
'''
- return self.get_header('Reply-Text')
+ return self.get_header('Reply-Text')
def is_reply_text_success(self):
'''
Returns True if ReplyText header begins with +OK.
-
+
Returns False otherwise.
'''
reply = self.get_reply_text()
@@ -140,8 +142,8 @@ def get_unquoted_raw_event(self):
def __str__(self):
return '<%s headers=%s, body=%s>' \
- % (self.__class__.__name__,
- str(self.get_unquoted_raw_headers().replace('\n', '\\n')),
+ % (self.__class__.__name__,
+ str(self.get_unquoted_raw_headers().replace('\n', '\\n')),
str(self.get_body()).replace('\n', '\\n'))
@@ -167,7 +169,7 @@ def get_response(self):
def is_success(self):
'''
Returns True if api command is a success.
-
+
Otherwise returns False.
'''
return self._raw_body and self._raw_body[:3] == '+OK'
@@ -201,7 +203,7 @@ def get_job_uuid(self):
def is_success(self):
'''
Returns True if bgapi command is a success.
-
+
Otherwise returns False.
'''
return self.is_reply_text_success()
@@ -229,10 +231,7 @@ def get_response(self):
def is_success(self):
'''
Returns True if command is a success.
-
+
Otherwise returns False.
'''
return self.is_reply_text_success()
-
-
-
Oops, something went wrong.

0 comments on commit 3ca2770

Please sign in to comment.