# Created by Leo from: C:\Python24\tom2\NewLeo\googalstrip.leo # << googolstrip declarations >> import googolplex from sgmllib import SGMLParser import urlparse import wx import wx.html as html import wx.lib.foldpanelbar as fpb #import wx.lib.iewin as iewin from wx.gizmos import * from wx.lib.throbber import * import threading import sys,string,time,os from wx.lib.buttons import * import Image import image_view import ImgQueryLib import urllib2 import StringIO from wx.lib.evtmgr import eventManager import sgmllib from string import lower, replace, split, join import webwig import HTMLparse #import wx.lib.evtmgr as eventManager #import metakit #wx.InitAllImageHandlers() gs = googolplex.Googolplex() #gs.maxresults(20) #gs.language('lang_es') #gs.setproxy('localhost:8080') #res = gs.search('niburu') #for i in res: # print i['title'] #print 'Total:',len(res) #DcxImagePlugin,EpsImagePlugin, import ArgImagePlugin,BmpImagePlugin,CurImagePlugin,FliImagePlugin,FpxImagePlugin,GbrImagePlugin,GifImagePlugin,IcoImagePlugin,ImImagePlugin,ImtImagePlugin,IptcImagePlugin,JpegImagePlugin,McIdasImagePlugin,MicImagePlugin,MpegImagePlugin,MspImagePlugin,PcdImagePlugin,PcxImagePlugin,PdfImagePlugin,PixarImagePlugin,PngImagePlugin,PpmImagePlugin,PsdImagePlugin,SgiImagePlugin, SunImagePlugin,TgaImagePlugin,TiffImagePlugin,WmfImagePlugin import XVThumbImagePlugin,XbmImagePlugin,XpmImagePlugin # -- end -- << googolstrip declarations >> # << googolstrip methods >> (1 of 13) def is_ord (string): new_text = '' for i in string: if ord(i) > 127: new_text = new_text + '' else: new_text = new_text + i return new_text # << googolstrip methods >> (2 of 13) def WXToPIL(image, mode = 'RGBA'): "convert a wx.Image to a PIL RGBA image" imageData = image.GetData() size = (image.GetWidth(), image.GetHeight()) imagePIL = Image.fromstring('RGB', size, imageData) if mode != 'RGB': imagePIL = imagePIL.convert(mode) return imagePIL # << googolstrip methods >> (3 of 13) def PILToWX(image): "convert a PIL image to a wx.Image" if (image.mode == 'RGBA'): bk = Image.new("RGB", image.size, (255, 250, 255)) image = Image.composite(image, bk, image) if (image.mode != 'RGB'): image = image.convert('RGB') imageData = image.tostring('raw', 'RGB') imageWx = wx.EmptyImage(image.size[0], image.size[1]) imageWx.SetData(imageData) imageWx.SetMaskColour(255, 250, 255) return imageWx # << googolstrip methods >> (4 of 13) class HTML2Text(sgmllib.SGMLParser): # << class HTML2Text declarations >> from htmlentitydefs import entitydefs # replace entitydefs from sgmllib # -- end -- << class HTML2Text declarations >> # << class HTML2Text methods >> (1 of 8) def __init__(self, ignore_tags=(), indent_width=4, page_width=80): sgmllib.SGMLParser.__init__(self) self.result = "" self.indent = 0 self.ol_number = 0 self.page_width=page_width self.inde_width=indent_width self.lines=[] self.line=[] self.ignore_tags = ignore_tags # << class HTML2Text methods >> (2 of 8) def add_text(self,text): # convert text into words words = split(replace(text,'\n',' ')) self.line.extend(words) # << class HTML2Text methods >> (3 of 8) def add_break(self): self.lines.append((self.indent,self.line)) self.line=[] # << class HTML2Text methods >> (4 of 8) def generate(self): # join lines with indents indent_width = self.inde_width page_width = self.page_width out_paras=[] for indent,line in self.lines+[(self.indent,self.line)]: i=indent*indent_width indent_string = i*' ' line_width = page_width-i out_para='' out_line=[] len_out_line=0 for word in line: len_word = len(word) if len_out_line+len_word> (5 of 8) def mod_indent(self,i): self.indent = self.indent + i if self.indent < 0: self.indent = 0 # << class HTML2Text methods >> (6 of 8) def handle_data(self, data): if data: self.add_text(data) # << class HTML2Text methods >> (7 of 8) def unknown_starttag(self, tag, attrs): """ Convert HTML to something meaningful in plain text """ tag = lower(tag) if tag not in self.ignore_tags: try: if tag[0]=='h' or tag in ['br','pre','p','hr']: # insert a blank line self.add_break() elif tag =='img': # newline, text, newline src = '' for k, v in attrs: if lower(k) == 'src': src = v self.add_break() self.add_text('Image: ' + src) elif tag =='li': self.add_break() if self.ol_number: # num - text self.add_text(str(self.ol_number) + ' - ') self.ol_number = self.ol_number + 1 else: # - text self.add_text('- ') elif tag in ['dd','dt']: self.add_break() # increase indent self.mod_indent(+1) elif tag in ['ul','dl','ol']: # blank line # increase indent self.mod_indent(+1) if tag=='ol': self.ol_number = 1 except: pass # << class HTML2Text methods >> (8 of 8) def unknown_endtag(self, tag): """ Convert HTML to something meaningful in plain text """ tag = lower(tag) if tag not in self.ignore_tags: try: if tag[0]=='h' or tag in ['pre']: # newline, text, newline self.add_break() elif tag =='li': self.add_break() elif tag in ['dd','dt']: self.add_break() # descrease indent self.mod_indent(-1) elif tag in ['ul','dl','ol']: # blank line self.add_break() # decrease indent self.mod_indent(-1) self.ol_number = 0 except: pass # -- end -- << class HTML2Text methods >> # << googolstrip methods >> (5 of 13) def html2text(s, ignore_tags=(), indent_width=4, page_width=80): ignore_tags = [t.lower() for t in ignore_tags] parser = HTML2Text(ignore_tags, indent_width, page_width) parser.feed(s) parser.close() parser.generate() return parser.result # << googolstrip methods >> (6 of 13) class MyHtmlWindow(html.HtmlWindow): # << class MyHtmlWindow methods >> (1 of 6) def __init__(self, parent, id): html.HtmlWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE) self.log = log self.withforms = False self.Bind(wx.EVT_SCROLLWIN, self.OnScroll ) if "gtk2" in wx.PlatformInfo: self.NormalizeFontSizes() # << class MyHtmlWindow methods >> (2 of 6) def OnScroll( self, event ): #print 'event.GetOrientation()',event.GetOrientation() #print 'event.GetPosition()',event.GetPosition() event.Skip() # << class MyHtmlWindow methods >> (3 of 6) def OnLinkClicked(self, linkinfo): self.log.WriteText('OnLinkClicked: %s\n' % linkinfo.GetHref()) if self.withforms == True: url = linkinfo.GetHref() TomFilter = HTMLparse.TomFilter() webtext = urllib2.urlopen(url).read() formtxt = TomFilter.formfilter(webtext,url) self.SetPage(formtxt) else: # Virtuals in the base class have been renamed with base_ on the front. self.base_OnLinkClicked(linkinfo) # << class MyHtmlWindow methods >> (4 of 6) self.log.WriteText('OnSetTitle: %s\n' % title) self.base_OnSetTitle(title) # << class MyHtmlWindow methods >> (5 of 6) self.log.WriteText('OnCellMouseHover: %s, (%d %d)\n' % (cell, x, y)) self.base_OnCellMouseHover(cell, x, y) # << class MyHtmlWindow methods >> (6 of 6) self.log.WriteText('OnCellClicked: %s, (%d %d)\n' % (cell, x, y)) self.base_OnCellClicked(cell, x, y, evt) # -- end -- << class MyHtmlWindow methods >> # << googolstrip methods >> (7 of 13) class PyHtmlWindow(html.HtmlWindow): # << class PyHtmlWindow methods >> (1 of 2) def __init__(self, parent, id,reltedframe): html.HtmlWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE) self.parent = parent self.reltedframe = reltedframe self.address = '' if "gtk2" in wx.PlatformInfo: self.NormalizeFontSizes() # << class PyHtmlWindow methods >> (2 of 2) def OnLinkClicked(self, linkinfo): self.reltedframe.WebObjects = {} url = linkinfo.GetHref() self.address = url self.parent.LoadURL(url) # -- end -- << class PyHtmlWindow methods >> # << googolstrip methods >> (8 of 13) class HtmlPanel(wx.Panel): # << class HtmlPanel methods >> (1 of 6) def __init__(self, parent,reltedframe): wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE) #fpb.FoldPanelBar.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, fpb.FPB_DEFAULT_STYLE | fpb.FPB_VERTICAL) self.rframe = reltedframe self.cwd = os.path.split(sys.argv[0])[0] if not self.cwd: self.cwd = os.getcwd() self.titleBase = parent.GetTitle() self.TomFilter = HTMLparse.TomFilter() self.html = PyHtmlWindow(self, -1,reltedframe) self.html.SetRelatedFrame(reltedframe, self.titleBase + "%s") self.html.SetRelatedStatusBar(0) self.printer = html.HtmlEasyPrinting() self.box = wx.BoxSizer(wx.VERTICAL) self.box.Add(self.html, 1, wx.GROW) self.SetSizer(self.box) self.SetAutoLayout(True) self.OnShowDefault(None) # << class HtmlPanel methods >> (2 of 6) def OnShowDefault(self, event): #name = os.path.join(self.cwd, opj('data/test.htm')) #self.html.LoadPage('c:\\RBRanch\\out\\rbranch_strangness4.htm') pass # << class HtmlPanel methods >> (3 of 6) def surf(self, event): url = event.GetString() self.LoadURL(url) # << class HtmlPanel methods >> (4 of 6) def LoadText(self,webtext,url): self.rframe.WebObjects = {} formtxt = self.TomFilter.formfilter(webtext,url) #wx.SafeYield() self.html.address = url self.webhistory.Append(url) self.html.SetPage(formtxt) # << class HtmlPanel methods >> (5 of 6) def OnBack(self, event): if not self.html.HistoryBack(): wx.MessageBox("No more items in history!") # << class HtmlPanel methods >> (6 of 6) def OnForward(self, event): if not self.html.HistoryForward(): wx.MessageBox("No more items in history!") # -- end -- << class HtmlPanel methods >> # << googolstrip methods >> (9 of 13) class ImgFrame(wx.Frame): # << class ImgFrame methods >> (1 of 2) def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title, size = (500, 500),style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE ) self.notebook = wx.Notebook(self, wx.NewId(), style=wx.NB_TOP) self.ViewList = [] # << class ImgFrame methods >> (2 of 2) def URLAdd(self,img, path): id = wx.NewId() #self.ViewList.append(image_view.ImageView(self.notebook,id))#,tools = [image_view.PanTool, image_view.ZoomTool, image_view.SaveTool])) #self.ViewList[len(self.ViewList)-1].set_image(img) self.ViewList.append(image_view.ImageView(self.notebook,id,tools = [image_view.PanTool,image_view.ZoomTool, image_view.InspectTool, image_view.BoxTool , image_view.SharpTool , image_view.ColorTool , image_view.BrightTool , image_view.ContTool , image_view.RestoreTool , image_view.RedTool , image_view.GreenTool , image_view.BlueTool, image_view.LoadTool, image_view.SaveTool, image_view.URLTool], image = img, pos=(-1, -1), size=(-1, -1), style=0, name='ImageView')) self.notebook.AddPage(self.ViewList[len(self.ViewList)-1],os.path.split(path)[1]) # -- end -- << class ImgFrame methods >> # << googolstrip methods >> (10 of 13) class MyIParser(SGMLParser): # << class MyIParser methods >> def start_img(self,attrs): self.attrs.append(attrs) # -- end -- << class MyIParser methods >> # << googolstrip methods >> (11 of 13) def tomparse(page , urlroot): tom = MyIParser() tom.attrs = [] img_list = [] for line in page: try: tom.feed(line) except: pass for i in tom.attrs: for j in i: if j[0] == 'src': if j[1][:4] != 'http': img_list.append(urlparse.urljoin(urlroot , j[1])) else: img_list.append(j[1]) return img_list # << googolstrip methods >> (12 of 13) class MyFrame(wx.Frame): # << class MyFrame methods >> (1 of 15) def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, -1, title, size = (500, 500),style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE ) self.tommytest = Image.new('RGB',(128,128)) self.testimageflag = 0 self.images = {} self.imgmach = [] self.image_dir_list = [] self.pages = {} self.imgmach = [] self.mythreads = [] self.imagelist = [] self.seccondtime = 1 self.newcount = 0 self.totalthreadcount = 1 self.imageframe = ImgFrame(self, -1, 'Maching images') self.imgdatabase = ImgQueryLib.ImgDB()#'c:\\python22\\tom.dfi') id = wx.NewId() #self.CodeWindow = iewin.IEHtmlWindow(self, id, style = wx.NO_FULL_REPAINT_ON_RESIZE) self.CodeWindow = HtmlPanel(self,self)#MyHtmlWindow(self, id)# sizer = wx.BoxSizer(wx.VERTICAL) btnSizer = wx.BoxSizer(wx.HORIZONTAL) self.btn1 = wx.Button(self, wx.NewId(), 'Search', style=wx.BU_EXACTFIT)#wx.GenBitmapButton(self, -1, self.startsbmp) eventManager.Register(self.OnOpenButton, wx.EVT_BUTTON, self.btn1) #wx.EVT_BUTTON(self, btn.GetId(), self.OnOpenButton) btnSizer.Add(self.btn1, 1, wx.EXPAND ) self.main_stories = '' txt1 = wx.StaticText(self, -1, 'Sites:')#wx.StaticBitmap(self, -1, self.site_bmp) #btnSizer.Add(txt, 1, wx.ALIGN_RIGHT) sliderSizer = wx.BoxSizer(wx.HORIZONTAL) self.text = wx.TextCtrl(self, -1, '25')#,(-1,-1),(-1, -1)) slid = wx.NewId() self.slider = wx.SpinButton(self, slid, (-1,-1),(-1, -1), wx.SP_HORIZONTAL)#wx.Slider(self, 100, 25, 1, 100, (-1,-1),(-1, -1),wx.SL_HORIZONTAL | wx.SL_LABELS ) self.slider.SetRange(0,200) self.slider.SetValue(25) sliderSizer.Add(txt1, 1, wx.EXPAND) sliderSizer.Add(self.text, 2, wx.EXPAND) sliderSizer.Add(self.slider, 2, wx.EXPAND) eventManager.Register(self.OnSpin, wx.EVT_SPIN, self.slider) #wx.EVT_SPIN(self, slid, self.OnSpin) #self.slider.SetTickFreq(5, 1) #btn = wx.Button(self, wx.NewId(), "Save", style=wx.BU_EXACTFIT) #wx.EVT_BUTTON(self, btn.GetId(), self.OnSaveButton) btnSizer.Add(sliderSizer, 3,wx.EXPAND) self.btn = wx.Button(self, wx.NewId(), 'Add Image', style=wx.BU_EXACTFIT)#wx.GenBitmapButton(self, -1, self.addimg_bmp) eventManager.Register(self.OnImageButton, wx.EVT_BUTTON, self.btn) #wx.EVT_BUTTON(self, btn.GetId(), self.OnImageButton) btnSizer.Add(self.btn, 1, wx.EXPAND) self.current = '' stSizer = wx.BoxSizer(wx.HORIZONTAL) txt = wx.StaticText(self, -1, 'Search Term:')#wx.StaticBitmap(self, -1, self.search_bmp ) stSizer.Add(txt, 1, wx.ALIGN_RIGHT ) #btnSizer.Add(txt, 1, wx.ALIGN_RIGHT ) self.term = wx.TextCtrl(self, -1, '')#, size=(125, -1)) eventManager.Register(self.onchar, wx.EVT_TEXT, self.term) #wx.EVT_TEXT(self, self.term.GetId(), self.onchar) stSizer.Add(self.term, 1, wx.EXPAND) btnSizer.Add(stSizer, 2, wx.EXPAND) #self.led = wx.LEDNumberCtrl(self, -1, (-1,-1), (125, -1)) #btnSizer.Add(self.led, 1, wx.EXPAND) self.g2 = wx.Gauge(self, -1, 50, wx.Point(110, 95), wx.Size(250, 25), wx.GA_HORIZONTAL|wx.GA_SMOOTH) self.g2.SetBezelFace(3) self.g2.SetShadowWidth(3) #self.otherThrobber = Throbber(self, -1,self.throb_img)#, size=(48, 48), frameDelay = 0.15,frames = 12,frameWidth = 48, label = "Stop") #btnSizer.Add(self.otherThrobber, 1, wx.EXPAND) btnSizer.Add(self.g2, 1, wx.EXPAND) sizer.Add(btnSizer,1, wx.EXPAND) sizer.Add(self.CodeWindow,30, wx.EXPAND) self.SetSizer(sizer) self.SetAutoLayout(True) eventManager.Register(self.OnSize, wx.EVT_SIZE, self) #wx.EVT_SIZE(self, self.OnSize) eventManager.Register(self.onIdle, wx.EVT_IDLE, self) # << class MyFrame methods >> (2 of 15) def OnOpenButton(self, event): self.pages = {} self.seccondtime = 1 #self.otherThrobber.Start() if self.testimageflag: self.imageframe.Show() sitenum = int(self.slider.GetValue()) gs.maxresults(sitenum) self.g2.SetRange(int(sitenum)) try: self.res = gs.search(self.current) except: dlg = wx.MessageDialog(frame, 'Comunications not resonding captain!', 'Engineers Report', wx.OK | wx.ICON_INFORMATION) dlg.ShowModal() dlg.Destroy() return print self.res for i in self.res: self.mythreads.append(threading.Thread(group=None, target=self.launchthread, name=i['title'], args=(i['url'],i['title']), kwargs={})) self.mythreads[len(self.mythreads)-1].start() #self.launchthread(i['url'],i['title']) #pageindex = self.pages.keys() #pageindex.sort() #pageindex.reverse() #self.main_stories = "" #for i in pageindex: # print 'index: ',i # self.main_stories = self.main_stories + self.pages[i] #self.main_stories + self.main_stories + '' #self.CodeWindow.html.LoadString(self.main_stories) #print self.main_stories[:20] #self.Savesearch() #if self.testimageflag: # self.testImage() # self.Saveimage() # << class MyFrame methods >> (3 of 15) def OnSize(self, evt): self.Layout() # << class MyFrame methods >> (4 of 15) def OnSpin(self, evt): self.text.SetValue(str(evt.GetPosition())) # << class MyFrame methods >> (5 of 15) def OnDestroy(self,evt): evt.Skip() # << class MyFrame methods >> (6 of 15) def getcount(self,text,search): countthing = 0 for i in string.split(search): countthing = countthing + text.count(i) return countthing # << class MyFrame methods >> (7 of 15) def onchar(self,evt): self.current = evt.GetString() # << class MyFrame methods >> (8 of 15) def launchthread(self, url, title): print title gettencount = 0 counterthing = 0.1 imgthreads = [] try: self.page = urllib2.urlopen(url) except: print 'cant open url' return #try: cleanhtml = self.page.read() stories = cleanhtml# = html2safehtml(stories,valid_tags=('br','p'))#, 'a', 'i', 'br', 'p')) cleanhtml = html2text(cleanhtml,ignore_tags=('br','p',),indent_width=4,page_width=80) cleanhtml = is_ord(cleanhtml) #print 'clean',cleanhtml[:10],cleanhtml[-10:] gettencount = self.getcount(cleanhtml,self.current) print 'gettencount',gettencount if gettencount == 0: pass else: print 'pages',len(self.pages),cleanhtml[:20] if self.pages.has_key(gettencount): while self.pages.has_key(gettencount + counterthing): counterthing = counterthing + .1 self.images[gettencount + counterthing] = tomparse(StringIO.StringIO(stories) , url) self.pages[gettencount + counterthing] = '

TITLE: ' + title + '
LINK: ' + url + '

' + cleanhtml else: self.images[gettencount] = tomparse(StringIO.StringIO(stories) , url) self.pages[gettencount] = '

TITLE: ' + title + '
LINK: ' + url + '

' + cleanhtml if self.testimageflag: try: parsdir = urlparse.urlparse(url)[2] except: parsdir = '/unknown/' + str(time.time()) #newdir = os.path.split(parsdir)[1] pathtext = self.current.strip().replace(' ','_') pathtext = pathtext.replace('.','_') parsdir = pathtext #+ os.path.splitext(newdir)[0].replace('.','_') + str(len(self.pages)) newdir = os.path.join('c:\\python24\\tom2\\urlimg',parsdir) if not os.path.exists(newdir): os.mkdir(newdir) #print 'Made directory ',newdir newdir = str(newdir) if not (newdir in self.image_dir_list): self.image_dir_list.append(newdir) for path in tomparse(StringIO.StringIO(stories) , url): self.imagelist.append((path,newdir)) self.imgthread(path,newdir) #imgthreads.append(threading.Thread(group=None, target=self.imgthread, name=url, args=((path),(newdir)), kwargs={})) #imgthreads[len(imgthreads)-1].start() #except: # pass # << class MyFrame methods >> (9 of 15) def imgthread(self, fname,rootpath): #print 'saveing ',fname,' at ',rootpath newpath = '' typofimage = os.path.splitext(fname)[1] if typofimage not in ('.gif','.jpg','.png','.bmp'): #print 'not in image type' return try: tom = urllib2.urlopen(fname) except: #print "Error opening/decoding image file " + fname return tomstr = tom.read() try: aImage = Image.open(StringIO.StringIO(tomstr)).convert('RGB') #WXToPIL(wx.ImageFromStream(StringIO.StringIO(tomstr)),'RGB') newpath = os.path.join(rootpath,os.path.split(fname)[1]) except: #print 'PIL open error ',newpath return if aImage.size[0] > 30 and aImage.size[1] > 30: try: aImage.save(newpath) except: #print 'PIL save problem ',newpath pass #try: # self.imgdatabase.addImage(aImage,newpath) #except: # #print 'Database add problem ',newpath # pass del aImage del tom # << class MyFrame methods >> (10 of 15) def Savesearch(self): name = self.current.strip().replace(' ','_') + '.htm' path = os.path.join('c:\\python24\\tom2\\urlimg',name) tom = file(path,'w') tom.write(self.main_stories) tom.close() del tom # << class MyFrame methods >> (11 of 15) def Saveimage(self): name = self.current.strip().replace(' ','_') + '.idb' path = os.path.join('c:\\python23\\tom2\\urlimg',name) self.imgdatabase.changefname(path) self.imgdatabase.savedb() # << class MyFrame methods >> (12 of 15) def OnImageButton(self,evt): wildcard = "Jpeg (*.jpg)|*.jpg|Giff (*.gif)|*.gif|Bitmap (*.bmp)|*.bmp|All files (*.*)|*.*" dlg = wx.FileDialog(self, "Choose an image", "", "", wildcard, wx.OPEN) if dlg.ShowModal() == wx.ID_OK: path = str(dlg.GetPath()) self.tommytest = Image.open(path).convert('RGB') self.imageframe.URLAdd(self.tommytest, path) self.tommytest = self.tommytest.resize((128,128)) self.testimageflag = 1 dlg.Destroy() # << class MyFrame methods >> (13 of 15) def onIdle(self,evt): #print 'self.totalthreadcount threading.activeCount()',self.totalthreadcount ,threading.activeCount() if self.totalthreadcount != threading.activeCount(): self.totalthreadcount = threading.activeCount() self.g2.SetValue(int(threading.activeCount())) #print 'threading.activeCount()',threading.activeCount() #self.led.SetValue(str(threading.activeCount())) print 'threads', threading.enumerate(),'self.pages',len(self.pages) pageindex = self.pages.keys() pageindex.sort() pageindex.reverse() self.main_stories = '' for i in pageindex: #print 'index: ',i self.main_stories = self.main_stories + self.pages[i] self.main_stories + self.main_stories + '' self.CodeWindow.LoadText(self.main_stories,'')#LoadString(self.main_stories) #print self.main_stories[:20] if self.totalthreadcount == 1: self.Savesearch() #self.otherThrobber.Stop() if self.testimageflag and self.seccondtime: #print 'threading.activeCount()',threading.activeCount() #self.led.SetValue(str(threading.activeCount())) #self.otherThrobber.Start() lastthred = threading.Thread(group=None, target=self.GetwebImages, name='imgsv', args=(), kwargs={}) lastthred.start() #for i in self.imagelist:self.imgthread(i[0],i[1]) #self.imgage_testing = 1 #self.testImage() #if self.totalthreadcount == 1: #self.Saveimage() elif self.testimageflag and not self.seccondtime: self.testImage() self.Saveimage() # << class MyFrame methods >> (14 of 15) def GetwebImages(self): count = 1 self.g2.SetRange(len(self.imagelist)) for i in self.imagelist: self.g2.SetValue(count) self.imgthread(i[0],i[1]) count = count + 1 self.seccondtime = 0 # << class MyFrame methods >> (15 of 15) def testImage(self): mythreads = [] #print 'checking images',len(self.image_dir_list) #os.chdir('c:\\python22\\urlimg') for direc in self.image_dir_list: for path in os.listdir(direc): #print direc,'directory',path,'path' if path != 'Thumbs.db': #mythreads.append(threading.Thread(group=None, target=self.imgdatabase.addFile, name=path, args=((os.path.join(direc,path)),), kwargs={})) #mythreads[len(mythreads)-1].start() self.imgdatabase.addFile(os.path.join(direc,path)) #while mythreads[len(mythreads)-1].isAlive(): #pass #self.imgdatabase.addFile(os.path.join(os.getcwd(),path)) self.imgmach = self.imgdatabase.eng.query(self.tommytest) for i in self.imgmach: aImage = Image.open(i.pair[0]) self.imageframe.URLAdd(aImage, i.pair[0]) #self.otherThrobber.Stop() print time.time() # -- end -- << class MyFrame methods >> # << googolstrip methods >> (13 of 13) class LogApp(wx.App): # << class LogApp methods >> def OnInit(self): frame = MyFrame(None, -1, "Captain's Search") self.SetTopWindow(frame) frame.Show() return True # -- end -- << class LogApp methods >> # -- end -- << googolstrip methods >> #!/usr/bin/python app = LogApp(0) # Create an instance of the application class app.MainLoop() # Tell it to start processing event