Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
#!/usr/bin/env python | |
# coding: utf-8 | |
import argparse | |
import os | |
import sys | |
import time | |
import atexit | |
import logging | |
import signal |
Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
by Sander Marechal
I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.
from celery import Task | |
from celery.task import task | |
from my_app.models import FailedTask | |
from django.db import models | |
@task(base=LogErrorsTask) | |
def some task(): | |
return result | |
class LogErrorsTask(Task): |
################################################################################ | |
# Method 1: Install using rpm packages (credit to DarkMukke) | |
# | |
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm | |
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7 | |
# WARNING: removing vim-minimal uninstalls `sudo` if you skip the second step | |
# make sure to at least run `yum install sudo` | |
yum -y remove vim-minimal vim-common vim-enhanced |
;(function(document, window, undefined) { | |
// wrap always your modules to avoid the namespace pollution | |
// use always the strict statement | |
'use strict'; | |
// you do not need to wrap all your code in an if statement... | |
if (!document.createElement('svg').getAttributeNS) return; | |
// shortcut to select any DOM element | |
var $ = document.querySelectorAll.bind(document), | |
// create an array with all the inputs to uste | |
// BTW I am sure that this solution is neither correct but it comes from the original code logic |