Package Ganga :: Package Runtime :: Module AMGA_repository_runtime
[hide private]
[frames] | no frames]

Source Code for Module Ganga.Runtime.AMGA_repository_runtime

 1   
 2  from Ganga.Utility.logging import getLogger,log_user_exception 
 3  logger = getLogger() 
 4  import Ganga.Utility.Config 
 5  config = Ganga.Utility.Config.getConfig('Configuration') 
 6   
 7  #keep the (names,regs) 
 8  names=[] 
 9  regs=[] 
10   
11 -def requiresGridProxy():
12 rtype = config['repositorytype'] 13 if 'Remote' in rtype: 14 remote_config = Ganga.Utility.Config.getConfig("%s_Repository"%rtype) 15 return bool(remote_config['reqSSL']) 16 else: 17 return False
18
19 -def bootstrap():
20 import os.path 21 22 global names,regs 23 24 names = ['jobs','templates'] 25 docstrings = ['default job registry', 'default registry of job templates'] 26 27 # debug 28 for c in config: 29 logger.debug('%s = %s',c,config[c]) 30 31 from Ganga.Core.JobRepository.ARDA import repositoryFactory 32 from Ganga.Core.exceptions import RepositoryError 33 34 def print_error(x): 35 for c in config: 36 logger.error('%s = %s',c,config[c]) 37 if config['repositorytype'] == 'RemoteAMGA': 38 logger.error('check login name, host and port number') 39 s = 'Cannot connect to the repository: '+str(x) 40 logger.error(s) 41 return s
42 43 reps = [] 44 try: 45 for n in names: 46 reps.append(repositoryFactory(subpath = n)) 47 except RepositoryError,x: 48 s = print_error(x) 49 raise 50 except Exception,x: 51 s = print_error(x) 52 log_user_exception(logger) 53 raise 54 55 from Ganga.GPIDev.Lib.JobRegistry import JobRegistryInstance, JobRegistryInterface, allJobRegistries 56 57 regs = map(lambda x: JobRegistryInstance(*x), zip(names,reps)) 58 59 from Ganga.GPIDev.Streamers.MigrationControl import migrated_jobs 60 assert(not migrated_jobs) # initially the list should be empty 61 62 for n,r in zip(names,regs): 63 allJobRegistries['native_'+n] = r 64 r._scan_repository() 65 # commit the migrated jobs (if any) 66 r._flush(migrated_jobs) 67 migrated_jobs[:] = [] 68 69 proxies = map(lambda x: JobRegistryInterface(x), regs) 70 71 logger.debug('registred repository atexit handler') 72 73 import atexit 74 atexit.register(shutdown) 75 76 return zip(names,proxies,docstrings) 77 78
79 -def shutdown():
80 global names,regs 81 from Ganga.Runtime.Repository_runtime import _shutdown 82 _shutdown(names,regs)
83