Category: Python

  • Run external scripts inside Odoo’s environment

    Run external scripts inside Odoo’s environment

    You may run into a situation where you want to script actions in Odoo but do not necessarily want to run them within Odoo or its shell. To this end, we have devised a way to load and interact with the Odoo environment within a Python script. Our use case was a [[|slow executing backup […]

  • Dynamic DNS With CloudFlare – Ubiquiti EdgeRouter

    This tutorial will walk you through the process of setting up Dynamic DNS with CloudFlare on the Ubiquiti EdgeRouter (or really any form of Linux). Please see [[ddns-using-libcloud-edgerouter|here]] if you need to accomplish this using [[|LibCloud]], or [[dynamic-dns-with-ubiquiti-edgerouter|here]] if you are using a supported provider. === The Steps === # First, we will need to […]

  • Benchmarking Go, Node, Python & PyPy

    I was just recently introduced to [[|Go]], and it seems to offer some great features. I wrote a few simple benchmarks to evaluate Go against [[|Node.js]] and [[|Python]]/[[|PyPy]] in terms of speed. The results initially surprised me, but a user comment guided me to update Golang because they have made a lot of optimizations since […]

  • Python CloudFlare API Library

    I have just recently started experimenting with [[|CloudFlare’s]] services & API. In order to migrate my current framework, I required the ability to work with this API via Python. [[|Apache’s Libcloud]] does not have a CloudFlare driver, and the requirements for building a supported driver require quite a bit more time than rolling a library […]

  • Creating A Python Plugin Framework With Metaclasses

    This tutorial will walk you through creating a generic plugin framework in Python using metaclassing. This framework can be easily be dropped into existing code to allow seamless integration of Python plugins. There are essentially 3 parts to this framework: # **The mount point** – This provides a central location between the plugins and the […]

  • Convert SVN to Mercurial (Script)

    Below is a simple Python script that will traverse your online SVN repo and run the necessary commands to convert it to Mercurial. This is probably useless to most, but it saved me a great deal of time converting a large set of repos so I figured posting it couldn’t hurt: {{{ lang=python #!/usr/bin/env python […]

  • Determine Which Modules Are In A Package – Python

    Below is a method to enumerate Python modules located in a directory: {{{ lang=python import pkgutil def get_pkg_modules(pkg_path, recurse=False, add_prefix=”): ”’ Get modules of a package located at pkg_path @param str pkg_path Path of package to inspect @param bool recurse Recursive inspection? @param str add_prefix Add this prefix to results @return list List of modules […]

  • Mercurial/Trac Changeset Hook

    Below is a Mecurial changegroup hook to modify tickets on a remote Trac instance using XML-RPC. To use it, place the following in your hgrc (make necessary changes in [trac-hook] section). * File: repo/.hg/hgrc {{{ lang=ini [extensions] trac_hg_hook = /path/to/ [hooks] changegroup.sync = python:trac_hg_hook.hook [trac-hook] trac_root = /var/lib/trac api_url = repo_name = test python_eggs […]

  • Performance Metrics – Apache vs Nginx

    We just deployed [[|Nginx]] as a forward proxy for our production server. Before deploying, we took some page load benchmarks so that we could get an idea of what we improved with this change. The benchmarking was a simple python script that opened 100 concurrent threads (3 times to spot outliers) to a list of […]

  • Reorder all fields in Trac

    We decided to add a business justification field to our Trac instance today, but needed to put it directly below the description field so that it was in a more logical position for the users. It is not possible to intermingle custom ticket fields with standard ones (from within Trac), so editing the ticket template […]