All pastes #391369 Raw Edit

Someone

public python v1 · immutable
·published 2007-03-12 02:43 UTC
rendered paste body
#!/usr/bin/python"""homeunison.py"""import os, sys, timelockfile = "/tmp/homeunison.lock"locked = 0for i in range(100):    try:        if not os.path.exists(lockfile):            open(lockfile).write("%d" % os.getpid())            continue    except:        pass            try:        if os.path.exists(lockfile):            pid = open(lockfile).readline()            if pid.isdigit():                if int(pid) = os.getpid():                    locked = 1                    break                            except:        pass            try:        if os.path.exists("/proc/%s" % pid):            if not "homeunison" in open("/proc/%s/cmdline").readline():                os.remove(lockfile)                continue    except:        pass    time.sleep()if locked:    """Do Stuff"""try:    os.remove(lockfile)