def paths(clnk=None, api=None, elnk=None, ctsk=None): extensions = core.read_extend() if clnk: clnk_path = extensions['coreLink'][clnk]['path'] else: clnk_path = 'corr.main.coreLink' clnk_module = core.extend_load(clnk_path) if api: api_path = extensions['api'][api]['path'] else: api_path = 'corr.main.api' if elnk: elnk_path = extensions['execLink'][elnk]['path'] else: elnk_path = 'corr.main.execLink' if ctsk: ctsk_path = extensions['corrTask'][ctsk]['path'] else: ctsk_path = 'corr.main.corrTask' return [clnk_module, api_path, elnk_path, ctsk_path]
def __init__(self, pid=None, name=None, refresh=10, aid=None, origin=None, tag=None, clnk_module=None, api_module=None, elnk_module=None, timeout=60*60): self.pid = pid self.origin = origin self.aid = aid self.name = name self.refresh = refresh self.root = None self.history = [] self.tag = tag self.record = '' self.info = None self.timeout = timeout self.clnk_module = clnk_module self.link = elnk_module.ExecLink(tag=tag, watcher='corrTask') extensions = core.read_extend() self.api_module = api_module self.records = [] self.request = {} self.ios = {'inputs':[], 'outputs':[]}
def handle(config, conx, register, sync, align, unregister, name, host, port, key, watch, unwatch, list, show, tag, newtag, upload, file, env, path, obj, group, force, extend, add, delete, all, alias, impl, clnk, api, elnk, ctsk): def paths(clnk=None, api=None, elnk=None, ctsk=None): extensions = core.read_extend() if clnk: clnk_path = extensions['coreLink'][clnk]['path'] else: clnk_path = 'corr.main.coreLink' clnk_module = core.extend_load(clnk_path) if api: api_path = extensions['api'][api]['path'] else: api_path = 'corr.main.api' if elnk: elnk_path = extensions['execLink'][elnk]['path'] else: elnk_path = 'corr.main.execLink' if ctsk: ctsk_path = extensions['corrTask'][ctsk]['path'] else: ctsk_path = 'corr.main.corrTask' return [clnk_module, api_path, elnk_path, ctsk_path] if extend: extensions = core.read_extend() if add: if clnk: core.extension_add(extensions, 'coreLink') elif api: core.extension_add(extensions, 'api') elif elnk: core.extension_add(extensions, 'execLink') elif ctsk: core.extension_add(extensions, 'corrTask') else: # # print "Unknown extension group -- interoerate not supported yet." pass if delete: if clnk: core.extension_delete(extensions, 'coreLink', alias) elif api: core.extension_delete(extensions, 'api', alias) elif elnk: core.extension_delete(extensions, 'execLink', alias) elif ctsk: core.extension_delete(extensions, 'corrTask', alias) if all: core.extension_all(extensions) elif newtag and name: extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].tag(name=name, api=extends[1], elnk=extends[2], ctsk=extends[3]) elif list: extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) regs = extends[0].list(api=extends[1], elnk=extends[2], ctsk=extends[3]) for reg in regs: print "{0}\t{1}\t{2}\t{3}".format( reg['name'], str(reg['tags']), reg['status']['stamp'], reg['status']['value']) elif show and (name or tag): extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) print extends[0].show(name=name, tag=tag, api=extends[1], elnk=extends[2], ctsk=extends[3]) elif align: extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].align(api=extends[1], elnk=extends[2], ctsk=extends[3]) elif register and name: extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].register(name=name, api=extends[1], elnk=extends[2], ctsk=extends[3]) elif sync: extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].sync(name=name, tag=tag, force=force, api=extends[1], elnk=extends[2], ctsk=extends[3]) elif unregister: extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].unregister(name=name, api=extends[1], elnk=extends[2], ctsk=extends[3]) elif watch and (name or tag): extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].watch(name=name, tag=tag, api=extends[1], elnk=extends[2], ctsk=extends[3]) elif unwatch and (name or tag): extends = paths(clnk=clnk, api=api, elnk=elnk, ctsk=ctsk) extends[0].unwatch(name=name, tag=tag, api=extends[1], elnk=extends[2], ctsk=extends[3]) else: if clnk: extensions = core.read_extend() clnk_path = extensions['coreLink'][alias]['path'] else: clnk_path = 'corr.main.coreLink' clnk_module = core.extend_load(clnk_path) clnk_module.handle()