Beispiel #1
0
 def set_directory(self, dir):
     if QTools.test_dir(dir, 'w'):
         self.lock_dir = dir
         return True
     return False
Beispiel #2
0
import os
import re

LOCK_SUPPORT = False
try:
    import lock_file
    LOCK_SUPPORT = True
except:
    pass

import QTools

LOCK_DIRECTORY = ''
if os.environ.has_key('CNC_LOCK_DIRECTORY') and QTools.test_dir(os.environ['CNC_LOCK_DIRECTORY'], 'w'):
    LOCK_DIRECTORY = os.environ['CNC_LOCK_DIRECTORY']
if not QTools.test_dir(LOCK_DIRECTORY, 'w'):
    LOCK_DIRECTORY = '/opt/util/var/lock'
if not QTools.test_dir(LOCK_DIRECTORY, 'w'):
    LOCK_DIRECTORY = '/home/jdedwards/quasar/trunk/util/var/lock'
if not QTools.test_dir(LOCK_DIRECTORY, 'w'):
    LOCK_DIRECTORY = '.'

class QExLocked(Exception):
    """signals that the lock could not be acquired"""

class QLock:
    def __init__(self, name=None):
        self.lock_dir = LOCK_DIRECTORY
        self.lock_path = None
        self.lock_pid = None
        self.lock = None