def deployApp(args): """Deploy Boinc App with lock""" print "Asking to enter in execution with lock mode..." with LockFile(args['lockfile'], wait=True): print "acquire the lock file..." deployManagement(args) print "Exit execution with lock..."
def run_setup(with_extensions): def _run_setup(): kwargs_tmp = dict(kwargs) if with_extensions: monotonic_libraries = [] if sys.platform == 'linux2': monotonic_libraries = ['rt'] kwargs_tmp['ext_modules'] = [ Extension("newrelic.packages.wrapt._wrappers", ["newrelic/packages/wrapt/_wrappers.c"]), Extension("newrelic.common._monotonic", ["newrelic/common/_monotonic.c"], libraries=monotonic_libraries), Extension("newrelic.core._thread_utilization", ["newrelic/core/_thread_utilization.c"]), ] kwargs_tmp['cmdclass'] = dict(build_ext=optional_build_ext) setup(**kwargs_tmp) if os.environ.get('TDDIUM') is not None: try: print('INFO: Running under tddium. Use lock.') from lock_file import LockFile except ImportError: print('ERROR: Cannot import locking mechanism.') _run_setup() else: print('INFO: Attempting to create lock file.') with LockFile('setup.lock', wait=True): _run_setup() else: _run_setup()
def lock(name=""): mkdir("%s/lock" % os.environ["SCRAP_DIR"]) lock_file = "%s/lock/%s.%s.%s" % (os.environ["SCRAP_DIR"], os.path.basename(sys.argv[0]), os.environ["STRAT"], name) # Check for previously running instance try: lock_f = LockFile(lock_file, wait=False, remove=False) except LockError: error("Could not create lockfile, previous instance running?") sys.exit(0) return lock_f
def run_setup(with_extensions): def _run_setup(): # Create a local copy of kwargs, if there is no c compiler run_setup # will need to be re-run, and these arguments can not be present. kwargs_tmp = dict(kwargs) if with_extensions: monotonic_libraries = [] if with_librt(): monotonic_libraries = ['rt'] kwargs_tmp['ext_modules'] = [ Extension("newrelic.packages.wrapt._wrappers", ["newrelic/packages/wrapt/_wrappers.c"]), Extension("newrelic.common._monotonic", ["newrelic/common/_monotonic.c"], libraries=monotonic_libraries), Extension("newrelic.core._thread_utilization", ["newrelic/core/_thread_utilization.c"]), ] kwargs_tmp['cmdclass'] = dict(build_ext=optional_build_ext) setup(**kwargs_tmp) if os.environ.get('TDDIUM') is not None: try: print('INFO: Running under tddium. Use lock.') from lock_file import LockFile except ImportError: print('ERROR: Cannot import locking mechanism.') _run_setup() else: print('INFO: Attempting to create lock file.') with LockFile('setup.lock', wait=True): _run_setup() else: _run_setup()
# First check the user provided a directory to run in... if len(sys.argv) < 2: print 'Creates a database for handwriting spliting and recognition, using all line graphs found in the given directory and its subdirectories. Database is written into the directory as hwr.rf' print 'Usage:' print 'python main.py <dir to make db in> [optimise]' print sys.exit(1) root_dir = sys.argv[1] # If the user has requested optimisation then do just that - basically it either does random offsets from the best in a chain, or a random start, depending on a draw - totally ad-hoc... if 'optimise' in sys.argv: runs = [] # Load runs that have been done thus far... with LockFile('runs.json', 'r') as f: if f != None: runs = json.load(f) ind_runs = to_index(runs) # Decide what to do based on runs thus far - in a While loop as it can fail... approach = '' while True: if len(runs) < 32 or random.random() < 0.1: approach = 'random' # Totally random initalisation... params = {} for key in ranges.keys(): params[key] = random.randrange(len(ranges[key]))