heapy commands
authorThomasV <thomasv@gitorious>
Sun, 24 Nov 2013 21:02:19 +0000 (01:02 +0400)
committerThomasV <thomasv@gitorious>
Sun, 24 Nov 2013 21:02:19 +0000 (01:02 +0400)
backends/irc/__init__.py
server.py

index f0056d0..0ec2a8b 100644 (file)
@@ -169,7 +169,7 @@ class ServerProcessor(Processor):
         params = request['params']
         result = None
 
-        if method in ['server.stop', 'server.info']:
+        if method in ['server.stop', 'server.info', 'server.heapy']:
             try:
                 password = request['params'][0]
             except:
@@ -210,6 +210,19 @@ class ServerProcessor(Processor):
             p = self.dispatcher.request_dispatcher.processors['blockchain']
             result = p.queue.qsize()
 
+        elif method == 'server.heapy':
+            try:
+                s = request['params'][1]
+            except:
+                s = None
+
+            if s:
+                from guppy import hpy
+                h = hpy()
+                try:
+                    result = str(eval(s))
+                except:
+                    result = "error"
         else:
             print_log("unknown method", request)
 
index 0af6cc6..9c2bb99 100755 (executable)
--- a/server.py
+++ b/server.py
@@ -90,7 +90,11 @@ def run_rpc_command(command, stratum_tcp_port):
         return
 
     method = 'server.' + command
-    request = json.dumps({'id': 0, 'method': method, 'params': [password]})
+    params = [password]
+    if len(sys.argv) > 2:
+        params.append(sys.argv[2])
+    
+    request = json.dumps({'id': 0, 'method': method, 'params': params})
     s.send(request + '\n')
     msg = ''
     while True: