Skip to content
This repository
Browse code

Add copyright notice to all source files

  • Loading branch information...
commit 3ca27708bf9b367dc564d80ae0770fb273d26442 1 parent 9179f62
authored April 27, 2011

Showing 38 changed files with 124 additions and 75 deletions. Show diff stats Hide diff stats

  1. 3  src/examples/freeswitch/inbound/inbound_api.py
  2. 3  src/examples/freeswitch/inbound/inbound_api_notfound.py
  3. 11  src/examples/freeswitch/inbound/inbound_autoreconnect.py
  4. 3  src/examples/freeswitch/inbound/inbound_bgapi.py
  5. 3  src/examples/freeswitch/inbound/inbound_bgapi2.py
  6. 2  src/examples/freeswitch/inbound/inbound_concurrent_bgapi.py
  7. 2  src/examples/freeswitch/inbound/inbound_concurrent_dialer_server.py
  8. 4  src/examples/freeswitch/inbound/inbound_connectfailure.py
  9. 5  src/examples/freeswitch/inbound/inbound_filter.py
  10. 3  src/examples/freeswitch/inbound/inbound_stop.py
  11. 3  src/examples/freeswitch/inbound/inbound_stop_spawned.py
  12. 5  src/examples/freeswitch/outbound/outbound_async_server_test.py
  13. 3  src/examples/freeswitch/outbound/outbound_sync_server_test.py
  14. 7  src/plivo/core/errors.py
  15. 2  src/plivo/core/freeswitch/commands.py
  16. 35  src/plivo/core/freeswitch/eventsocket.py
  17. 21  src/plivo/core/freeswitch/eventtypes.py
  18. 10  src/plivo/core/freeswitch/inboundsocket.py
  19. 2  src/plivo/core/freeswitch/outboundsocket.py
  20. 5  src/plivo/core/freeswitch/transport.py
  21. 3  src/plivo/core/transport.py
  22. 2  src/plivo/rest/freeswitch/helpers.py
  23. 2  src/plivo/rest/freeswitch/inbound_socket.py
  24. 2  src/plivo/rest/freeswitch/outbound_server.py
  25. 2  src/plivo/rest/freeswitch/outbound_socket.py
  26. 2  src/plivo/rest/freeswitch/rest_api.py
  27. 2  src/plivo/rest/freeswitch/rest_server.py
  28. 2  src/plivo/rest/freeswitch/restexceptions.py
  29. 2  src/plivo/rest/freeswitch/verbs.py
  30. 21  src/plivo/utils/daemonize.py
  31. 5  src/plivo/utils/logger.py
  32. 2  src/scripts/initscript/debian/plivo-myscript
  33. 2  src/scripts/plivod
  34. 2  src/scripts/tests.py
  35. 2  src/tests.py
  36. 7  src/tests/freeswitch/test_events.py
  37. 5  src/tests/freeswitch/test_inboundsocket.py
  38. 2  tools/profiler.sh
3  src/examples/freeswitch/inbound/inbound_api.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -25,4 +27,3 @@
25 27
     except (SystemExit, KeyboardInterrupt): pass
26 28
 
27 29
     log.info("exit")
28  
-
3  src/examples/freeswitch/inbound/inbound_api_notfound.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -24,4 +26,3 @@
24 26
     except (SystemExit, KeyboardInterrupt): pass
25 27
 
26 28
     log.info("exit")
27  
-
11  src/examples/freeswitch/inbound/inbound_autoreconnect.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 import gevent
3 5
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
@@ -6,7 +8,7 @@
6 8
 
7 9
 
8 10
 class MyInboundEventSocket(InboundEventSocket):
9  
-    '''Inbound eventsocket connector that automatically reconnects 
  11
+    '''Inbound eventsocket connector that automatically reconnects
10 12
     when the freeswitch eventsocket module closed the connection
11 13
     '''
12 14
     def __init__(self, host, port, password, filter="ALL", pool_size=500, connect_timeout=5):
@@ -23,14 +25,13 @@ def start(self):
23 25
                 self.serve_forever()
24 26
             except ConnectError, e:
25 27
                 self.log.error("ConnectError: %s" % str(e))
26  
-            except (SystemExit, KeyboardInterrupt): 
  28
+            except (SystemExit, KeyboardInterrupt):
27 29
                 break
28 30
             self.log.error("Inbound socket closed, try to reconnect ...")
29 31
             gevent.sleep(1.0)
30 32
         self.log.info("Inbound socket terminated")
31  
-        
  33
+
32 34
 
33 35
 if __name__ == '__main__':
34 36
     c = MyInboundEventSocket('127.0.0.1', 8021, 'ClueCon')
35  
-    c.start()    
36  
-
  37
+    c.start()
3  src/examples/freeswitch/inbound/inbound_bgapi.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -31,4 +33,3 @@
31 33
     except (SystemExit, KeyboardInterrupt): pass
32 34
 
33 35
     log.info("exit")
34  
-
3  src/examples/freeswitch/inbound/inbound_bgapi2.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -53,4 +55,3 @@ def wait_background_job(self):
53 55
     except (SystemExit, KeyboardInterrupt): pass
54 56
 
55 57
     log.info("exit")
56  
-
2  src/examples/freeswitch/inbound/inbound_concurrent_bgapi.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
2  src/examples/freeswitch/inbound/inbound_concurrent_dialer_server.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
2 4
 from plivo.core.errors import ConnectError
3 5
 from plivo.utils.logger import StdoutLogger
4  src/examples/freeswitch/inbound/inbound_connectfailure.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 import traceback
3 5
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
@@ -34,5 +36,3 @@
34 36
     log.info('#'*60 + '\n')
35 37
 
36 38
     log.info('exit')
37  
-        
38  
-
5  src/examples/freeswitch/inbound/inbound_filter.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -24,6 +26,3 @@
24 26
     except (SystemExit, KeyboardInterrupt): pass
25 27
 
26 28
     log.info("exit")
27  
-            
28  
-        
29  
-
3  src/examples/freeswitch/inbound/inbound_stop.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -19,4 +21,3 @@
19 21
     except (SystemExit, KeyboardInterrupt): pass
20 22
 
21 23
     log.info("exit")
22  
-
3  src/examples/freeswitch/inbound/inbound_stop_spawned.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from plivo.core.freeswitch.inboundsocket import InboundEventSocket
3 5
 from plivo.core.errors import ConnectError
@@ -27,4 +29,3 @@ def stop(inbound_event_listener, log):
27 29
     except (SystemExit, KeyboardInterrupt): pass
28 30
 
29 31
     log.info("exit")
30  
-
5  src/examples/freeswitch/outbound/outbound_async_server_test.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Outbound server example in async mode full .
@@ -44,7 +46,7 @@ def run(self):
44 46
         self.answer()
45 47
         self.log.info("Wait answer")
46 48
         event = self._action_queue.get()
47  
-        gevent.sleep(1) # sleep 1 sec: sometimes sound is truncated after answer 
  49
+        gevent.sleep(1) # sleep 1 sec: sometimes sound is truncated after answer
48 50
         self.log.info("Channel answered")
49 51
 
50 52
         # play file
@@ -74,4 +76,3 @@ def do_handle(self, socket, address):
74 76
 if __name__ == '__main__':
75 77
     outboundserver = AsyncOutboundServer(('127.0.0.1', 8084), AsyncOutboundEventSocket)
76 78
     outboundserver.serve_forever()
77  
-
3  src/examples/freeswitch/outbound/outbound_sync_server_test.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Outbound server example in sync mode full .
@@ -68,4 +70,3 @@ def do_handle(self, socket, address):
68 70
 if __name__ == '__main__':
69 71
     outboundserver = SyncOutboundServer(('127.0.0.1', 8084), SyncOutboundEventSocket)
70 72
     outboundserver.serve_forever()
71  
-
7  src/plivo/core/errors.py
... ...
@@ -1,14 +1,15 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Exceptions classes
4 6
 """
5 7
 
6  
-class LimitExceededError(Exception): 
  8
+class LimitExceededError(Exception):
7 9
     '''Exception class when MAXLINES_PER_EVENT is reached'''
8 10
     pass
9 11
 
10 12
 
11  
-class ConnectError(Exception): 
  13
+class ConnectError(Exception):
12 14
     '''Exception class for connection'''
13 15
     pass
14  
-
2  src/plivo/core/freeswitch/commands.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 FreeSWITCH Commands class
35  src/plivo/core/freeswitch/eventsocket.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Event Socket class
@@ -77,7 +79,7 @@ def stop_event_handler(self):
77 79
         '''
78 80
         if self._handler_thread:
79 81
             self._handler_thread.kill()
80  
-        
  82
+
81 83
     def handle_events(self):
82 84
         '''
83 85
         Gets and Dispatches events in an endless loop using gevent spawn.
@@ -96,7 +98,7 @@ def handle_events(self):
96 98
             except GreenletExit, e:
97 99
                 self.connected = False
98 100
                 return
99  
-        
  101
+
100 102
     def read_event(self):
101 103
         '''
102 104
         Reads one Event from socket until EOL.
@@ -188,11 +190,11 @@ def _event_plain(self, event):
188 190
         '''
189 191
         # Gets raw data for this event
190 192
         raw = self.read_raw(event)
191  
-        # If raw was found drops current event 
  193
+        # If raw was found drops current event
192 194
         # and replaces with Event created from raw
193 195
         if raw:
194 196
             event = Event(raw)
195  
-            # Gets raw response from Event Content-Length header 
  197
+            # Gets raw response from Event Content-Length header
196 198
             # and raw buffer
197 199
             raw_response = self.read_raw_response(event, raw)
198 200
             # If rawresponse was found, this is our Event body
@@ -218,7 +220,7 @@ def _unknown_event(self, event):
218 220
     def dispatch_event(self, event):
219 221
         '''
220 222
         Dispatches one event with callback.
221  
-        
  223
+
222 224
         E.g. Receives Background_Job event and calls on_background_job function.
223 225
         '''
224 226
         method = 'on_' + event.get_header('Event-Name').lower()
@@ -228,27 +230,27 @@ def dispatch_event(self, event):
228 230
             callback = self.unbound_event(event)
229 231
         # Calls callback.
230 232
         # On exception calls callback_failure method.
231  
-        try: 
  233
+        try:
232 234
             callback(event)
233  
-        except: 
  235
+        except:
234 236
             self.callback_failure(event)
235  
-    
  237
+
236 238
     def unbound_event(self, event):
237 239
         '''
238 240
         Catches all unbound events from FreeSWITCH.
239  
-        
  241
+
240 242
         Can be implemented by the subclass.
241 243
         '''
242 244
         pass
243  
-    
  245
+
244 246
     def callback_failure(self, event):
245 247
         '''
246 248
         Called when callback to an event fails.
247  
-        
  249
+
248 250
         Can be implemented by the subclass.
249 251
         '''
250 252
         pass
251  
-    
  253
+
252 254
     def disconnect(self):
253 255
         '''
254 256
         Disconnects from eventsocket and stops handling events.
@@ -269,7 +271,7 @@ def _send(self, cmd):
269 271
         if isinstance(cmd, types.UnicodeType):
270 272
             cmd = cmd.encode("utf-8")
271 273
         self.transport.write(cmd + EOL*2)
272  
-        
  274
+
273 275
     def _sendmsg(self, name, arg=None, uuid="", lock=False, loops=1):
274 276
         if isinstance(name, types.UnicodeType):
275 277
             name = name.encode("utf-8")
@@ -285,7 +287,7 @@ def _sendmsg(self, name, arg=None, uuid="", lock=False, loops=1):
285 287
             arglen = len(arg)
286 288
             msg += "content-type: text/plain\ncontent-length: %d\n\n%s\n" % (arglen, arg)
287 289
         self.transport.write(msg + EOL)
288  
-        
  290
+
289 291
     def _protocol_send(self, command, args=""):
290 292
         with self._lock:
291 293
             self._send("%s %s" % (command, args))
@@ -294,18 +296,17 @@ def _protocol_send(self, command, args=""):
294 296
         # Casts to ApiResponse, if event is api
295 297
         if command == 'api':
296 298
             event = ApiResponse.cast(event)
297  
-        # Casts to BgapiResponse, if event is bgapi 
  299
+        # Casts to BgapiResponse, if event is bgapi
298 300
         elif command == "bgapi":
299 301
             event = BgapiResponse.cast(event)
300 302
         # Casts to CommandResponse by default
301 303
         else:
302 304
             event = CommandResponse.cast(event)
303 305
         return event
304  
-    
  306
+
305 307
     def _protocol_sendmsg(self, name, args=None, uuid="", lock=False, loops=1):
306 308
         with self._lock:
307 309
             self._sendmsg(name, args, uuid, lock, loops)
308 310
             event = self._response_queue.get()
309 311
         # Always casts Event to CommandResponse
310 312
         return CommandResponse.cast(event)
311  
-
21  src/plivo/core/freeswitch/eventtypes.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Event Types classes
@@ -20,7 +22,7 @@ def __init__(self, buffer=""):
20 22
                 try:
21 23
                     var, val = line.rstrip().split(': ', 1)
22 24
                     self.set_header(var, val)
23  
-                except ValueError: 
  25
+                except ValueError:
24 26
                     pass
25 27
 
26 28
     def __getitem__(self, key):
@@ -49,12 +51,12 @@ def get_reply_text(self):
49 51
 
50 52
         Returns None if header not found.
51 53
         '''
52  
-        return self.get_header('Reply-Text') 
  54
+        return self.get_header('Reply-Text')
53 55
 
54 56
     def is_reply_text_success(self):
55 57
         '''
56 58
         Returns True if ReplyText header begins with +OK.
57  
-        
  59
+
58 60
         Returns False otherwise.
59 61
         '''
60 62
         reply = self.get_reply_text()
@@ -140,8 +142,8 @@ def get_unquoted_raw_event(self):
140 142
 
141 143
     def __str__(self):
142 144
         return '<%s headers=%s, body=%s>' \
143  
-               % (self.__class__.__name__, 
144  
-                  str(self.get_unquoted_raw_headers().replace('\n', '\\n')), 
  145
+               % (self.__class__.__name__,
  146
+                  str(self.get_unquoted_raw_headers().replace('\n', '\\n')),
145 147
                   str(self.get_body()).replace('\n', '\\n'))
146 148
 
147 149
 
@@ -167,7 +169,7 @@ def get_response(self):
167 169
     def is_success(self):
168 170
         '''
169 171
         Returns True if api command is a success.
170  
-        
  172
+
171 173
         Otherwise returns False.
172 174
         '''
173 175
         return self._raw_body and self._raw_body[:3] == '+OK'
@@ -201,7 +203,7 @@ def get_job_uuid(self):
201 203
     def is_success(self):
202 204
         '''
203 205
         Returns True if bgapi command is a success.
204  
-        
  206
+
205 207
         Otherwise returns False.
206 208
         '''
207 209
         return self.is_reply_text_success()
@@ -229,10 +231,7 @@ def get_response(self):
229 231
     def is_success(self):
230 232
         '''
231 233
         Returns True if command is a success.
232  
-        
  234
+
233 235
         Otherwise returns False.
234 236
         '''
235 237
         return self.is_reply_text_success()
236  
-
237  
-
238  
-
10  src/plivo/core/freeswitch/inboundsocket.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Inbound Event Socket class
@@ -27,12 +29,12 @@ def _wait_auth_request(self):
27 29
         timer = Timeout(self.transport.get_connect_timeout())
28 30
         timer.start()
29 31
         try:
30  
-            # When auth/request is received, 
  32
+            # When auth/request is received,
31 33
             # _authRequest method in BaseEventSocket will push this event to queue
32 34
             # so we will just wait this event here.
33 35
             return self._response_queue.get()
34 36
         except Timeout:
35  
-            raise ConnectError("Timeout waiting auth/request") 
  37
+            raise ConnectError("Timeout waiting auth/request")
36 38
         finally:
37 39
             timer.cancel()
38 40
 
@@ -76,7 +78,5 @@ def serve_forever(self):
76 78
         """
77 79
         Starts waiting for events in endless loop.
78 80
         """
79  
-        while self.is_connected(): 
  81
+        while self.is_connected():
80 82
             gevent.sleep(0.1)
81  
-
82  
-
2  src/plivo/core/freeswitch/outboundsocket.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Outbound Event Socket class
5  src/plivo/core/freeswitch/transport.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Freeswitch Transport classes
@@ -27,7 +29,7 @@ def write(self, data):
27 29
             raise ConnectError('not connected')
28 30
         self.sockfd.write(data)
29 31
         self.sockfd.flush()
30  
-        
  32
+
31 33
 
32 34
 
33 35
 class OutboundTransport(Transport):
@@ -36,4 +38,3 @@ def __init__(self, socket, address, connect_timeout=5):
36 38
         self.sockfd = socket.makefile()
37 39
         self.address = address
38 40
         self.timeout = connect_timeout
39  
-
3  src/plivo/core/transport.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Transport class
@@ -26,4 +28,3 @@ def close(self):
26 28
 
27 29
     def get_connect_timeout(self):
28 30
         return self.timeout
29  
-
2  src/plivo/rest/freeswitch/helpers.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 import re
2 4
 import urlparse
3 5
 
2  src/plivo/rest/freeswitch/inbound_socket.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 # -*- coding: utf-8 -*-
3 5
 from gevent import monkey; monkey.patch_all()
2  src/plivo/rest/freeswitch/outbound_server.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 # -*- coding: utf-8 -*-
3 5
 from gevent import monkey; monkey.patch_all()
2  src/plivo/rest/freeswitch/outbound_socket.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 # -*- coding: utf-8 -*-
3 5
 
2  src/plivo/rest/freeswitch/rest_api.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 from gevent import monkey; monkey.patch_all()
2 4
 from flask import Flask, request
3 5
 
2  src/plivo/rest/freeswitch/rest_server.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 # -*- coding: utf-8 -*-
3 5
 from gevent import monkey; monkey.patch_all()
2  src/plivo/rest/freeswitch/restexceptions.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 # -*- coding: utf-8 -*-
3 5
 
2  src/plivo/rest/freeswitch/verbs.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 # -*- coding: utf-8 -*-
3 5
 
21  src/plivo/utils/daemonize.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Daemonize application.
@@ -115,32 +117,32 @@ def daemon_script(script, user, group, path='/', pidfile=None, script_args=(), o
115 117
 def main():
116 118
     parser = optparse.OptionParser()
117 119
     parser.add_option("-s", "--script", action="store", type="string",
118  
-                      dest="script", help="python script SCRIPT to run (argument is mandatory)", 
  120
+                      dest="script", help="python script SCRIPT to run (argument is mandatory)",
119 121
                       metavar="SCRIPT")
120 122
     parser.add_option("-p", "--pidfile", action="store", type="string",
121 123
                       dest="pidfile", help="write pid to PIDFILE (argument is mandatory)",
122 124
                       metavar="PIDFILE")
123 125
     parser.add_option("-u", "--user", action="store", type="string",
124  
-                      dest="user", help="set uid to USER (argument is mandatory)", 
  126
+                      dest="user", help="set uid to USER (argument is mandatory)",
125 127
                       metavar="USER")
126 128
     parser.add_option("-g", "--group", action="store", type="string",
127  
-                      dest="group", help="set gid to GROUP (argument is mandatory)", 
  129
+                      dest="group", help="set gid to GROUP (argument is mandatory)",
128 130
                       metavar="GROUP")
129 131
     parser.add_option("-G", "--groups", action="append", type="string", default=[],
130  
-                      dest="groups", help="set other groups gid to OTHERGROUP (can be added multiple times)", 
  132
+                      dest="groups", help="set other groups gid to OTHERGROUP (can be added multiple times)",
131 133
                       metavar="OTHERGROUP")
132 134
     parser.add_option("-P", "--pybin", action="store", type="string", default=None,
133  
-                      dest="pybin", help="set python binary PYBIN to run script", 
  135
+                      dest="pybin", help="set python binary PYBIN to run script",
134 136
                       metavar="PYBIN")
135 137
     parser.add_option("-a", "--scriptarg", action="append", type="string", default=[],
136  
-                      dest="scriptargs", help="add ARG to python script (can be added multiple times)", 
  138
+                      dest="scriptargs", help="add ARG to python script (can be added multiple times)",
137 139
                       metavar="ARG")
138 140
     (options, args) = parser.parse_args()
139 141
 
140 142
     script = options.script
141 143
     user = options.user
142 144
     group = options.group
143  
-    pidfile = options.pidfile 
  145
+    pidfile = options.pidfile
144 146
     ogroups = options.groups
145 147
     pybin = options.pybin
146 148
     scriptargs = options.scriptargs
@@ -149,11 +151,10 @@ def main():
149 151
         parser.print_help()
150 152
         sys.exit(1)
151 153
 
152  
-    daemon_script(script, user, group, pidfile=pidfile, 
153  
-                  script_args=scriptargs, other_groups=ogroups, 
  154
+    daemon_script(script, user, group, pidfile=pidfile,
  155
+                  script_args=scriptargs, other_groups=ogroups,
154 156
                   python_bin=pybin)
155 157
 
156 158
 
157 159
 if __name__ == '__main__':
158 160
     main()
159  
-
5  src/plivo/utils/logger.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 """
3 5
 Log classes : stdout, syslog and file loggers
@@ -38,7 +40,7 @@ def __init__(self, loglevel=LOG_DEBUG, servicename=__default_servicename__):
38 40
     def set_debug(self):
39 41
         self.loglevel = LOG_DEBUG
40 42
         self._logger.setLevel(self.loglevel)
41  
-        
  43
+
42 44
     def set_info(self):
43 45
         self.loglevel = LOG_INFO
44 46
         self._logger.setLevel(self.loglevel)
@@ -159,4 +161,3 @@ def __init__(self, logfile='/tmp/%s.log' % __default_servicename__, \
159 161
         h.setFormatter(fmt)
160 162
         self._logger = RootLogger(loglevel)
161 163
         self._logger.addHandler(h)
162  
-
2  src/scripts/initscript/debian/plivo-myscript
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #! /bin/sh
2 4
 ### BEGIN INIT INFO
3 5
 # Provides:          plivo service
2  src/scripts/plivod
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/usr/bin/env python
2 4
 """
3 5
 Daemonizer for python scripts.
2  src/scripts/tests.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 import plivo.tests
2 4
 
3 5
 plivo.tests.run_test()
2  src/tests.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 import unittest
3 5
 
7  src/tests/freeswitch/test_events.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from unittest import TestCase
3 5
 
@@ -31,8 +33,8 @@ class TestEvent(TestCase):
31 33
 
32 34
     def test_command_reply(self):
33 35
         ev = Event(self.EVENT_COMMAND_REPLY)
34  
-        self.assertEquals(ev.get_content_type(), "command/reply") 
35  
-        self.assertEquals(ev.get_reply_text(), "+OK accepted") 
  36
+        self.assertEquals(ev.get_content_type(), "command/reply")
  37
+        self.assertEquals(ev.get_reply_text(), "+OK accepted")
36 38
         self.assertTrue(ev.is_reply_text_success())
37 39
 
38 40
     def test_auth_request(self):
@@ -46,4 +48,3 @@ def test_event_plain(self):
46 48
         ev2 = Event(self.EVENT_PLAIN)
47 49
         self.assertEquals(ev2.get_header("Event-Name"), "RE_SCHEDULE")
48 50
         self.assertEquals(len(self.EVENT_PLAIN), ev1.get_content_length())
49  
-
5  src/tests/freeswitch/test_inboundsocket.py
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 # -*- coding: utf-8 -*-
2 4
 from unittest import TestCase
3 5
 
@@ -217,7 +219,7 @@ def tearDown(self):
217 219
             self.server_proc.kill()
218 220
         except:
219 221
             pass
220  
-        
  222
+
221 223
     def test_login_failure(self):
222 224
         isock = InboundEventSocket('127.0.0.1', 23333, 'ClueCon')
223 225
         self.assertRaises(ConnectError, isock.connect)
@@ -249,4 +251,3 @@ def test_events(self):
249 251
             self.assertEquals(ev.get_header('Event-Name'), 'HEARTBEAT')
250 252
         for ev in isock.re_schedule_events:
251 253
             self.assertEquals(ev.get_header('Event-Name'), 'RE_SCHEDULE')
252  
-
2  tools/profiler.sh
... ...
@@ -1,3 +1,5 @@
  1
+# Copyright (c) 2011 Plivo Team. See LICENSE for details.
  2
+
1 3
 #!/bin/bash
2 4
 
3 5
 # profile a python script with cProfile

0 notes on commit 3ca2770

Please sign in to comment.
Something went wrong with that request. Please try again.