I have this code to run in python.
Thanks in advance...
A real python beginner..!!!!
# This program searches through Exchange logs
# to find the source of account lockouts
# ONLY WORKS IN PYTHON 3
# Imports Regular Expressions and GLOB
import re, glob
def findusername():
print()
return
# Prompts user for a username
raw_user = raw_input("Type the username:")
user = raw_user
print("Please wait while the program searches for "+user)
print("The program could take up to two minutes to complete")
# Creates a list to store the lines of the log files
clean_log = []
# Creates a list of each log file path
logs = glob.glob("\\\xxxxxxxxxxx\c$\inetpub\logs\LogFiles\W3SVC1\*.log")
# Cycles through each individual log file
for log in logs:
# Opens the file as "searchfile" variable
with open(log, "r") as searchfile:
# Looks at each line in "searchfile"
for line in searchfile:
# Locates the "user" variable in the text file
if re.search(user, line, re.M|re.I):
# Locates 401 (access denied) errors
if re.search(r'\s401\s', line, re.M|re.I):
clean_log.append(line)
# Prints each line of the parsed log list
for line in clean_log:
print(line)
raw_input("Press enter to exit")and it works great but trying to program in a gui and im getting lost trying to get it to work. So i set up a gui to test with and exported it into a py file and got this.# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'austin.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_ExchangeSearch(object):
def setupUi(self, ExchangeSearch):
ExchangeSearch.setObjectName(_fromUtf8("ExchangeSearch"))
ExchangeSearch.resize(800, 391)
self.centralwidget = QtGui.QWidget(ExchangeSearch)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.Run = QtGui.QPushButton(self.centralwidget)
self.Run.setGeometry(QtCore.QRect(430, 30, 75, 23))
self.Run.setObjectName(_fromUtf8("Run"))
self.NameLabel = QtGui.QLabel(self.centralwidget)
self.NameLabel.setGeometry(QtCore.QRect(30, 30, 131, 21))
self.NameLabel.setObjectName(_fromUtf8("NameLabel"))
########################## close form ###########################
self.Closebtn = QtGui.QPushButton(self.centralwidget)
self.Closebtn.setGeometry(QtCore.QRect(700, 320, 75, 23))
self.Closebtn.setObjectName(_fromUtf8("Close"))
self.Closebtn.clicked.connect(QtCore.QCoreApplication.instance().quit)
#################################################################
self.NameInput = QtGui.QLineEdit(self.centralwidget)
self.NameInput.setGeometry(QtCore.QRect(180, 30, 231, 20))
self.NameInput.setObjectName(_fromUtf8("NameInput"))
self.SearchResult = QtGui.QTextBrowser(self.centralwidget)
self.SearchResult.setGeometry(QtCore.QRect(20, 110, 751, 192))
self.SearchResult.setObjectName(_fromUtf8("SearchResult"))
ExchangeSearch.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(ExchangeSearch)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuFile = QtGui.QMenu(self.menubar)
self.menuFile.setObjectName(_fromUtf8("menuFile"))
ExchangeSearch.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(ExchangeSearch)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
ExchangeSearch.setStatusBar(self.statusbar)
################## close form through menubar ###################
self.actionExit = QtGui.QAction(ExchangeSearch)
self.actionExit.setObjectName(_fromUtf8("actionExit"))
self.actionExit.triggered.connect(QtCore.QCoreApplication.instance().quit)
#################################################################
self.menuFile.addAction(self.actionExit)
self.menubar.addAction(self.menuFile.menuAction())
self.retranslateUi(ExchangeSearch)
QtCore.QMetaObject.connectSlotsByName(ExchangeSearch)
def retranslateUi(self, ExchangeSearch):
ExchangeSearch.setWindowTitle(_translate("ExchangeSearch", "Exchange Search Utility", None))
self.Run.setText(_translate("ExchangeSearch", "Run", None))
self.NameLabel.setText(_translate("ExchangeSearch", "Please Enter User Name:", None))
self.Closebtn.setText(_translate("ExchangeSearch", "Close", None))
self.menuFile.setTitle(_translate("ExchangeSearch", "File", None))
self.actionExit.setText(_translate("ExchangeSearch", "Exit", None))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
ExchangeSearch = QtGui.QMainWindow()
ui = Ui_ExchangeSearch()
ui.setupUi(ExchangeSearch)
ExchangeSearch.show()
sys.exit(app.exec_())When I try to code the run button to perform it never works or displays anything in text box. So i delete all the code I added and start over.. Any hints or clues to help me...?Thanks in advance...
A real python beginner..!!!!
