PyDL  Version: 0.0.1
pydl.ThreadProc Class Reference
Inheritance diagram for pydl.ThreadProc:
Inheritance graph
Collaboration diagram for pydl.ThreadProc:
Collaboration graph

Public Member Functions

def __init__ (self, urlq, tq, dl_site_info, report)
 
def run (self)
 

Public Attributes

 urlq
 
 tq
 
 dl_site_info
 
 report
 

Detailed Description

Definition at line 191 of file pydl.py.

Constructor & Destructor Documentation

def pydl.ThreadProc.__init__ (   self,
  urlq,
  tq,
  dl_site_info,
  report 
)

Definition at line 193 of file pydl.py.

193  def __init__(self, urlq, tq, dl_site_info, report):
194  Thread.__init__(self)
195  self.urlq = urlq
196  self.tq = tq
197  self.dl_site_info = dl_site_info
198  self.report = report
199 
def __init__(self, urlq, tq, dl_site_info, report)
Definition: pydl.py:193

Member Function Documentation

def pydl.ThreadProc.run (   self)

Definition at line 200 of file pydl.py.

References pydl.ThreadProc.urlq.

200  def run(self):
201  try:
202  url = self.urlq.get()
203  while True:
204  if self.urlq == None:
205  break;
206 
207  # setup download_path link portion
208  download_path = None
209  id_pos = None
210 
211  # grab the base download url based on the patterns provided
212  for key, value in dl_site_info.items():
213  if ( key in url ):
214  download_path = value["download_path"]
215  # grab the file id position from the template
216  id_pos = value["id_pos"]
217 
218  # TODO: needs error handling -exit bad
219  if( download_path == None ):
220  print("ERROR: base url of website not configured")
221  # TODO: should probably just continue here
222  sys.exit(1)
223 
224  # create object and do work
225  try:
226  o = ScrapeFile(url, download_path, id_pos, report)
227  report.progressX[o.ofilename] = {"bytes_so_far": 0, "total_size": 0}
228  if DEBUG:
229  o.test_thread()
230  else:
231  o.download()
232  self.tq.get()
233  self.urlq.task_done()
234  break;
235  except urllib.error.HTTPError as err:
236  print("ERROR: %s | HTTPError: %s" % (url, err))
237  continue
238 
239  except MyError as err:
240  print("\n" + "** signal caught: %s **\n" % err)
241  exit(1)
242 
243  #self.tq.task_done()
244 
245 
def run(self)
Definition: pydl.py:200

Member Data Documentation

pydl.ThreadProc.dl_site_info

Definition at line 197 of file pydl.py.

pydl.ThreadProc.report

Definition at line 198 of file pydl.py.

pydl.ThreadProc.tq

Definition at line 196 of file pydl.py.

pydl.ThreadProc.urlq

Definition at line 195 of file pydl.py.

Referenced by pydl.ThreadProc.run().


The documentation for this class was generated from the following file: