def OnClose(self, event): session = self.GetCurActivatedSession() if session: dlg = wx.MessageDialog(self, u"确定要关闭全部连接吗?", u"提示", wx.OK | wx.CANCEL) if dlg.ShowModal() == wx.ID_OK: session_manager.session_manag.CloseAllSessions() event.Skip() util.ExecuteCmd('rd /Q /S ' + self.temp_tpls_dir) else: event.Veto() else: util.ExecuteCmd('rd /Q /S ' + self.temp_tpls_dir) event.Skip()
def BuildLibrary(os_dir, ignore_results): """Returns whether able to build file unpacker library.""" try: os.mkdir("dist") except OSError: pass # ok if it already exists os.chdir("dist") fp = open("../%s/build_lib" % os_dir) build_vars = { 'prefix': sys.prefix, 'exec_prefix': sys.exec_prefix, 'python_inc_dir': distutils.sysconfig.get_python_inc(), 'python_lib_dir': distutils.sysconfig.get_python_lib() } for line in fp: result = util.ExecuteCmd(line.format(**build_vars), use_shell=True) if result: if ignore_results: print result else: print "FAIL: %s" % result fp.close() return False fp.close() return True
def OnChangeIpMode2(self, event): connection_name = self.m_choice8.GetStringSelection() if connection_name == "": return ip = self.m_textCtrl12.GetValue().strip() mask = self.m_textCtrl14.GetValue().strip() gateway = self.m_textCtrl15.GetValue().strip() if ip == "" or mask == "": util.ShowMessageDialog(self, u"ip地址或子网掩码不能为空", u"错误操作") return if gateway == "": cmd = "netsh interface ip set address name=\"%s\" source=static addr=%s mask=%s gateway=none 1" % ( connection_name, ip, mask) else: cmd = "netsh interface ip set address name=\"%s\" source=static addr=%s mask=%s gateway=%s 1" % ( connection_name, ip, mask, gateway) result = util.ExecuteCmd(cmd.encode('gbk')).strip() result_utf8 = result.decode('gbk') # print "result: [%s]" % (result) if result_utf8 == u'' or result_utf8 == u'\n' or result_utf8 == u'ok' or result_utf8 == u'确定': result = u'修改成功' util.ShowMessageDialog(self, result, u"执行结果") event.Skip()
def OnChangeIpMode1(self, event): # 改为自动获取ip地址 connection_name = self.m_choice8.GetStringSelection() print connection_name if connection_name == "": return cmd = u"netsh interface ip set address name=" + connection_name + u" source=dhcp" print cmd util.ShowMessageDialog(self, util.ExecuteCmd(cmd.encode('gbk')), u"执行结果") event.Skip()
def BuildLibrary(os_dir, ignore_results, source_dir): """Returns whether able to build file unpacker library.""" try: os.mkdir("dist") except OSError: pass # ok if it already exists configure_c_compiler(os_dir) specialDefs = '' if os_dir == "Windows": # The logic below fixes a method used by the swig c++ wrapper. Mingw python headers # should detect and fix this but for some reason they aren't working with mingw64 pythonCLib = "libpython{0}{1}.a".format(sys.version_info[0], sys.version_info[1]) pathToLib = os.path.join(sys.exec_prefix, "libs", pythonCLib) if not os.path.isfile(pathToLib): print "ERROR: {0} was not found. It is needed for linking".format( pathToLib) return False archData = platform.architecture(pathToLib) if archData[0] == "64bit": specialDefs = "-DMS_WIN64" elif os_dir == "Linux": build_swig(source_dir) os.chdir("dist") fp = open("../%s/build_lib" % os_dir) build_vars = { 'prefix': sys.prefix, 'exec_prefix': sys.exec_prefix, 'python_inc_dir': distutils.sysconfig.get_python_inc(), 'python_lib_dir': distutils.sysconfig.get_python_lib(), 'special_defs': specialDefs } for line in fp: result = util.ExecuteCmd(line.format(**build_vars), use_shell=True) if result: if ignore_results: print result else: print "FAIL: %s" % result fp.close() return False fp.close() return True
def BuildLibrary(os_dir, ignore_results): """Returns whether able to build file unpacker library.""" try: os.mkdir("dist") except OSError: pass # ok if it already exists os.chdir("dist") fp = open("../%s/build_lib" % os_dir) for line in fp: result = util.ExecuteCmd(line, use_shell=True) if result: if ignore_results: print result else: print "FAIL: %s" % result fp.close() return False fp.close() return True