def create_connection(self, params): """Create a new connection""" session = create_session() try: cname = params[0] # Connection Name ctype = params[1] # Connection Type cdata = params[2] # Connection Extra Data if (cname and ctype and cdata): # FIXME: check params connection = {} connection['name'] = cname connection['type'] = ctype connection['data'] = cdata created = self.write_connection(connection) if created: self.log.debug(_("Connection '%s' created" % cname)) session['rc'] = '0' session['output'] = cname else: session['rc'] = '-1' session['output'] = "Connection '%s' could not be created." % cname except: session['rc'] = '-1' session['output'] = "Error. Connection '%s' could not be created." % cname return session
def list_connections(self): """Returns a list of available connections""" session = create_session() lc = [] try: for conn in os.listdir(LPATH['CONNECTIONS']): lc.append(conn) session['output'] = ':'.join(lc) # conn1:conn2:...:connN session['rc'] = '0' except Exception, error: session['rc'] = '-1' session['output'] = error
def stop_application(self, *args): """Stop Vazaar""" session = create_session() try: self.app.store.close() self.log.debug( _("Stopping Vazaar... see you later!") ) loop = self.app.get_mainloop() loop.quit() session['rc'] = '0' session['output'] = '' except Exception, error: self.log.error(error) session['rc'] = '-1' session['output'] = ''
def __init__(self, loop=None): self.session = asyncio.get_event_loop().run_until_complete( utils.create_session(loop) )
def __init__(self, loop=None): self.baseurl = 'http://localhost:{}'.format(constants.TASKS_PORT) self.session = asyncio.get_event_loop().run_until_complete( utils.create_session(loop) )
def use_connection(self, params): """Stop using current connection and use a new one""" session = create_session() session['rc'] = '-1' session['output'] = 'Not Implemented' return session