Author archives: Mike C. Fletcher

Create your own virtual keyboard with Python

So at some point I need the voice dictation client to be able to do basic interactions with applications on the desktop (think typing text and the like). So how do I go about doing that? I want to be compatible with Wayland when it shows up, but still work on X (since that's where I'm working now). That would seem to preclude using X event sending. What about making a "virtual keyboard" that actually sends the events through the Linux kernel event subsystem?

The resulting spike-test is checked into the listener project. It seems to work. Yay ...

Continue reading

GStreamer Level Plugin Monitoring

So you have an audio stream where you'd like to get a human-friendly readout of the current audio level. You add a level component, but how do you actually get the level messages it generates?

            bus.add_signal_watch()
            bus.connect( 'message', self.on_level )

It really seems that you *should* be able to use element.connect(), but there doesn't seem to be an available event to which to connect on the level. So, you wind up having to process all of the events and look for your level event...

    def on_level( self, bus, message ):
        """Level message was received"""
        if message ...

Continue reading

wx in a VirtualEnv (for RunSnakeRun)

Since I got asked about this in email I'll post it here for the google-verse. Say you want to allow your developers to use RunSnakeRun running in a virtualenv on an Ubuntu distribution.  You'll recall that normally to run RSR as a utility you do:

$ sudo apt-get install python-wxgtk2.8
$ pip install --user SquareMap RunSnakeRun
$ runsnake

That gets a bit more complex when you want to put RSR in a virtualenv (the question was actually how to make this work on many, many workstations using puppet, but you puppet peoples can figure that out). Building wxPython is not ...

Continue reading

Nginx Reverse Proxy with Authentication

So you have an internal device the web-gui of which you want authenticated users to be able to access.  You've got nginx running on the front-end server. You're willing to open up a port on the outside firewall, but all access on that port needs to go through your main web-app's permissions. You setup an nginx proxy like so:

upstream internal_gui {
    server 198.51.100.5:443 fail_timeout=0;
}

That sets up your upstream proxy. Here we're connecting to ssl. We then setup a server to listen on a high port (using ssl). It has two ...

Continue reading

RunSnakeRun/Squaremap with wxPython 3.0.0

There is a very minor new release on PyPi to allow Squaremap (and thus RunSnakeRun) to run on wxPython 3.0.0. The only people likely to be affected are those on bleeding-edge distros (Gentoo, Arch) or Windows.  You should be able to

pip install --update SquareMap

To get the latest version. Thanks to Kristof for the fix.

Continue reading

PyOpenGL 3.1.0 final is out

After far too long, and way more changes than originally intended, PyOpenGL 3.1.0 final is now out. The big changes are:

  • Generation of wrappers is substantially more automatic and based on Khronos source-files with annotations from the Chromium/regal project
  • Common code-base for Python 2.6, 2.7, 3.3 and 3.4, Python 2.5 is no longer supported, 2to3 is no longer used
  • Better isolation and pervasive lazy-loading behavior to prevent loading unused libraries (e.g. GLUT in non-GLUT contexts or GLES in OpenGL contexts)
  • Automated wrappers now (generally) allow passing in output arrays *or* having ...
  • Continue reading

    React.js with Django

    So I've been doing a spike test with a project where I'm trying to use React.js to build a front-end to a Django application. The bulk of this application is basic Django forms, posts, page-loads, etc. but there's a number of complex views for scheduling, content uploading etc. As of now I think I'm willing to say that React is going to become part of my toolbox. There are definitely some issues that I gather Facebook has addressed in their "Flux" framework, but that seems to go a bit too far for me.

    Things I ...

    Continue reading

    Found the source of SegFaults on AMD + FreeGLUT

    So the source of the segfaults that I'm seeing on fglrx and FreeGLUT on Kubuntu 14.04 has come to light. It's a known issue with the registration of FreeGLUT and fglrx at-exit handers (at the C level). You can work around it in your own code with PyOpenGL 3.1.0b3+ (which is still pending release) using:

            try:
                if fgDeinitialize: fgDeinitialize(False)
            except NameError as err:
                pass # Older PyOpenGL, you may see a seg-fault here...
            import sys
            sys.exit( 0 )
    

    Where fgDeinitialize is available in the GLUT namespace.

    Continue reading

    PyOpenGL test_core on 2.7, 3.3 and 3.4

    I just finished doing a clean test run across those 3 releases of Python with each of the 8 major config flags on/off (i.e. 48 runs of the test suite). As expected, almost all of the failures were in Python 3.x, and mostly related to unicode, where COPY_ON_ERROR generated failures when a unicode string was passed in; but those were almost all *usage* errors (i.e. errors in the test suite).

    However, a nasty real bug in the non-accelerated buffer handler was found and is now fixed (the accelerated code uses the C API directly, so it ...

    Continue reading

    Ubuntu Configuration for Inspiron 15r Running Hot

    So you have a Dell Ubuntu 14.04 Laptop and it is running way too hot. You can configure it to run at a reasonable level using i8kmon. As with anything heat related, be careful. If you miss-configure the machine you are likely to wind up with a fried machine!

    You create a file called /etc/i8kmon.conf and put the following in it:

    set config(daemon)      0
    
    # Automatic fan control, override with --auto option
    set config(auto)        1
    
    # Report status on stdout, override with --verbose option
    set config(verbose) 1
    
    # Status check timeout (seconds), override with --timeout option
    set ...

    Continue reading