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 (_('Method not found for %s') %sym_link) if args.stop_consoled: wait_thread.stop() os.system('cl-consoled --stop') return 0 if args.session_clean: wait_thread.stop() session_clean(client) if args.session_info or args.session_num_info: wait_thread.stop() client_session_info(client, args.session_num_info) return 0 if args.session_list: wait_thread.stop() client_session_list(client) return 0 if args.list_pid: wait_thread.stop() if args.dump: from pid_information import client_pid_info client_pid_info(client) else: from pid_information import client_list_pid client_list_pid(client) if args.pid_res: wait_thread.stop() get_entire_frame(client, args.pid_res) return 0 if args.pid_kill: wait_thread.stop() from pid_information import client_pid_kill return client_pid_kill(client, args.pid_kill) retCode = 0 if not args.method: wait_thread.stop() client_list_methods(client) return 1 elif args.method and args.help: view_params = get_view_params(client, args.method + '_view', step = None, expert = True, onlyhelp = True) view = get_view(client, args.method, client.sid, view_params) wait_thread.stop() sys.stdout.write("\b") sys.stdout.flush() method_parser = get_method_argparser(view, args) method_parser.print_help() client.service.clear_method_cache(client.sid, args.method) else: try: client.frame_period = clVarsCore.Get('core.cl_core_get_frame_period') except: client.frame_period = 2 method_result = call_method(client, args, unknown_args, wait_thread) if method_result: client.no_progress = args.no_progress try: analysis(client, client.sid, method_result) except urllib2.URLError, e: _print (e) except KeyboardInterrupt: try: print mess = method_result[0][0] pid = int(mess.message) result = client.service.pid_kill(pid, client.sid) if result in [0,2]: print _('Process terminated') elif result == -1: print _("Certificate not found on the server") elif result == -2: print _("Session not matching your certificate") elif result == 1: print _("Failed to terminate the process") # get_entire_frame(client, pid) analysis(client, client.sid, method_result) except Exception, e: _print (e.message)
def __init__(self, parent, ClientObj): # super(ViewProc, self).__init__(parent) QtGui.QWidget.__init__(self, parent) # self._parent = parent self.ClientObj = ClientObj self.client = ClientObj.client self.pid = 0 client_pid_info(ClientObj, ClientObj.client, 0) list_pid = client_list_pid(self.ClientObj.client) ClientObj._parent.setWindowTitle ( \ _('View information about the running processes')\ + ' - ' + self.ClientObj.Name) self.lable_list = [] self.button_list = [] self.status_list = [] self.grid_layout = QtGui.QGridLayout() self.helpLabel = LabelWordWrap \ (_('View information about the running processes'), self) self.grid_layout.addWidget(self.helpLabel, 0, 0, 1, 0) if not list_pid: list_pid = [] for num in range (0, len(list_pid)): if list_pid[num] == ClientObj._parent.sys_update_pid: continue # add method name if self.ClientObj.process_dict[str(list_pid[num])].has_key \ ('method_name'): method_name = self.ClientObj.process_dict[str(list_pid[num])] \ ['method_name'] else: method_name = self.ClientObj.process_dict[str(list_pid[num])] \ ['name'] if self.ClientObj.method_names.has_key(method_name): view_method_name = self.ClientObj.method_names[method_name] # try: # view_method_name = self.ClientObj.param_objects \ # [method_name]['view_method_name'] # except: else: view_method_name = method_name try: view_method_name = view_method_name.encode('utf-8') except (UnicodeEncodeError, UnicodeDecodeError): pass self.lable_list.append(LabelWordWrap(str(view_method_name), self)) self.grid_layout.addWidget(self.lable_list[num], num+2,0) # add start time process # del mircosec time_text = ClientObj.process_dict[str(list_pid[num])]['time'].\ rsplit('.', 1)[0] self.grid_layout.addWidget(LabelWordWrap(time_text, self), num+2,1) # add status button if self.ClientObj.process_dict[str(list_pid[num])]['status'] == '1': kill_but_text = _('Kill the process? (It\'s active)') kill_button = QtGui.QPushButton(kill_but_text, self) kill_button.clicked.connect(self.kill_process \ (int(list_pid[num]), num+2, 2)) self.status_list.append(kill_button) if self.ClientObj.process_dict[str(list_pid[num])]['status'] =='0': self.status_list.append(LabelWordWrap \ (_('Process completed'), self)) if self.ClientObj.process_dict[str(list_pid[num])]['status'] =='2': self.status_list.append(LabelWordWrap \ (_('Process killed'), self)) self.grid_layout.addWidget(self.status_list[num], num+2, 2) # add 'View result' button button_text = _('View the result, PID %s') %str(list_pid[num]) Button = QtGui.QPushButton(button_text, self) Button.clicked.connect(self.onActivated(str(list_pid[num]), \ str(view_method_name))) self.button_list.append(Button) self.grid_layout.addWidget(self.button_list[num], num+2, 3) if not len(list_pid): self.grid_layout.addWidget(LabelWordWrap(_('No running processes' ' in the current session'), self)) else: self.grid_layout.addWidget(LabelWordWrap(_('Task name'), self),1,0) self.grid_layout.addWidget(LabelWordWrap(_('Start time'),self),1,1) self.grid_layout.addWidget(LabelWordWrap(_('Status'), self), 1,2) lbl = LabelWordWrap(_('Result'), self) lbl.setMinimumHeight(lbl.sizeHint().height()*3) self.grid_layout.addWidget(lbl, 1,3) # for clear memory after closed this window self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.grid_layout.setAlignment(QtCore.Qt.AlignTop) self.setLayout(self.grid_layout) self.show()