@@ -61,12 +61,8 @@ def validateUrl(self,url):
6161 return False
6262
6363 def stop (self ):
64- print ('Process running:' , self .processGetSource , self .processGetSource .is_alive ())
6564 self .processGetSource .terminate ()
6665 print ('Process terminated:' , self .processGetSource , self .processGetSource .is_alive ())
67- # self.processGetSource.join()
68- # print ('Process joined:', self.processGetSource, self.processGetSource.is_alive())
69- # print ('Process exit code:', self.processGetSource.exitcode)
7066 self .buttonGetInput .setEnabled (True )
7167
7268 # This function will scrap it is also recurive if required
@@ -90,6 +86,7 @@ def getSource(self):
9086 url = self .validateUrl (self .r .html ._next ())
9187 if url :
9288 if self .r .status_code == 200 :
89+ # self.listWidgetLogs.addItem('\n'+self.r.html._next())
9390 self .getSource ()
9491
9592
@@ -111,7 +108,11 @@ def getInput(self):
111108 self .listWidgetMain .addItem (self .xpathSrc )
112109 self .processGetSource = multiprocessing .Process (target = self .getSource ())
113110 self .processGetSource .start ()
114- # self.getSource()
111+ self .processGetSource .join ()
112+ print ('Process joined:' , self .processGetSource , self .processGetSource .is_alive ())
113+ print ('Process exit code:' , self .processGetSource .exitcode )
114+ if self .processGetSource .exitcode == 0 :
115+ self .stop ()
115116 elif url is None or len (url ) < 5 :
116117 timestampDay = self .getTimeStamp ()
117118 self .listWidgetLogs .addItem (timestampDay )
@@ -124,8 +125,14 @@ def getInput(self):
124125 # Saves logs from Preserved logs
125126 def saveLogs (self ):
126127 timestampDay = datetime .now ().strftime ("%A %d %B %Y %I %M %S%p" )
127- file = open (self .scriptDir + os .path .sep + 'WebScrappingLogs ' + timestampDay + '.txt' ,'a+' )
128-
128+ fileName = self .scriptDir + os .path .sep + 'WebScrappingLogs ' + timestampDay + '.txt'
129+ file = open (fileName ,'a+' , encoding = 'utf-8' )
130+
131+ file .writelines ('Command Logs ' + timestampDay )
132+ for i in range (self .listWidgetMain .count ()):
133+ file .writelines (self .listWidgetMain .item (i ).text () + '\n ' )
134+
135+ file .writelines ('\n Source Logs' )
129136 for i in range (self .listWidgetLogs .count ()):
130137 file .writelines (self .listWidgetLogs .item (i ).text () + '\n ' )
131138 # file.writelines(itemsTextList)
0 commit comments