def on_cleanup(): app.cleanup()
import cache import sandbox import sandboxlib print('') if not os.path.exists('./VERSION'): if os.path.basename(os.getcwd()) != 'definitions': if os.path.isdir(os.path.join(os.getcwd(), 'definitions')): os.chdir(os.path.join(os.getcwd(), 'definitions')) else: if os.path.isdir(os.path.join(os.getcwd(), '..', 'definitions')): os.chdir(os.path.join(os.getcwd(), '..', 'definitions')) app.setup(sys.argv) app.cleanup(app.config['tmp']) with app.timer('TOTAL'): tmp_lock = open(os.path.join(app.config['tmp'], 'lock'), 'r') fcntl.flock(tmp_lock, fcntl.LOCK_SH | fcntl.LOCK_NB) target = os.path.join(app.config['defdir'], app.config['target']) app.log('TARGET', 'Target is %s' % target, app.config['arch']) with app.timer('DEFINITIONS', 'parsing %s' % app.config['def-version']): defs = Definitions() with app.timer('CACHE-KEYS', 'cache-key calculations'): cache.cache_key(defs, app.config['target']) cache.cull(app.config['artifacts']) target = defs.get(app.config['target']) if app.config['total'] == 0 or (app.config['total'] == 1 and
def test_cleanup(): assert app.cleanup() == "Success\n"
from definitions import Definitions import cache import sandbox import sandboxlib print('') if not os.path.exists('./VERSION'): if os.path.basename(os.getcwd()) != 'definitions': if os.path.isdir(os.path.join(os.getcwd(), 'definitions')): os.chdir(os.path.join(os.getcwd(), 'definitions')) else: if os.path.isdir(os.path.join(os.getcwd(), '..', 'definitions')): os.chdir(os.path.join(os.getcwd(), '..', 'definitions')) app.setup(sys.argv) app.cleanup(app.config['tmp']) with app.timer('TOTAL'): tmp_lock = open(os.path.join(app.config['tmp'], 'lock'), 'r') fcntl.flock(tmp_lock, fcntl.LOCK_SH | fcntl.LOCK_NB) target = os.path.join(app.config['defdir'], app.config['target']) app.log('TARGET', 'Target is %s' % target, app.config['arch']) with app.timer('DEFINITIONS', 'parsing %s' % app.config['def-version']): defs = Definitions() with app.timer('CACHE-KEYS', 'cache-key calculations'): cache.cache_key(defs, app.config['target']) cache.cull(app.config['artifacts']) target = defs.get(app.config['target']) if app.config['total'] == 0 or (app.config['total'] == 1
log('uri too long: %s',s) continue p=unicode(p) if len(p)>settings.max_uri_length: log('uri too long: %s',p) continue datatype=None if type(o) is rdflib.Literal: datatype,o=convert_literal(o) if datatype is None or o is None: continue else: o=unicode(o) if len(o)>settings.max_uri_length: log('uri too long: %s',o) continue if not options.dry_run: app.new_triple(s,p,o,datatype,options) except Exception: traceback.print_exc() if not options.dry_run: app.save_state() sys.exit(1) if not options.dry_run: app.cleanup(options) app.save_state()
log('COUNT', '%s has %s %s' % (config['target'], config[kind], kind)) log('RESULT', 'Cache-key for target is at', config['result-file']) print('') original_cwd = os.getcwd() if not os.path.exists('./VERSION'): if os.path.basename(os.getcwd()) != 'definitions': if os.path.isdir(os.path.join(os.getcwd(), 'definitions')): os.chdir(os.path.join(os.getcwd(), 'definitions')) else: if os.path.isdir(os.path.join(os.getcwd(), '..', 'definitions')): os.chdir(os.path.join(os.getcwd(), '..', 'definitions')) setup(sys.argv, original_cwd) cleanup(config['tmp']) with timer('TOTAL'): tmp_lock = open(os.path.join(config['tmp'], 'lock'), 'r') fcntl.flock(tmp_lock, fcntl.LOCK_SH | fcntl.LOCK_NB) target = os.path.join(config['defdir'], config['target']) log('TARGET', 'Target is %s' % target, config['arch']) with timer('DEFINITIONS', 'parsing %s' % config['def-version']): app.defs = Pots() target = app.defs.get(config['target']) if config.get('mode', 'normal') == 'parse-only': Pipeline(target) os._exit(0)
for kind in ['systems', 'strata', 'chunks']: log('COUNT', '%s has %s %s' % (config['target'], config[kind], kind)) log('RESULT', 'Cache-key for target is at', config['result-file']) print('') if not os.path.exists('./VERSION'): if os.path.basename(os.getcwd()) != 'definitions': if os.path.isdir(os.path.join(os.getcwd(), 'definitions')): os.chdir(os.path.join(os.getcwd(), 'definitions')) else: if os.path.isdir(os.path.join(os.getcwd(), '..', 'definitions')): os.chdir(os.path.join(os.getcwd(), '..', 'definitions')) setup(sys.argv) cleanup(config['tmp']) with timer('TOTAL'): tmp_lock = open(os.path.join(config['tmp'], 'lock'), 'r') fcntl.flock(tmp_lock, fcntl.LOCK_SH | fcntl.LOCK_NB) target = os.path.join(config['defdir'], config['target']) log('TARGET', 'Target is %s' % target, config['arch']) with timer('DEFINITIONS', 'parsing %s' % config['def-version']): app.defs = Pots() target = app.defs.get(config['target']) if config.get('mode', 'normal') == 'parse-only': Pipeline(target) os._exit(0)
"""Performs a cleanup of Orchest controlled resources. This is used to ensure that on Orchest start and stop the system remains in a consistent state and without dangling resources like pods or sessions. """ from app import cleanup if __name__ == "__main__": cleanup()