Roman's Blog

Random notes of a Python developer

Featured Image

Recent surprise

 Oct. 13, 2016    0 comments 

Quite a while ago I created a GUI micro-famework for Kodi mediacenter (formerly XBMC). At that time I tried to develop a subtitle addon for Addic7ed.com (which I did) and I needed to create a UI for the addon. Previously subtitle addons in Kodi had to have their own UI, so I used a several classes that Kodi-Python API provides and created a UI for my addon. Inspired with success (those were my first attempts to write something useful in Python) I decided to extend that UI to a micro-framework that would allow to create user interfaces for Kodi addon in pure Python without messing with XML skinning. I published my micro-framework on GitHub, submitted it to the Kodi official addon repository and created a topic on the Kodi official forum. I also used it in a couple of my personal projects, and that was all. (...)

Read post

 KodiPython

Featured Image

Comparison of HTML5 Parsers: Gumbo vs html5lib

 July 29, 2016    0 comments 

When developing content plugin for Kodi mediacenter the most important part is where to get the content from. One of the possible ways is to scrap websites that host multimedia content. Yes, legality of that content is another question, but legal matters are beyond the scope of this post.

In Python world BeautifulSoup library (BS for short) in combination with html5lib parser is a popular choice. However, according to the BeautifulSoup documentation the html5lib parser is the slowest, albeit the most reliable, of all html parsers. So I googled for alternatives and found Gumbo parser made by Google itself. According to the description it's fully HTML5-compliant and written in pure C99 with no external dependencies. And it has Python bindings compatible with popular Python HTML parsing libraries, including BeautifulSoup. The BeautifulSoup binding was written for BS 3 of but making it compatible with BS 4 was relatively easy, which I did and submitted a pull request on GitHub (which seems to be ignored by the repo maintainers). (...)

Read post

 HTMLPython

Featured Image

Wsgi-Boost-Server: A Python WSGI Server Written in C++

 July 15, 2016    0 comments 

At last I found some time to write about my recent project — WsgiBoostServer. I started it to learn C++ and, specifically, writing binary extension modules for Python using Boost.Python. As the name implies, this is a WSGI server, that is, a HTTP server for Python web applications. But in addition to Python applications WsgiBoostServer can also serve static files that allows to use it for serving standalone Python micro-services with all their static content.

Because WsgiBoostServer is written in C++ using Boost.Asio library, it is faster than pure Python WSGI servers like Waitress or CherryPy. And since it can be used as a regular Python module (although binary), it does not require complex set-up and can be included in any Python application. More info about WsgiBoostServer and its source code can be found in my GitHub repository. It's MIT-licensed so feel free to use it as you like if you find this my little side-project interesting.

Update: Unfortunately, deeper testing revealed serious problems. WsgiBoostServer works with pure-Python WSGI applications without problems but crashes because of memory corruption if I add some binary Python modules in the mix. My guess is that Boost.Asio does not work well inside a Python interpreter which does its own memory management. Since diagnosing such arcane memory problems is way over my head, I had to abandon this project frown.

Read post

 BoostC++Python

Featured Image

YATP: A Torrent Streaming Plugin for Kodi

 May 23, 2016    0 comments 

My YATP (Yet Another Torrent Player) plugin for Kodi mediacenter is not a new project. I stated it a wile ago partly out of curiosity, partly because of practical reasons because I needed a torrent player that satisfied my needs. (...)

Read post

 BitTorrentKodiPluginPython

Featured Image

Boost ASIO Stackful Coroutines May Resume In A Different Thread

 May 18, 2016    0 comments 

Currently I'm learning C++ and specifically how to write binary Python modules with Boost.Python. As a part of my learning I've decided to develop a PEP-3333 compliant multithreaded WSGI server written in C++ using Boost.Asio and Boost.Python. (...)

Read post

 BoostC++Python