|
|
|
@ -21,7 +21,7 @@ from sudsds.transport import TransportError
|
|
|
|
|
from client_class import Client_suds
|
|
|
|
|
import traceback as tb
|
|
|
|
|
import time, logging
|
|
|
|
|
import os, sys
|
|
|
|
|
import os, sys, datetime
|
|
|
|
|
import threading, urllib2
|
|
|
|
|
from function import analysis, clear, get_entire_frame
|
|
|
|
|
from pid_information import client_list_methods
|
|
|
|
@ -65,6 +65,20 @@ def client_signal(client):
|
|
|
|
|
def https_server(client, args, unknown_args, url, clVarsCore, wait_thread):
|
|
|
|
|
client_post_auth(client)
|
|
|
|
|
|
|
|
|
|
sym_link = os.path.basename(sys.argv[0])
|
|
|
|
|
if sym_link != 'cl-console':
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
results = client.service.get_methods(client.sid, 'console')
|
|
|
|
|
find_flag = False
|
|
|
|
|
if hasattr (results, 'stringArray'):
|
|
|
|
|
for _array in results.stringArray:
|
|
|
|
|
if _array.string[0] == sym_link:
|
|
|
|
|
args.method = _array.string[1]
|
|
|
|
|
find_flag = True
|
|
|
|
|
break
|
|
|
|
|
if not find_flag:
|
|
|
|
|
_print (_('Not found method for symlink %s') %sym_link)
|
|
|
|
|
|
|
|
|
|
if args.stop_consoled:
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
os.system('cl-consoled --stop')
|
|
|
|
@ -111,6 +125,8 @@ def https_server(client, args, unknown_args, url, clVarsCore, wait_thread):
|
|
|
|
|
# print '6 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
|
method_parser, view = get_method_argparser(client, args)
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
sys.stdout.write("\b")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
method_parser.print_help()
|
|
|
|
|
# now = datetime.datetime.now()
|
|
|
|
|
# print '7 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
@ -157,9 +173,6 @@ def https_server(client, args, unknown_args, url, clVarsCore, wait_thread):
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
class StoppableThread(threading.Thread):
|
|
|
|
|
"""Thread class with a stop() method. The thread itself has to check
|
|
|
|
|
regularly for the stopped() condition."""
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super(StoppableThread, self).__init__()
|
|
|
|
|
self._stop = threading.Event()
|
|
|
|
@ -171,7 +184,7 @@ class StoppableThread(threading.Thread):
|
|
|
|
|
for i in l:
|
|
|
|
|
sys.stdout.write("\r\r" + i)
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
|
time.sleep(.02)
|
|
|
|
|
time.sleep(.1)
|
|
|
|
|
if self.stopped():
|
|
|
|
|
sys.stdout.write("\b")
|
|
|
|
|
sys.stdout.flush()
|
|
|
|
@ -190,7 +203,6 @@ def main():
|
|
|
|
|
args, unknown_args = parser.parse_known_args()
|
|
|
|
|
wait_thread = StoppableThread()
|
|
|
|
|
wait_thread.start()
|
|
|
|
|
|
|
|
|
|
if not args.method and args.help:
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
sys.stdout.write('\r')
|
|
|
|
@ -200,6 +212,10 @@ def main():
|
|
|
|
|
# print '1/2 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
if os.path.basename(sys.argv[0]) != 'cl-console':
|
|
|
|
|
args.method = '_temp_'
|
|
|
|
|
args.host = 'localhost'
|
|
|
|
|
|
|
|
|
|
if not args.method:
|
|
|
|
|
if unknown_args:
|
|
|
|
|
wait_thread.stop()
|
|
|
|
@ -276,7 +292,7 @@ def main():
|
|
|
|
|
del (client)
|
|
|
|
|
except urllib2.URLError, e:
|
|
|
|
|
wait_thread.stop()
|
|
|
|
|
print _('Failed to connect')+':', e
|
|
|
|
|
print '\b' + _('Failed to connect')+':', e
|
|
|
|
|
return 1
|
|
|
|
|
# server_host_name = 'dspiridonov.local.calculate.ru'
|
|
|
|
|
|
|
|
|
@ -316,15 +332,23 @@ def main():
|
|
|
|
|
else:
|
|
|
|
|
key_passwd = None
|
|
|
|
|
try:
|
|
|
|
|
# now = datetime.datetime.now()
|
|
|
|
|
# print '3/1 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
|
client = Client_suds(url, transport=HTTPSClientCertTransport \
|
|
|
|
|
(CERT_KEY, CERT_FILE, path_to_cert, password=key_passwd,
|
|
|
|
|
wait_thread = wait_thread))
|
|
|
|
|
if not wait_thread.isAlive():
|
|
|
|
|
wait_thread = StoppableThread()
|
|
|
|
|
wait_thread.start()
|
|
|
|
|
# now = datetime.datetime.now()
|
|
|
|
|
# print '3/2 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
|
client.wsdl.services[0].setlocation(url)
|
|
|
|
|
client.set_parameters (path_to_cert, CERT_FILE, CERT_KEY)
|
|
|
|
|
# now = datetime.datetime.now()
|
|
|
|
|
# print '3/3 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
|
client_post_cert(client, clVarsCore)
|
|
|
|
|
# now = datetime.datetime.now()
|
|
|
|
|
# print '3/4 ===> %ds %dms' %(now.second, now.microsecond)
|
|
|
|
|
Connect_Error = 0
|
|
|
|
|
except VerifyError, e:
|
|
|
|
|
# print e.value
|
|
|
|
|