Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
Файл: api.py Проект: t00m/Vazaar
 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'] = ''
Пример #4
0
 def __init__(self, loop=None):
     self.session = asyncio.get_event_loop().run_until_complete(
         utils.create_session(loop)
     )
Пример #5
0
 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)
     )
Пример #6
0
 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