Ejemplo n.º 1
0
 def run( self ):
   quotesThread.run( self )
   if self.db == -1:
     self.fileHnd.write( "<companies>\n" )
   companies = []
   print 'Tworzenie listy indeksow'
   yP = YahooIndustryindexParser()
   yP.parsePageSource( yP.getAddrE() )
   print 'Znaleziono ' + str( yP.getIndicesList().__len__() ) + ' indeksow'
   print 'Tworzenie listy spolek'
   for i in yP.getIndicesList():
     rows = self.executeQuery( self.createQuery( i ) )
     if rows.__len__() > 0:
       if not rows[0].get( "company" ) == None:
         for row in rows[0].get( "company" ):
           try:
             tmpSymbol = row.get( "symbol" )
             tmpName = row.get( "name" )
             company = companyStruct()
             company.setName( tmpName )
             company.setSymbol( tmpSymbol )
             companies.append( company )
           except:
             continue
   self.count = companies.__len__()
   print 'Znaleziono ' + str( companies.__len__() ) + ' spolek'
   print 'Poczatek przetwarzania spolek'
   print 'Pobieranie podstawowych danych'
   threads = []
   if not self.ui == None:
     self.ui.setNoONews( self.count )
   for company in companies:
     nxt = True
     while nxt:
       #try:
         time.sleep( 0.4 )
         cParser = YahooCompaniesParser()
         hParser = YahooCompaniesHoldersParser()
         pThread = YahooCompaniesParserThread( self.id, self.fileHnd, cParser, hParser, company, threads.__len__(), self.count, self.ui, self.db )
         pThread.start()
         threads.append( pThread )
         nxt = False
       #except:
         #msg = 'Nie udalo sie utworzyc watku [ ' + self.id + ' ' + str( threads.__len__() ) + ' / ' + str( self.count ) + ' ]' + "\n"
         #sys.stderr.write( msg )
         #nxt = True
   for thread in threads:
       thread.join( 1.0 )
   print 'Koniec przetwarzania spolek'
   if self.db == -1:
     self.fileHnd.write( "</companies>\n" )
     self.fileHnd.close()
Ejemplo n.º 2
0
 def run( self ):
   if self.process == 0:
     return
   quotesThread.run( self )
   if not self.ui == None:
     self.ui.setNoOCompanys( self.companiesList.__len__() )
   for company in self.companiesList:
     rows = self.executeQuery( self.createQuery( company ) )
     #print company
     if not self.ui == None:
       self.ui.setNoOQuotes( rows.__len__() )
       self.toDatabase( company, rows )
     #for row in rows:
       #self.toDatabase( company, row )
       #if not self.ui == None:
         #self.ui.endQuote()
     if not self.ui == None:
       self.ui.endCompany()