2019-06-12 01:28:20 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.join(CURDIR))
|
|
|
|
|
|
|
|
import uexpect
|
|
|
|
|
|
|
|
prompt = ':\) '
|
|
|
|
end_of_block = r'.*\r\n.*\r\n'
|
|
|
|
|
|
|
|
def client(command=None, name='', log=None):
|
2019-07-10 03:27:19 +00:00
|
|
|
client = uexpect.spawn(['/bin/bash','--noediting'])
|
2019-06-12 01:28:20 +00:00
|
|
|
if command is None:
|
2019-07-10 03:27:19 +00:00
|
|
|
command = os.environ.get('CLICKHOUSE_BINARY', 'clickhouse') + '-client'
|
2019-06-12 01:28:20 +00:00
|
|
|
client.eol('\r')
|
|
|
|
client.logger(log, prefix=name)
|
2019-06-13 10:36:59 +00:00
|
|
|
client.timeout(20)
|
2019-07-10 03:27:19 +00:00
|
|
|
client.expect('[#\$] ', timeout=2)
|
|
|
|
client.send(command)
|
2019-06-12 01:28:20 +00:00
|
|
|
return client
|