Richard Jones' Log

Tue, 26 Jul 2011
Using Solaris "priv" with Fabric

I needed support for "priv" instead of Fabric's built-in "sudo" support. I went through a number of (sometimes quite horrific) iterations before I settled on this relatively simple solution:

import contextlib

@contextlib.contextmanager
def priv(user):
    '''Context manager to cause all run()'ed operations to be
    priv('user')'ed.
    
    Replaces env.shell with the priv command for the duration of the
    context.
    '''
    save_shell = env.shell
    env.shell = 'priv su - %s -c' % user
    yield
    env.shell = save_shell

This is then used in a fabfile like so:

    with priv('remote_user'):
        run('do some remote command as remote_user')
        run('another remote command as remote_user')
category: Python | permanent link
Thu, 21 Jul 2011
PyWeek 13 (September 2011) is coming!

The 13th Python Game Programming Challenge (PyWeek) is coming. It'll run from the 11th to the 18th of September.

The PyWeek challenge:

  1. Invites entrants to write a game in one week from scratch either as an individual or in a team,
  2. Is intended to be challenging and fun,
  3. Will hopefully increase the public body of game tools, code and expertise,
  4. Will let a lot of people actually finish a game, and
  5. May inspire new projects (with ready made teams!)

If you've never written a game before and would like to try things out then perhaps you could try either:

  1. The tutorial I presented at LCA 2010, Introduction to Game Programming, or
  2. The book Invent Your Own Computer Games With Python
category: News | permanent link