def run(self): # import pdb;pdb.set_trace() for file_name in self.filenames: yield (str('Opening: ' + file_name)) results = sky_manifest.ManifestReader( file_name, self.MainFrame).getJnumbers() self.retailer_code = results[0] self.MainFrame.currentItemInfo[ 'retailer_code'] = self.retailer_code self.jnumbers = results[1] self.total_count = len(self.jnumbers) self.current_count = 1 if 'jnumber' in self.jnumbers: self.jnumbers.remove('jnumber') if '4number' in self.jnumbers: self.jnumbers.remove('4number') for jnumber in self.jnumbers: self.itemNumber = jnumber self.MainFrame.scanNumberTextValue = jnumber self.MainFrame.currentItemInfo[ 'retailer_code'] = self.retailer_code try: self.data = FetchPage(self.MainFrame).results except Exception, e: print(e) continue if self.itemNumber is "" or None: continue if isinstance(self.data, Exception): continue if 'jnumber' not in jnumber: self.data = FetchPage(self.MainFrame).results # self.infoLogger("self.data"+str(self.data)) try: itemResults = Check(self.MainFrame) images = itemResults.downloadImages() except Exception: print(traceback.format_exc()) else: print('Retailer Code Not Recognized:' + str(self.retailer_code)) self.current_count += 1 yield ('Pre-Fetching: Manifests: ' + str(len(self.filenames)) + ' Items in Current: ' + str(self.current_count) + '/' + str(self.total_count))
def run(self): import pdb;pdb.set_trace() for file_name in self.filenames: yield ('Opening: ' + file_name) results = sky_manifest.ManifestReader(file_name,self.MainFrame).getJnumbers() self.retailer_code = results[0] self.MainFrame.currentItemInfo['retailer_code'] = self.retailer_code self.jnumbers = results[1] self.total_count = len(self.jnumbers) self.current_count = 1 if 'jnumber' in self.jnumbers: self.jnumbers.remove('jnumber') if '4number' in self.jnumbers: self.jnumbers.remove('4number') for jnumber in self.jnumbers: self.itemNumber = jnumber self.MainFrame.scanNumberTextValue = jnumber self.MainFrame.currentItemInfo['retailer_code'] = self.retailer_code self.data = FetchPage(self.MainFrame).results if self.itemNumber is "" or None: continue if 'jnumber' not in jnumber: self.data = FetchPage(self.MainFrame).results self.infoLogger("self.data"+str(self.data)) try: itemResults = Check(self.MainFrame) images = itemResults.downloadImages() except Exception: print(traceback.format_exc()) else: print('Retailer Code Not Recognized:'+str(self.retailer_code)) self.current_count += 1 yield ('Pre-Fetching: Manifests: ' + str(len(self.filenames)) + ' Items in Current: '+str(self.current_count) + '/' + str(self.total_count)) yield('Completed PreFetching.')
def prepareImageButtons(self): ''' Prepares image buttons for ImageSelectionFrame ''' self.infoLogger('\n# ImageSelectionFrame.prepareImageButtons #') check = Check(self.MainFrame) check.storeRadioSelection() self.sizer = wx.BoxSizer(wx.VERTICAL) button_id = 900 for name in self.MainFrame.currentItemInfo['image_list']: try: name = name.split('?')[0] + '.JPEG' if len(self.MainFrame.jNumber) is 0: self.MainFrame.jNumber = self.MainFrame.defaultJNumber #self.infoLogger('. Creating Button For: ' + self.MainFrame.jNumber) defaultJPagesFolder = self.MainFrame.defaultJPagesFolder jNumberFolderPath = os.path.join(str(defaultJPagesFolder), str(self.MainFrame.jNumber)) self.fp = os.path.join(jNumberFolderPath, str(name)) if os.path.exists(self.fp): self.infoLogger("File Exists: " + self.fp) pass else: self.infoLogger("Doesnt exist: " + self.fp) break #self.debugLogger("prepareImageButtons:",name,defaultJPagesFolder,jNumberFolderPath,self.fp) try: self.infoLogger("Trying self.createButtonImage") button_names = self.createButtonImage( name, defaultJPagesFolder, jNumberFolderPath, self.fp) self.infoLogger( str(button_names) + " " + str(traceback.format_exc())) #self.debugLogger("button_names: ",button_names) if isinstance(button_names, Exception): raise (button_names) except Exception, e: self.infoLogger('we had a problem ' + str(e)) break pressed = button_names[0] disabled = button_names[1] button_name = str('button' + str(button_id)) print(type(pressed)) if isinstance(pressed, int): exit() #self.debugLogger("Button Names: ", pressed, disabled, button_name) try: self.button_name = ShapedButton( self.panel, wx.Bitmap(self.fp), wx.Bitmap(pressed), wx.Bitmap(disabled), title=self.fp, id=button_id, ) # button_name is ShapedButton instance and for the logger # pass MainFrame to instance self.button_name.setMainFrame(self.MainFrame) except Exception, e: self.infoLogger(str(e) + " " + str(traceback.format_exc())) continue self.button_name.Bind(wx.EVT_BUTTON, self.on_button) self.sizer.AddStretchSpacer(1) self.sizer.Add(self.button_name, 0, wx.ALIGN_CENTER) self.sizer.AddStretchSpacer(1) button_id += 1