IPython embedded shell

Gajim has embedded IPython shell window as shown on screenhost below.

Window with interactive IPython shell embedded working with Gajim

To use interactive shell window follow these steps:

  1. first of all you need IPython installed. Possible ways to do it:
    • download it from here: http://ipython.scipy.org/dist/ and install manually
    • use package from Cheese Shop:
      sudo easy_install ipython
    • install package using your distro's repository, eg. in Ubuntu/Debian:
      sudo apt-get install ipython
  2. checkout/update SVN version of Gajim if you haven't already. Use these intructions. Remember: IPython shell is available only in SVN version.
  3. from main source code directory invoke command below to show/hide IPython window:
    src/gajim-remote.py toggle_ipython
  • Note 1: gajim-remote.py uses DBUS so you have to install it separately if you haven't already
  • Note 2: gajim-remote.py communicates with Gajim instance that was run first if you have multiple opened (i.e using different profiles)

It's working. What know?

Note: current instance of Gajim is available through gajim variable.

A few ideas to get you started:

  • list all elements visible from current scope (you should see gajim variable listed):
    dir()
  • show/hide roster window (this clearly indicates whether IPython shell works correctly):
    gajim.interface.roster.window.show()
    gajim.interface.roster.window.hide()
  • display accounts (using pprint):
    import pprint; pprint.pprint(gajim.connections)
  • send message from one JID (one of accounts) to another:
    from_account = "account name string" # one of keys in gajim.connections dictionary
    to_jid = "some_test_login@jabber.org"
    conn = gajim.connections[from_account]
    msg = "hello gajim"
    conn.send_message(to_jid,msg, keyID=None, session=conn.make_new_session(to_jid))

Note: Interactive IPython shell in Gajim is based on Embedding In GTK - IPython.

Attachments