@@ -25,21 +25,30 @@ class Web(QtWidgets.QMainWindow):
2525 def __init__ (self ):
2626 super (Web ,self ).__init__ ()
2727 self .scriptDir = os .path .dirname (os .path .realpath (__file__ ))
28- uic .loadUi (self .scriptDir + os .path .sep + 'WebScrapper.ui' ,self )
28+ filePath = self .scriptDir + os .path .sep + 'WebScrapper.ui'
29+ filePath = os .path .join (os .path .dirname (sys .executable ), filePath )
30+ uic .loadUi (filePath ,self )
2931 self .setWindowIcon (QIcon (self .scriptDir + os .path .sep + 'icon.png' ))
3032 self .setWindowTitle ('WebScrapper by [@Nishant Ghanate]' )
33+ # self.setFixedSize(1366, 768)
3134 self .buttonGetInput .clicked .connect (self .getInput )
3235 self .buttonSaveLogs .clicked .connect (self .saveLogs )
3336 self .buttonClearLogs .clicked .connect (self .clearLogs )
3437 self .buttonClear .clicked .connect (self .clear )
3538 self .buttonStop .clicked .connect (self .stop )
39+ self .buttonStop .setEnabled (False )
3640 self .oldUrl = "_"
3741 self .Guide = Guide ()
3842 self .actionGuide .triggered .connect (self .guideWindow )
3943
44+ def resource_path (relative_path ):
45+ if hasattr (sys , '_MEIPASS' ):
46+ return os .path .join (sys ._MEIPASS , relative_path )
47+ return os .path .join (os .path .abspath ("." ), relative_path )
48+
4049 #Acttivate UI fucntions
4150 QtCore .pyqtSlot ()
42-
51+
4352 # Returns Time in e.g 1 oct 2018 formart
4453 def getTimeStamp (self ):
4554 return datetime .now ().strftime ("%A %d. %B %Y %I:%M:%S %p" )
@@ -91,7 +100,7 @@ def getSource(self):
91100 except :
92101 self .listWidgetLogs .addItem ('Xpath exception please try again' )
93102
94-
103+
95104 # Get button function connection
96105 def getInput (self ):
97106 url = self .textEditUrl .toPlainText ()
@@ -106,10 +115,11 @@ def getInput(self):
106115 self .processGetSource = multiprocessing .Process (target = self .getSource ())
107116 self .processGetSource .start ()
108117 self .processGetSource .join ()
109-
118+ self . buttonGetInput . setEnabled ( False )
110119 print ('Process joined:' , self .processGetSource , self .processGetSource .is_alive ())
111120 print ('Process exit code:' , self .processGetSource .exitcode )
112121 if self .processGetSource .exitcode == 0 :
122+ self .buttonStop .setEnabled (False )
113123 self .stop ()
114124 elif url is None or len (url ) < 5 :
115125 timestampDay = self .getTimeStamp ()
@@ -126,7 +136,7 @@ def saveLogs(self):
126136 fileName = self .scriptDir + os .path .sep + 'WebScrappingLogs ' + timestampDay + '.txt'
127137 file = open (fileName ,'a+' , encoding = 'utf-8' )
128138
129- file .writelines ('Command Logs ' + timestampDay )
139+ file .writelines ('Command Logs ' + timestampDay + ' \n ' )
130140 for i in range (self .listWidgetMain .count ()):
131141 file .writelines (self .listWidgetMain .item (i ).text () + '\n ' )
132142
0 commit comments