def SaveTotalPageToFile(self, new_page_num): print '====================save the totalpage to totalpage.ini====================' iniFile = INIFILE(self.proFileName) if not iniFile.initflag: print 'class initializing failed. check the [%s] file first.' % ( self.proFileName) os._exit(0) loaded_page_num = iniFile.GetValue('Main', 'loadedpage') print '====================the loaded_page_num is [%s], the new_page_num is [%s]====================' % ( loaded_page_num, new_page_num) iniFile.SetValue('SUM', 'totalpage', new_page_num).EndWrite().UnInit() if int(new_page_num) >= int(loaded_page_num): # if there is new page # self.unload_page_num = int(new_page_num) - int(loaded_page_num) self.unload_page_num = int(new_page_num) - int(loaded_page_num) if self.unload_page_num == 0: # 页码未增加,但是图片新增了 self.unload_page_num = 1 elif self.unload_page_num > 0: # 增加新页面了,但是旧页上图片存在未下载的情况***会导致下载不会结束 self.unload_page_num += 1 print 'since we start at page %s, we still got (%s) pages to load.' % ( self.page, self.unload_page_num) else: # nothing new, stop main thread print 'Oops! Nothing new. exit main thread now.' os._exit(0) # terminal sub thread self.enable = False # terminal main thread
def ShowOnePage(self, now_page_items, page): for idx, item in enumerate(now_page_items): print "\nopen " + item[0] time.sleep(1.666) self.GetFileDownloadPath(item[0]) # print '========one page done.=================' print '========Please hit the Enter.=================' if self.allDone: print 'Nothing left. Now close this application.' # self.enable = False #let the main thread know it's time to quit os._exit(0) # can teminal main thread. #当前页码 iniFile = INIFILE(self.proFileName) if iniFile.initflag: iniFile.SetValue('Main', 'loadedpage', page).EndWrite().UnInit() # 输出一页后暂停 time.sleep(1) print 'take a snap for 1s.'
def SaveTotalPageToFile(self, new_page_num): print '====================save the totalpage to totalpage.ini====================' file = INIFILE('totalpage.ini') old_page_num = file.GetValue('Main', 'totalpage') print '====================the old_page_num is [%s], the new_page_num is [%s]====================' % ( old_page_num, new_page_num) file.SetValue('Main', 'totalpage', new_page_num).EndWrite().UnInit() if int(new_page_num) >= int(old_page_num): #if there is new page self.unload_page_num = int(new_page_num) - int(old_page_num) if self.unload_page_num == 0: #页码未增加,但是图片新增了 self.unload_page_num = 1 elif self.unload_page_num > 0: #增加新页面了,但是旧页上图片存在未下载的情况 self.unload_page_num += 1 print 'Ok, we got %s pages to load.' % (self.unload_page_num) else: #nothing new, stop main thread print 'Oops! Nothing new. exit main thread now.' os._exit(0) #terminal sub thread self.enable = False #terminal main thread
def SaveTotalPageToFile(self, new_page_num): print '====================save the totalpage to totalpage.ini====================' file = INIFILE('qiubaiadult_page.ini') # must write something if you set is_write to true. otherwise your file become empty. is_ok = file.Init(True, True) if not is_ok: print 'class initializing failed. check the [%s] file first.' % ('totalpage.ini') os._exit(0) old_page_num = file.GetValue('Main', 'totalpage') print '====================the old_page_num is [%s], the new_page_num is [%s]====================' % ( old_page_num, new_page_num) file.SetValue('Main', 'totalpage', new_page_num) # close all file.UnInit() if int(new_page_num) >= int(old_page_num): # if there is new page # self.unload_page_num = int(new_page_num) - int(old_page_num) self.unload_page_num = int(new_page_num) - int(old_page_num) if self.unload_page_num == 0: # 页码未增加,但是图片新增了 self.unload_page_num = 1 elif self.unload_page_num > 0: # 增加新页面了,但是旧页上图片存在未下载的情况***会导致下载不会结束 self.unload_page_num += 1 print 'since we start at page %s, we still got (%s-%s) pages to load.' % ( self.page, self.unload_page_num, self.page) else: # nothing new, stop main thread print 'Oops! Nothing new. exit main thread now.' os._exit(0) # terminal sub thread self.enable = False # terminal main thread
def whichPage2Start(self): file = INIFILE(self.proFileName) if file.initflag: startPage = file.GetValue('Main', 'loadedpage', 1) self.page = int(startPage)