def main(wait_thread): parser = parse() args, unknown_args = parser.parse_known_args() wait_thread.start() # if os.path.basename(sys.argv[0]) != 'cl-console': # args.method = '_temp_' # args.host = 'localhost' if not args.method and args.help: wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() parser.print_help() return 0 if not args.method: if unknown_args: wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() args = parser.parse_args() logging.basicConfig(level=logging.FATAL) logging.getLogger('sudsds.client').setLevel(logging.FATAL) logging.getLogger('sudsds.transport').setLevel(logging.FATAL) logging.getLogger('sudsds.transport.http').setLevel(logging.FATAL) logging.getLogger('sudsds.umx.typed').setLevel(logging.ERROR) clVarsCore = DataVarsCore() clVarsCore.importCore() clVarsCore.flIniFile() homePath = clVarsCore.Get('ur_home_path') port = args.port host = args.host path_to_cert = args.path_to_cert if not path_to_cert: path_to_cert = clVarsCore.Get('core.cl_client_cert_dir') path_to_cert = path_to_cert.replace("~",homePath) for dirs in ['', 'ca', 'trusted']: dir_path = os.path.join(path_to_cert, dirs) if not os.path.isdir(dir_path): if not makeDirectory(dir_path): wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() print _("Failed to create directory %s") %dir_path return 1 if args.update_crl: wait_thread.stop() getCRL = threading.Thread(target=get_CRL, args = (path_to_cert, )) getCRL.start() getCRL.join() print 'GRL updated' return 0 if args.by_host: wait_thread.stop() client_post_request (path_to_cert, args) return 0 if args.from_host: wait_thread.stop() client_get_cert (path_to_cert, args) return 0 url = "https://%s:%d/?wsdl" %(host, port) clear() serv_hostname = get_server_hostname(host, path_to_cert) get_name_flag = False if serv_hostname: Connect_Error = 1 crypto_Error = 0 client, Connect_Error, crypto_Error, passwd_flag, e = \ connect_with_cert (serv_hostname, path_to_cert, url, args, wait_thread, clVarsCore, crypto_Error, Connect_Error) if not wait_thread.isAlive(): wait_thread = StoppableThread() wait_thread.start() get_name_flag = True if Connect_Error: if crypto_Error and passwd_flag: wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() print _('Invalid password') # delete password from daemon list clear_password(host, port) elif e: wait_thread.stop() if type(e.message) != int: print _('Error: '), e get_name_flag = False if get_name_flag: try: client.port = port return_val = 1 try: return_val = https_server(client, args, unknown_args, url, \ clVarsCore, wait_thread) except urllib2.URLError, e: print _('Error: '), e except KeyboardInterrupt: wait_thread.stop() red = '\n'+'\033[31m * \033[0m' print red + _("Manually interrupted") except Exception, e: wait_thread.stop() if type(e.message) != int: if e.message: print e.message elif e.args: print e # tb.print_exc() return 1 wait_thread.stop() return return_val
if not wait_thread.isAlive(): wait_thread = StoppableThread() wait_thread.start() if Connect_Error == 0: break #If the certificate file misses if Connect_Error: if crypto_Error and passwd_flag: wait_thread.stop() sys.stdout.write('\r') sys.stdout.flush() print _('Invalid password') # delete password from daemon list clear_password(host, port) return 1 elif e: wait_thread.stop() if type(e.message) != int: print _('Error: '), e return 1 CERT_FILE = None CERT_KEY = None client = Client_suds(url, transport = HTTPSClientCertTransport \ (CERT_KEY, CERT_FILE, path_to_cert)) client.wsdl.services[0].setlocation(url) client.set_parameters (path_to_cert, CERT_FILE, CERT_KEY) client.port = port