Добавлено отладочный интерфейс.
[vpproxy.git] / plugins / debug_plugin.py
diff --git a/plugins/debug_plugin.py b/plugins/debug_plugin.py
new file mode 100644 (file)
index 0000000..ffa0079
--- /dev/null
@@ -0,0 +1,60 @@
+__author__ = 'rvb'
+'''
+Local Playlist Plugin
+(based on ytv plugin by ValdikSS)
+
+plsylist index
+
+http://ip:port/index
+
+m3u playlists
+
+http://ip:port/m3u
+http://ip:port/m3u/
+http://ip:port/m3u/list-name
+
+plain-tet channel names
+
+http://ip:port/list
+http://ip:port/list/
+http://ip:port/list/list-name
+
+forward to player
+
+http://ip:port/play/channel-name
+http://ip:port/play/list-name/channel-name
+http://ip:port/play/{list-name}/(get|mp4|webm)/channel-name
+
+'''
+import logging
+import gc
+from modules.PluginInterface import VPProxyPlugin
+import os
+from guppy import hpy
+h = hpy()
+
+class Debug(VPProxyPlugin):
+
+    handlers = ('debug',)
+
+    logger = logging.getLogger('mem_debug')
+
+    def handle(self, connection):
+
+        connection.send_response(200)
+        connection.send_header('Content-Type', 'text/plain')
+        connection.end_headers()
+        
+        gc.set_debug(gc.DEBUG_LEAK)
+
+        connection.wfile.write('{} objects collected\n'.format(gc.collect()))
+
+        connection.wfile.write(h.heap())
+
+    def getparam(self, key):
+        if key in self.params:
+            return self.params[key][0]
+        else:    
+            return None
+                                            
+                                            
\ No newline at end of file