loadit/client.py
def _request(self, is_redirected=False, **kwargs):
        """
        Request something to the server.
        """
        connection = Connection(self.server_address)

        try:
            # Authentication
            self.authenticate(connection, user=kwargs.pop('user', None), password=kwargs.pop('password', None))

            # Sending request
            if is_redirected:
                connection.send({key: kwargs[key] for key in ('request_type', 'path')})
            else:
                connection.send(kwargs)

            data = connection.recv()

            # Redirecting request (if necessary)
            if type(data) is dict and 'redirection_address' in data:

                for key in data:

                    if key != 'redirection_address':
                        kwargs[key] = data[key]

                connection.kill()
                connection.connect(tuple(data['redirection_address']))
                self.authenticate(connection)
                connection.send(kwargs)
                data = connection.recv()

            if type(data) is dict and 'msg' in data and data['msg']:
                log.info(data['msg'])

            # Processing request
            if kwargs['request_type'] == 'sync_databases':

                while data['msg'] != 'Done!':
                    data = connection.recv()
                    log.info(data['msg'])

            elif kwargs['request_type'] == 'new_batch':
                send_tables(connection, kwargs['files'], data)
                data = connection.recv()
            elif kwargs['request_type'] == 'query':
                reader = pa.RecordBatchStreamReader(pa.BufferReader(connection.recv().getbuffer()))
                log.info('Done!')
                data['batch'] = reader.read_next_batch()
            elif kwargs['request_type'] == 'add_attachment':
                log.info(f"Transferring '{os.path.basename(kwargs['file'])}' ({humansize(os.path.getsize(kwargs['file']))})...")
                connection.send_file(kwargs['file'])
                data = connection.recv()
            elif kwargs['request_type'] == 'download_attachment':
                connection.recv_file(os.path.join(kwargs['output_path'], kwargs['name']))
                data = connection.recv()

            return data
        finally:
            connection.kill()

        Request something to the server.
        
Request something to the server.
Request something to the server .
def _request(self, is_redirected=False, **kwargs):
        connection = Connection(self.server_address)
        try:
            self.authenticate(connection, user=kwargs.pop('user', None), password=kwargs.pop('password', None))
            if is_redirected:
                connection.send({key: kwargs[key] for key in ('request_type', 'path')})
            else:
                connection.send(kwargs)
            data = connection.recv()
            if type(data) is dict and 'redirection_address' in data:
                for key in data:
                    if key != 'redirection_address':
                        kwargs[key] = data[key]
                connection.kill()
                connection.connect(tuple(data['redirection_address']))
                self.authenticate(connection)
                connection.send(kwargs)
                data = connection.recv()
            if type(data) is dict and 'msg' in data and data['msg']:
                log.info(data['msg'])
            if kwargs['request_type'] == 'sync_databases':
                while data['msg'] != 'Done!':
                    data = connection.recv()
                    log.info(data['msg'])
            elif kwargs['request_type'] == 'new_batch':
                send_tables(connection, kwargs['files'], data)
                data = connection.recv()
            elif kwargs['request_type'] == 'query':
                reader = pa.RecordBatchStreamReader(pa.BufferReader(connection.recv().getbuffer()))
                log.info('Done!')
                data['batch'] = reader.read_next_batch()
            elif kwargs['request_type'] == 'add_attachment':
                log.info(f"Transferring '{os.path.basename(kwargs['file'])}' ({humansize(os.path.getsize(kwargs['file']))})...")
                connection.send_file(kwargs['file'])
                data = connection.recv()
            elif kwargs['request_type'] == 'download_attachment':
                connection.recv_file(os.path.join(kwargs['output_path'], kwargs['name']))
                data = connection.recv()
            return data
        finally:
            connection.kill()
def _request ( self , is_redirected = False , ** kwargs ) : connection = Connection ( self . server_address ) try : self . authenticate ( connection , user = kwargs . pop ( 'user' , None ) , password = kwargs . pop ( 'password' , None ) ) if is_redirected : connection . send ( { key : kwargs [ key ] for key in ( 'request_type' , 'path' ) } ) else : connection . send ( kwargs ) data = connection . recv ( ) if type ( data ) is dict and 'redirection_address' in data : for key in data : if key != 'redirection_address' : kwargs [ key ] = data [ key ] connection . kill ( ) connection . connect ( tuple ( data [ 'redirection_address' ] ) ) self . authenticate ( connection ) connection . send ( kwargs ) data = connection . recv ( ) if type ( data ) is dict and 'msg' in data and data [ 'msg' ] : log . info ( data [ 'msg' ] ) if kwargs [ 'request_type' ] == 'sync_databases' : while data [ 'msg' ] != 'Done!' : data = connection . recv ( ) log . info ( data [ 'msg' ] ) elif kwargs [ 'request_type' ] == 'new_batch' : send_tables ( connection , kwargs [ 'files' ] , data ) data = connection . recv ( ) elif kwargs [ 'request_type' ] == 'query' : reader = pa . RecordBatchStreamReader ( pa . BufferReader ( connection . recv ( ) . getbuffer ( ) ) ) log . info ( 'Done!' ) data [ 'batch' ] = reader . read_next_batch ( ) elif kwargs [ 'request_type' ] == 'add_attachment' : log . info ( f"Transferring '{os.path.basename(kwargs['file'])}' ({humansize(os.path.getsize(kwargs['file']))})..." ) connection . send_file ( kwargs [ 'file' ] ) data = connection . recv ( ) elif kwargs [ 'request_type' ] == 'download_attachment' : connection . recv_file ( os . path . join ( kwargs [ 'output_path' ] , kwargs [ 'name' ] ) ) data = connection . recv ( ) return data finally : connection . kill ( )
Request something to the server.
Request something to the server .
"""
        Request something to the server.
        """ # Authentication # Sending request # Redirecting request (if necessary) # Processing request
self
is_redirected