|
|
@ -23,7 +23,7 @@ from OpenSSL import crypto
|
|
|
|
import shlex
|
|
|
|
import shlex
|
|
|
|
from sudsds import MethodNotFound
|
|
|
|
from sudsds import MethodNotFound
|
|
|
|
from calculate.core.server.cert_cmd import getHwAddr, getIpLocal
|
|
|
|
from calculate.core.server.cert_cmd import getHwAddr, getIpLocal
|
|
|
|
from calculate.core.server.replace_class import printTable
|
|
|
|
from calculate.core.server.replace_class import printTable,Methods
|
|
|
|
|
|
|
|
|
|
|
|
from calculate.core.client.progressbar import Bar,Percentage,ETA,ProgressBar
|
|
|
|
from calculate.core.client.progressbar import Bar,Percentage,ETA,ProgressBar
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
@ -358,7 +358,11 @@ def analysis(client, sid, s):
|
|
|
|
def get_message(client, item, sid, pid):
|
|
|
|
def get_message(client, item, sid, pid):
|
|
|
|
""" get one message by its type """
|
|
|
|
""" get one message by its type """
|
|
|
|
for case in switch(item.type):
|
|
|
|
for case in switch(item.type):
|
|
|
|
if case('normal') or case('plain'):
|
|
|
|
if case('normal'):
|
|
|
|
|
|
|
|
if item.message:
|
|
|
|
|
|
|
|
Methods().printSUCCESS(item.message)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if case('plain'):
|
|
|
|
# sys.stdout.flush()
|
|
|
|
# sys.stdout.flush()
|
|
|
|
# sys.stdout.write('\x1b[1;33m' + item.message + '\033[0m')
|
|
|
|
# sys.stdout.write('\x1b[1;33m' + item.message + '\033[0m')
|
|
|
|
if item.message:
|
|
|
|
if item.message:
|
|
|
@ -366,6 +370,17 @@ def get_message(client, item, sid, pid):
|
|
|
|
print p.sub('', item.message)
|
|
|
|
print p.sub('', item.message)
|
|
|
|
# print item.message
|
|
|
|
# print item.message
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if case('pre'):
|
|
|
|
|
|
|
|
Methods().printPre(item.message)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if case('choice'):
|
|
|
|
|
|
|
|
message,answers = item.message.split('|')
|
|
|
|
|
|
|
|
answers = map(lambda x:(x[0],x[1].strip(')')),
|
|
|
|
|
|
|
|
map(lambda x:x.split('('),
|
|
|
|
|
|
|
|
answers.split(',')))
|
|
|
|
|
|
|
|
answer = Methods().askChoice(message,answers)
|
|
|
|
|
|
|
|
client.service.send_message(sid, pid, answer)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
if case('progress'):
|
|
|
|
if case('progress'):
|
|
|
|
if not client.no_progress:
|
|
|
|
if not client.no_progress:
|
|
|
|
get_Progress(client, sid, pid, item.id)
|
|
|
|
get_Progress(client, sid, pid, item.id)
|
|
|
@ -387,6 +402,9 @@ def get_message(client, item, sid, pid):
|
|
|
|
if case('question'):
|
|
|
|
if case('question'):
|
|
|
|
send_Message(client, sid, pid, item)
|
|
|
|
send_Message(client, sid, pid, item)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
|
|
|
|
if case('confirm'):
|
|
|
|
|
|
|
|
send_Confirm(client, sid, pid, item)
|
|
|
|
|
|
|
|
return 1
|
|
|
|
if case('password'):
|
|
|
|
if case('password'):
|
|
|
|
send_Password(client, sid, pid, item)
|
|
|
|
send_Password(client, sid, pid, item)
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
@ -547,8 +565,26 @@ def get_Table(client, sid, pid, item):
|
|
|
|
table = client.service.get_table(sid, pid, item.id)
|
|
|
|
table = client.service.get_table(sid, pid, item.id)
|
|
|
|
show_table(table, item)
|
|
|
|
show_table(table, item)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_Confirm(client,sid,pid,item):
|
|
|
|
|
|
|
|
print
|
|
|
|
|
|
|
|
ask = ""
|
|
|
|
|
|
|
|
while not ask:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
ask = raw_input(item.message+ '(yes/no): ')
|
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
|
|
|
ask = 'no'
|
|
|
|
|
|
|
|
print
|
|
|
|
|
|
|
|
if ask.lower() in ['n', 'no']:
|
|
|
|
|
|
|
|
ask = "no"
|
|
|
|
|
|
|
|
elif ask.lower() in ['y', 'yes']:
|
|
|
|
|
|
|
|
ask = "yes"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
ask = ""
|
|
|
|
|
|
|
|
client.service.send_message(sid, pid, ask)
|
|
|
|
|
|
|
|
|
|
|
|
def send_Message(client, sid, pid, item):
|
|
|
|
def send_Message(client, sid, pid, item):
|
|
|
|
""" send answer to the question """
|
|
|
|
""" send answer to the question """
|
|
|
|
|
|
|
|
print
|
|
|
|
answer = raw_input (item.message)
|
|
|
|
answer = raw_input (item.message)
|
|
|
|
client.service.send_message(sid, pid, answer)
|
|
|
|
client.service.send_message(sid, pid, answer)
|
|
|
|
# show_result(result)
|
|
|
|
# show_result(result)
|
|
|
|