Пример #1
0
 def delete(self, x, y):
     """
     update deletion from the grid in the coordibate (x,y)
     delete content from coordinate from the queue in order to recreate the actions that led to the solution.
     """
     if (x, y) in self.read_only_tiles:
         print("READ ONLY TILE ON ( ", x, y, ") CAN'T DELETE")
         sys.exit()
     self.grid[y][x] = EMPTY_VALUE
     self.full_tiles.remove((x, y))
     self.actions_queue.append(Action(x, y))
Пример #2
0
 def insert(self, x, y, value):
     """
     update insetrion to the grid with the value in coordibate (x,y)
     insert coordinate and value to the queue in order to recreate the actions that led to the solution.
     """
     if (x, y) in self.read_only_tiles:
         print("READ ONLY TILE ON ( ", x, y, ") CAN'T INSERT VALUE", value)
         sys.exit()
     self.grid[y][x] = value
     self.full_tiles += [(x, y)]
     self.actions_queue.append((Action(x, y, value)))
Пример #3
0
    def __init__(self, game, settings, map_settings):
        super(ViewWidget, self).__init__()

        self.game = game

        #self.map_widget = GameWidget(game, map_settings)
        #self.map_widget.setParentItem(self)
        #self.map_widget.hide()

        self.game_widget = GameWidget(game, settings)
        self.game_widget.setParentItem(self)
        self.active = self.game_widget
        self.levels = [self.game_widget.level]#, self.map_widget.level]

        self._info = InfoWidget()
        self.setWidget('top_right', self._info)
        self._info.resize_event.connect(self._onInfoResizeEvent)
        self._info.gained_focus.connect(self._onWidgetGainedFocus)
        self._info.lost_focus.connect(self._onWidgetLostFocus)

        self._question = InputWidget(self)
        self.setWidget('middle_left', self._question)
        self._question.finished.connect(self._onAnswerRecieved)
        self._question.canceled.connect(self._onAnswerRecieved)

        self._stats = StatsWidget()
        self.setWidget('bottom_left', self._stats)

        self._log = LogWidget()
        self.setWidget('top_left', self._log)
        game.events['action_happened_in_game'].connect(self._log.appendDungeonMessage)

        game.events['game_started'].connect(self._onGameStarted)
        game.events['turn_finished'].connect(self._onTurnFinished)

        for group, commands in game.commands.items():
            for command in commands.values():
                parent = self if group in self.game_widget.menu_names else self.game_widget.level
                action = Action(
                    parent, 
                    command.desc, 
                    [command.key], 
                    self.game_widget._onAction,
                    args=(group, command.name)
                )
                parent.addAction(action)

        for name in self.game_widget.settings.keys(self._settings_group):
            action = Action(self, name, ['Ctrl+' + name[0]], self._onSettingsChanged, args=('settings', name))
            action.setCheckable(True)
            action.setChecked(settings[self._settings_group, name])
            self.addAction(action)
            self._onSettingsChanged('settings', name)
Пример #4
0
    def setup_other(self):
        self.all_cb_params = [
            self.cb_param_1, self.cb_param_2, self.cb_param_3,
            self.cb_param_4, self.cb_param_5, self.cb_param_6
        ]
        self.all_lb_params = [
            self.lb_param_1, self.lb_param_2, self.lb_param_3,
            self.lb_param_4, self.lb_param_5, self.lb_param_6
        ]
        self.thread_func = {
            'begin': self.begin, 'before': self.before, 'error': self.error,
            'after': self.after, 'end': self.end
        }

        self.forbid_when_run_ctl = self.all_cb_params + [
            self.btn_make_cmd, self.btn_cmd_parallel, self.btn_cmd_serial, self.txt_input]
        self.set_icon()
        self.set_init_ui()
        self.action = Action({'line_output': self.txt_output.appendPlainText}, self.info, self.i_fmt)
        self.bind()
Пример #5
0
def selectTodoItem(stdscr, todoList):
    """
    Opens a display of the *todoList* for the user to select
    an item and choose an action to take.
    """
    selectionList = displayTodoList(stdscr, todoList)
    currentSelection = selectionList.current()
    highlightSelection(stdscr, currentSelection)

    while True:
        lastSelection = currentSelection
        k = stdscr.get_wch()
        if k in ['k', curses.KEY_UP]:
            currentSelection = selectionList.prev()
        elif k in ['j', curses.KEY_DOWN]:
            currentSelection = selectionList.next()
        elif k in ['d']:
            return Action(Action.REMOVE, currentSelection.todoItem)
        elif k == 'q':
            return None

        switchSelection(stdscr, lastSelection, currentSelection)
        stdscr.refresh()
Пример #6
0
class MainWnd(object):
    def __init__(self):
        self.com_cmd = [
            u'路径拼接', u'SQL导入命令', u'DS7导入命令', u'DS7编译命令', u'DS7导出命令',
            u'DS9导入命令', u'DS9编译命令', u'DS9导出命令', u'取主机文件', u'格式化'
        ]
        self.ds_cmd = OrderedDict([
            (u'枚举工程', 'listprojects'), (u'枚举工程属性', 'listproperties'), (u'查看工程信息', 'projectinfo'),
            (u'枚举JOB', 'ljobs'), (u'查看JOB日志', 'logsum'), (u'查看JOB信息', 'jobinfo'), (u'查看JOB报告', 'report'),
            (u'重置JOB', 'run -mode RESET'), (u'查看JOB调用', 'linvocations'), (u'查看JOB步骤', 'lstages'),
            (u'枚举JOB参数', 'lparams'), (u'枚举环境变量', 'listenv'), (u'添加环境变量', 'envadd'),
            (u'修改环境变量', 'envset'), (u'删除环境变量', 'envdelete')
        ])
        self.info = OrderedDict([
            ('1.1.1.1', {
                'host': 'xx', 'user': '******', 'pwd': 'xx', 'prj': 'xx',
                'ssh_pwd': 'xx', 'ds_prj_home': 'xx', 'ds': 7,
                'login_param': '-server 1.1.1.1 -user xx -password xx'
            }),
            xxx
        ])
        self.prj = [
            'xx', 'xx', xx
        ]
        self.i_fmt = '{input}'

    def setupUi(self, wnd):
        self.wnd = wnd
        wnd.setObjectName("MainWnd")
        wnd.setMinimumSize(QtCore.QSize(711, 480))
        wnd.setMaximumSize(QtCore.QSize(711, 480))
        wnd.resize(711, 480)
        self.centralWidget = QtGui.QWidget(wnd)
        self.centralWidget.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu)
        self.centralWidget.setObjectName("centralWidget")
        self.layoutWidget = QtGui.QWidget(self.centralWidget)
        self.layoutWidget.setGeometry(QtCore.QRect(10, 10, 691, 441))
        self.layoutWidget.setObjectName("layoutWidget")
        self.vl_total = QtGui.QVBoxLayout(self.layoutWidget)
        self.vl_total.setSpacing(6)
        self.vl_total.setSizeConstraint(QtGui.QLayout.SetDefaultConstraint)
        self.vl_total.setContentsMargins(0, 0, 0, 0)
        self.vl_total.setObjectName("vl_total")
        self.hl_setting_input = QtGui.QHBoxLayout()
        self.hl_setting_input.setObjectName("hl_setting_input")
        self.gp_setting = QtGui.QGroupBox(self.layoutWidget)
        self.gp_setting.setObjectName("gp_setting")
        self.vl_setting = QtGui.QVBoxLayout(self.gp_setting)
        self.vl_setting.setObjectName("vl_setting")
        self.hl_action_type = QtGui.QHBoxLayout()
        self.hl_action_type.setObjectName("hl_action_type")
        self.lb_action_type = QtGui.QLabel(self.gp_setting)
        self.lb_action_type.setObjectName("lb_action_type")
        self.hl_action_type.addWidget(self.lb_action_type)
        self.cb_action_type = QtGui.QComboBox(self.gp_setting)
        self.cb_action_type.setEditable(False)
        self.cb_action_type.setObjectName("cb_action_type")
        self.hl_action_type.addWidget(self.cb_action_type)
        self.vl_setting.addLayout(self.hl_action_type)
        self.hl_param_1 = QtGui.QHBoxLayout()
        self.hl_param_1.setObjectName("hl_param_1")
        self.lb_param_1 = QtGui.QLabel(self.gp_setting)
        self.lb_param_1.setObjectName("lb_param_1")
        self.hl_param_1.addWidget(self.lb_param_1)
        self.cb_param_1 = QtGui.QComboBox(self.gp_setting)
        self.cb_param_1.setEditable(True)
        self.cb_param_1.setObjectName("cb_param_1")
        self.hl_param_1.addWidget(self.cb_param_1)
        self.vl_setting.addLayout(self.hl_param_1)
        self.hl_param_2 = QtGui.QHBoxLayout()
        self.hl_param_2.setObjectName("hl_param_2")
        self.lb_param_2 = QtGui.QLabel(self.gp_setting)
        self.lb_param_2.setObjectName("lb_param_2")
        self.hl_param_2.addWidget(self.lb_param_2)
        self.cb_param_2 = QtGui.QComboBox(self.gp_setting)
        self.cb_param_2.setEditable(True)
        self.cb_param_2.setObjectName("cb_param_2")
        self.hl_param_2.addWidget(self.cb_param_2)
        self.vl_setting.addLayout(self.hl_param_2)
        self.hl_param_3 = QtGui.QHBoxLayout()
        self.hl_param_3.setObjectName("hl_param_3")
        self.lb_param_3 = QtGui.QLabel(self.gp_setting)
        self.lb_param_3.setObjectName("lb_param_3")
        self.hl_param_3.addWidget(self.lb_param_3)
        self.cb_param_3 = QtGui.QComboBox(self.gp_setting)
        self.cb_param_3.setEditable(True)
        self.cb_param_3.setObjectName("cb_param_3")
        self.hl_param_3.addWidget(self.cb_param_3)
        self.vl_setting.addLayout(self.hl_param_3)
        self.hl_param_4 = QtGui.QHBoxLayout()
        self.hl_param_4.setObjectName("hl_param_4")
        self.lb_param_4 = QtGui.QLabel(self.gp_setting)
        self.lb_param_4.setObjectName("lb_param_4")
        self.hl_param_4.addWidget(self.lb_param_4)
        self.cb_param_4 = QtGui.QComboBox(self.gp_setting)
        self.cb_param_4.setEditable(True)
        self.cb_param_4.setObjectName("cb_param_4")
        self.hl_param_4.addWidget(self.cb_param_4)
        self.vl_setting.addLayout(self.hl_param_4)
        self.hl_param_5 = QtGui.QHBoxLayout()
        self.hl_param_5.setObjectName("hl_param_5")
        self.lb_param_5 = QtGui.QLabel(self.gp_setting)
        self.lb_param_5.setObjectName("lb_param_5")
        self.hl_param_5.addWidget(self.lb_param_5)
        self.cb_param_5 = QtGui.QComboBox(self.gp_setting)
        self.cb_param_5.setEditable(True)
        self.cb_param_5.setObjectName("cb_param_5")
        self.hl_param_5.addWidget(self.cb_param_5)
        self.vl_setting.addLayout(self.hl_param_5)
        self.hl_param_6 = QtGui.QHBoxLayout()
        self.hl_param_6.setObjectName("hl_param_6")
        self.lb_param_6 = QtGui.QLabel(self.gp_setting)
        self.lb_param_6.setObjectName("lb_param_6")
        self.hl_param_6.addWidget(self.lb_param_6)
        self.cb_param_6 = QtGui.QComboBox(self.gp_setting)
        self.cb_param_6.setEditable(True)
        self.cb_param_6.setObjectName("cb_param_6")
        self.hl_param_6.addWidget(self.cb_param_6)
        self.vl_setting.addLayout(self.hl_param_6)
        self.hl_setting_input.addWidget(self.gp_setting)
        self.gp_input = QtGui.QGroupBox(self.layoutWidget)
        self.gp_input.setObjectName("gp_input")
        self.hl_input = QtGui.QHBoxLayout(self.gp_input)
        self.hl_input.setObjectName("hl_input")
        self.txt_input = QtGui.QPlainTextEdit(self.gp_input)
        self.txt_input.setObjectName("txt_input")
        self.hl_input.addWidget(self.txt_input)
        self.hl_setting_input.addWidget(self.gp_input)
        self.vl_total.addLayout(self.hl_setting_input)
        self.gp_output = QtGui.QGroupBox(self.layoutWidget)
        self.gp_output.setObjectName("gp_output")
        self.hl_output = QtGui.QHBoxLayout(self.gp_output)
        self.hl_output.setObjectName("hl_output")
        self.txt_output = QtGui.QPlainTextEdit(self.gp_output)
        self.txt_output.setObjectName("txt_output")
        self.hl_output.addWidget(self.txt_output)
        self.vl_total.addWidget(self.gp_output)
        self.progressBar = QtGui.QProgressBar(self.layoutWidget)
        self.progressBar.setProperty("value", 24)
        self.progressBar.setObjectName("progressBar")
        self.vl_total.addWidget(self.progressBar)
        self.hl_execute = QtGui.QHBoxLayout()
        self.hl_execute.setObjectName("hl_execute")
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.hl_execute.addItem(spacerItem)
        self.btn_make_cmd = QtGui.QPushButton(self.layoutWidget)
        self.btn_make_cmd.setObjectName("btn_make_cmd")
        self.hl_execute.addWidget(self.btn_make_cmd)
        self.btn_cmd_parallel = QtGui.QPushButton(self.layoutWidget)
        self.btn_cmd_parallel.setObjectName("btn_cmd_parallel")
        self.hl_execute.addWidget(self.btn_cmd_parallel)
        self.btn_cmd_serial = QtGui.QPushButton(self.layoutWidget)
        self.btn_cmd_serial.setObjectName("btn_cmd_serial")
        self.hl_execute.addWidget(self.btn_cmd_serial)
        self.btn_copy_result = QtGui.QPushButton(self.layoutWidget)
        self.btn_copy_result.setObjectName("btn_copy_result")
        self.hl_execute.addWidget(self.btn_copy_result)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.hl_execute.addItem(spacerItem1)
        self.vl_total.addLayout(self.hl_execute)
        wnd.setCentralWidget(self.centralWidget)
        self.setup_other()
        self.retranslateUi(wnd)
        QtCore.QMetaObject.connectSlotsByName(wnd)
        self.enable_run_ctl(False)

    def enable_run_ctl(self, val):
        [x.setEnabled(val) for x in [self.btn_cmd_serial, self.btn_cmd_parallel]]

    def retranslateUi(self, wnd):
        wnd.setWindowTitle(QtGui.QApplication.translate("MainWnd", "版本辅助工具", None, QtGui.QApplication.UnicodeUTF8))
        self.gp_setting.setTitle(QtGui.QApplication.translate("MainWnd", "参数", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_action_type.setText(
            QtGui.QApplication.translate("MainWnd", "操作类型", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_param_1.setText(QtGui.QApplication.translate("MainWnd", "文件路径", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_param_2.setText(QtGui.QApplication.translate("MainWnd", "参数2", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_param_3.setText(QtGui.QApplication.translate("MainWnd", "参数3", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_param_4.setText(QtGui.QApplication.translate("MainWnd", "参数4", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_param_5.setText(QtGui.QApplication.translate("MainWnd", "参数5", None, QtGui.QApplication.UnicodeUTF8))
        self.lb_param_6.setText(QtGui.QApplication.translate("MainWnd", "参数6", None, QtGui.QApplication.UnicodeUTF8))
        self.gp_input.setTitle(QtGui.QApplication.translate("MainWnd", "输入", None, QtGui.QApplication.UnicodeUTF8))
        self.gp_output.setTitle(QtGui.QApplication.translate("MainWnd", "输出", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_make_cmd.setText(QtGui.QApplication.translate("MainWnd", "生成命令", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_cmd_parallel.setText(
            QtGui.QApplication.translate("MainWnd", "并行执行", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_cmd_serial.setText(
            QtGui.QApplication.translate("MainWnd", "串行执行", None, QtGui.QApplication.UnicodeUTF8))
        self.btn_copy_result.setText(
            QtGui.QApplication.translate("MainWnd", "复制结果", None, QtGui.QApplication.UnicodeUTF8))

    def set_icon(self):
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap('app.ico'), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.wnd.setWindowIcon(icon)

    def set_init_ui(self):
        [self.cb_action_type.addItem(x) for x in self.com_cmd + [x for x in self.ds_cmd]]
        self.action_type_change(0)  # 默认选中路径拼接的选项
        self.cb_action_type.setFixedWidth(150)
        self.ctl([u'文件路径'])
        [x.setFixedWidth(150) for x in self.all_cb_params]
        self.progressBar.setValue(0)
        self.wnd.statusBar().showMessage('')
        if False:
            self.wnd.statusBar().addPermanentWidget(self.progressBar)
            self.wnd.statusBar().addWidget(self.progressBar)
            self.wnd.statusBar().insertPermanentWidget(self.progressBar)
            self.wnd.statusBar().insertWidget(self.progressBar)
        self.wnd.setWindowTitle('status_bar')
        self.wnd.show()

    # noinspection PyUnresolvedReferences
    def bind(self):
        self.btn_make_cmd.clicked.connect(self.make_cmd)
        self.btn_copy_result.clicked.connect(self.copy_result)
        self.btn_cmd_parallel.clicked.connect(self.cmd_parallel)
        self.btn_cmd_serial.clicked.connect(self.cmd_serial)
        self.cb_action_type.currentIndexChanged.connect(self.action_type_change)

    def setup_other(self):
        self.all_cb_params = [
            self.cb_param_1, self.cb_param_2, self.cb_param_3,
            self.cb_param_4, self.cb_param_5, self.cb_param_6
        ]
        self.all_lb_params = [
            self.lb_param_1, self.lb_param_2, self.lb_param_3,
            self.lb_param_4, self.lb_param_5, self.lb_param_6
        ]
        self.thread_func = {
            'begin': self.begin, 'before': self.before, 'error': self.error,
            'after': self.after, 'end': self.end
        }

        self.forbid_when_run_ctl = self.all_cb_params + [
            self.btn_make_cmd, self.btn_cmd_parallel, self.btn_cmd_serial, self.txt_input]
        self.set_icon()
        self.set_init_ui()
        self.action = Action({'line_output': self.txt_output.appendPlainText}, self.info, self.i_fmt)
        self.bind()

    @staticmethod
    def ctl_text_list(ctl):
        return [x.strip() for x in ctl.toPlainText().split('\n') if x.strip() != '']

    def pre_check(self):
        cmd = self.param['cmd']
        file_list = []
        invalid_file_list = []
        if cmd in [u'DS7导入命令', u'DS9导入命令']:
            file_list = [x.split()[-1] for x in self.ctl_text_list(self.txt_output)]
        elif cmd in [u'路径拼接']:
            file_list = self.ctl_text_list(self.txt_output)
        elif cmd in [u'SQL导入命令']:
            file_list = [x.split('@')[-1].split(';')[0] for x in self.ctl_text_list(self.txt_output)]
        elif cmd in [u'DS7导出命令', u'DS9导出命令', u'取主机文件']:
            out_path = self.param['3']
            if not os.path.isdir(out_path):
                self.txt_output.setPlainText(u'输出路径 [%s] 不存在!' % out_path)
                return False

        if len(file_list) > 0:  # 当需要检查文件有效性时再检查
            [invalid_file_list.append(x) for x in file_list if not os.path.isfile(x)]
            if len(invalid_file_list) > 0:
                self.txt_output.clear()
                [self.txt_output.appendPlainText(u'文件 [%s] 不存在!' % x) for x in invalid_file_list]
                return False

        return True

    def trans_cmd(self):
        self.update_data()
        cmd = self.param['cmd']
        self.action.set_output_list(self.ctl_text_list(self.txt_output))
        if cmd in [u'路径拼接', u'SQL导入命令', u'格式化']:
            pass
        elif cmd in [u'DS7导入命令']:
            self.action.trans_ds7_import()
        elif cmd in [u'DS7编译命令']:
            self.action.trans_ds7_compile()
        elif cmd in [u'DS7导出命令']:
            self.action.trans_ds7_export()
        elif cmd in [u'DS9导入命令']:
            self.action.trans_ds9_import()
        elif cmd in [u'DS9编译命令']:
            self.action.trans_ds9_compile()
        elif cmd in [u'DS9导出命令']:
            self.action.trans_ds9_export()
        elif cmd in [u'取主机文件']:
            self.action.sftp_do_get_file()
        elif cmd in self.ds_cmd:
            self.action.trans_ds_cmd()
        else:
            assert False, 'error trans'
        return self.action.get_output_list()

    def make_cmd(self):
        self.enable_run_ctl(True)
        self.update_data()
        self.txt_output.clear()
        cmd = self.param['cmd']
        self.action.set_input_list(self.ctl_text_list(self.txt_input))
        # noinspection PyBroadException
        try:
            if cmd == u'路径拼接':
                self.action.path_splice(self.param['1'])
            elif cmd == u'SQL导入命令':
                self.action.sql_splice(self.param['1'])
            elif cmd == u'DS7导入命令':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                path = self.param['3']
                self.action.ds7_import(env, project, path)
            elif cmd == u'DS7编译命令':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                self.action.ds7_compile(env, project)
            elif cmd == u'DS7导出命令':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                path = self.param['3']
                self.action.ds7_export(env, project, path)
            elif cmd == u'DS9导入命令':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                path = self.param['3']
                self.action.ds9_import(env, project, path)
            elif cmd == u'DS9编译命令':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                self.action.ds9_compile(env, project)
            elif cmd == u'DS9导出命令':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                path = self.param['3']
                self.action.ds9_export(env, project, path)
            elif cmd == u'取主机文件':
                ip = self.param['1']
                project = self.param['2']
                path = self.param['3']
                prj_home = self.info[ip]['ds_prj_home']
                self.action.sftp_get_file(ip, prj_home, project, path)
            elif cmd == u'格式化':
                fmt_str = self.param['1']
                param_list = [self.param['%d' % i] for i in range(2, 7)]
                self.action.format_str(fmt_str, param_list)
            elif cmd == u'枚举工程':
                env = '{%s}' % self.param['1']
                self.action.listprojects(env)
            elif cmd == u'枚举工程属性':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                self.action.listproperties(env, project)
            elif cmd == u'查看工程信息':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                self.action.projectinfo(env, project)
            elif cmd == u'枚举JOB':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.ljobs(env, project, job)
            elif cmd == u'查看JOB日志':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.logsum(env, project, job)
            elif cmd == u'查看JOB信息':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.jobinfo(env, project, job)
            elif cmd == u'查看JOB报告':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.report(env, project, job)
            elif cmd == u'重置JOB':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.reset(env, project, job)
            elif cmd == u'查看JOB调用':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.linvocations(env, project, job)
            elif cmd == u'查看JOB步骤':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                self.action.lstages(env, project, job)
            elif cmd == u'枚举JOB参数':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                job = self.param['3']
                param = self.param['4']
                self.action.lparams(env, project, job, param)
            elif cmd == u'枚举环境变量':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                env_name = self.param['3']
                self.action.listenv(env, project, env_name)
            elif cmd == u'添加环境变量':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                env_name = self.param['3']
                env_type = self.param['4']
                env_value = self.param['5']
                self.action.envadd(env, env_name, env_type, env_value, project)
            elif cmd == u'修改环境变量':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                env_name = self.param['3']
                env_value = self.param['4']
                self.action.envset(env, env_name, env_value, project)
            elif cmd == u'删除环境变量':
                env = '{%s}' % self.param['1']
                project = self.param['2']
                env_name = self.param['3']
                self.action.envdelete(env, env_name, project)
            self.txt_output.appendPlainText('')
        except:
            self.txt_output.appendPlainText(traceback.format_exc())
            self.enable_run_ctl(False)
        if not self.pre_check():
            self.enable_run_ctl(False)

    def copy_result(self):
        self.txt_output.selectAll()
        self.txt_output.copy()

    def begin(self):
        self.before_status = [[x, x.isEnabled()] for x in self.forbid_when_run_ctl]
        self.progressBar.setMaximum(len(self.action.get_output_list()))
        self.progressBar.setValue(0)
        [x.setEnabled(False) for x in self.forbid_when_run_ctl]
        self.wnd.statusBar().showMessage(u'   正在执行,请耐心等待……')
        self.end_check('begin')

    def end_check(self, step, idx=0, info=None):
        if self.param['cmd'] in [u'DS7编译命令', u'DS9编译命令']:
            if step == 'begin':
                self.compile_fail_list = []
            elif step == 'end':
                fail_count = len(self.compile_fail_list)
                if fail_count == 0:
                    self.txt_output.appendPlainText(u'JOB全部编译成功!')
                elif fail_count > 0:
                    self.txt_output.appendPlainText(u'如下JOB编译失败:')
                    [self.txt_output.appendPlainText(x.split('.')[0]) for x in self.compile_fail_list]
                    self.txt_output.appendPlainText(u'失败信息请参见编译日志。')
            elif step == 'after':
                for x in info:
                    if x.find('Succeeded') != -1:  # 如果包含Succeeded关键字则说明编译成功了
                        return
                input_list = self.ctl_text_list(self.txt_input)
                self.compile_fail_list.append(input_list[idx] if idx < len(input_list) else '[%d]' % idx)

    def end(self):
        [ctl.setEnabled(status) for ctl, status in self.before_status]
        self.wnd.statusBar().showMessage('')
        self.end_check('end')

    def before(self, idx):
        h_idx = idx + 1
        if False:
            print 'before[%d]' % h_idx
            self.progressBar.setValue(h_idx + 1)

    def error(self, info, idx):
        h_idx = idx + 1
        self.txt_output.appendPlainText('[%d] %s' % (h_idx, info.decode('gbk')))

    def after(self, info, idx):
        h_idx = idx + 1
        [self.txt_output.appendPlainText('[%d] %s' % (h_idx, x.strip().decode('gbk'))) for x in info if x.strip() != '']
        self.progressBar.setValue(self.progressBar.value() + 1)
        self.end_check('after', idx, info)

    def cmd_parallel(self):
        self.trans_cmd()
        ThreadExec(self.action.get_output_list(), self.thread_func)

    def cmd_serial(self):
        self.trans_cmd()
        ThreadExec(self.action.get_output_list(), self.thread_func, 1)

    def ctl_reset(self, enable=False):
        self.cb_before_txt_list = [x.currentText() for x in self.all_cb_params]
        [ctl.setText(u'参数%d' % (i + 1)) for (i, ctl) in enumerate(self.all_lb_params)]
        [x.setEnabled(enable) for x in self.all_cb_params]
        [x.clear() for x in self.all_cb_params]
        [x.setEditText('') for x in self.all_cb_params]

    def ctl(self, *ctl_list):
        for i, info in enumerate(ctl_list):
            self.all_lb_params[i].setText(info[0])
            self.all_cb_params[i].clear()
            if len(info) == 2:
                [self.all_cb_params[i].addItem(x) for x in info[1]]
                before_txt = self.cb_before_txt_list[i].strip()
                if before_txt != '' and before_txt in info[1]:
                    self.all_cb_params[i].setEditText(before_txt)
            self.all_cb_params[i].setEnabled(True)

    def action_type_change(self, index):
        cmd = self.cb_action_type.itemText(index)
        self.ctl_reset()
        ip7 = [x for x in self.info if self.info[x]['ds'] == 7]
        ip9 = [x for x in self.info if self.info[x]['ds'] == 9]
        ip_all = self.info.keys()
        evt = [u'明文', u'密码']
        cb = ['', self.i_fmt]
        if cmd in [u'路径拼接', u'SQL导入命令']:
            self.ctl([u'文件路径'])
        elif cmd in [u'DS7导入命令', u'DS7导出命令']:
            self.ctl([u'环境选择', ip7], [u'工程选择', self.prj], [u'文件路径'])
        elif cmd in [u'DS9导入命令', u'DS9导出命令']:
            self.ctl([u'环境选择', ip9], [u'工程选择', self.prj], [u'文件路径'])
        elif cmd in [u'取主机文件']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'文件路径'])
        elif cmd in [u'DS7编译命令']:
            self.ctl([u'环境选择', ip7], [u'工程选择', self.prj])
        elif cmd in [u'DS9编译命令']:
            self.ctl([u'环境选择', ip9], [u'工程选择', self.prj])
        elif cmd in [u'枚举工程属性', u'查看工程信息']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj])
        elif cmd in [u'枚举工程']:
            self.ctl([u'环境选择', ip_all])
        elif cmd in [u'枚举JOB']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'JOB名(可选)', cb])
        elif cmd == u'枚举JOB参数':
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'JOB名'], [u'参数名(可选)', cb])
        elif cmd in [u'重置JOB', u'查看JOB日志', u'查看JOB信息', u'查看JOB报告', u'查看JOB调用', u'查看JOB步骤']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'JOB名', cb])
        elif cmd in [u'枚举环境变量']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'变量名(可选)', cb])
        elif cmd in [u'添加环境变量']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'变量名', cb], [u'变量类型', evt], [u'变量值'])
        elif cmd in [u'修改环境变量']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'变量名', cb], [u'变量值'])
        elif cmd in [u'删除环境变量']:
            self.ctl([u'环境选择', ip_all], [u'工程选择', self.prj], [u'变量名', cb])
        elif cmd in [u'格式化']:
            self.ctl([u'格式串'], *[[u'{%d}' % i] for i in range(5)])
        else:
            self.ctl_reset()

    def update_data(self):
        self.param = {
            'cmd': self.cb_action_type.currentText().strip(),
            '1': self.cb_param_1.currentText().strip(),
            '2': self.cb_param_2.currentText().strip(),
            '3': self.cb_param_3.currentText().strip(),
            '4': self.cb_param_4.currentText().strip(),
            '5': self.cb_param_5.currentText().strip(),
            '6': self.cb_param_6.currentText().strip()
        }