pyfarm/pyfarm-agent — pull request #113 by opalmer (2014-07-13 03:55:52+00:00)
Title: Add Twisted Manhole Service

This change adds the twisted manhole service into the agent. When enabled you can connect to the agent using telnet which will provide access to a live Python interpreter. By default this service is disabled but it can be enabled using the `--enable-manhole` flag or the `agent_manhole` config value. This service is mainly useful for debugging purposes though it could be useful for other purposes too.

**Agent**
```
pyfarm-agent -n --master=127.0.0.1 start --time-offset=0 --jobtype-no-cache --enable-manhole
```

**Telnet**
```
telnet 127.0.0.1 50001
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Username: admin
Password:

>>> show()
objects: ['pp', 'show', 'current_assignments', 'agent', 'jobtypes', 'config']
>>> show(agent)
data attributes of
last_free_ram_post : 1405223415.15
reannounce_client_request : None
register_shutdown_events : True
scheduled_tasks :
services : {'api': < of pyfarm.agent.http.core.server.Site on 50000>, 'manhole': < of twisted.internet.protocol.ServerFactory on 50001>} (2 elements)
shutting_down : False

>>> \q
```

**Agent Log**
```
....
2014-07-12 23:50:18 INFO - pf.agent.manhole - Connection made from 127.0.0.1@53543
2014-07-12 23:50:42 INFO - pf.agent.manhole - 127.0.0.1@53543 - show()
2014-07-12 23:51:02 INFO - pf.agent.manhole - 127.0.0.1@53543 - show(agent)
2014-07-12 23:51:40 INFO - pf.agent.manhole - 127.0.0.1@53543 - \q
2014-07-12 23:51:40 INFO - pf.agent.manhole - Connection lost from 127.0.0.1@53543

```