def _addComic(self, **kwargs): if 'id' not in kwargs: self.data = 'Missing parameter: id' return else: self.id = kwargs['id'] try: importer.addComictoDB(self.id) except Exception, e: self.data = e
def _addComic(self, **kwargs): if 'id' not in kwargs: self.data = self._error_with_message('Missing parameter: id') return else: self.id = kwargs['id'] try: importer.addComictoDB(self.id) except Exception, e: self.data = e
def _addComic(self, **kwargs): if 'id' not in kwargs: self.data = self._failureResponse('Missing parameter: id') return else: self.id = kwargs['id'] try: importer.addComictoDB(self.id) except Exception, e: self.data = e
def _refreshComic(self, **kwargs): if 'id' not in kwargs: self.data = 'Missing parameter: id' return else: self.id = kwargs['id'] try: importer.addComictoDB(self.id) except Exception, e: self.data = e
def importIT(self): #set startup... if len(self.comiclist) > 0: self.sql_attach() query = "DELETE FROM maintenance" self.db.execute(query) query = "INSERT INTO maintenance (id, mode, total, status) VALUES (%s,'%s',%s,'%s')" % ('1', self.mode, len(self.comiclist), "running") self.db.execute(query) self.sql_close() logger.info('[MAINTENANCE-MODE][%s] Found %s series in previous db. Preparing to migrate into existing db.' % (self.mode.upper(), len(self.comiclist))) count = 1 for x in self.comiclist: logger.info('[MAINTENANCE-MODE][%s] [%s/%s] now attempting to add %s to watchlist...' % (self.mode.upper(), count, len(self.comiclist), x['ComicID'])) try: self.sql_attach() self.db.execute("UPDATE maintenance SET progress=?, total=?, current=? WHERE id='1'", (count, len(self.comiclist), re.sub('4050-', '', x['ComicID'].strip()))) self.sql_close() except Exception as e: logger.warn('[ERROR] %s' % e) maintenance_info = importer.addComictoDB(re.sub('4050-', '', x['ComicID']).strip(), calledfrom='maintenance') try: logger.info('MAINTENANCE: %s' % maintenance_info) if maintenance_info['status'] == 'complete': logger.fdebug('[MAINTENANCE-MODE][%s] Successfully added %s [%s] to watchlist.' % (self.mode.upper(), maintenance_info['comicname'], maintenance_info['year'])) else: logger.fdebug('[MAINTENANCE-MODE][%s] Unable to add %s [%s] to watchlist.' % (self.mode.upper(), maintenance_info['comicname'], maintenance_info['year'])) raise IOError self.maintenance_success.append(x) try: self.sql_attach() self.db.execute("UPDATE maintenance SET progress=?, last_comicid=?, last_series=?, last_seriesyear=? WHERE id='1'", (count, re.sub('4050-', '', x['ComicID'].strip()), maintenance_info['comicname'], maintenance_info['year'])) self.sql_close() except Exception as e: logger.warn('[ERROR] %s' % e) except IOError as e: logger.warn('[MAINTENANCE-MODE][%s] Unable to add series to watchlist: %s' % (self.mode.upper(), e)) self.maintenance_fail.append(x) count+=1 else: logger.warn('[MAINTENANCE-MODE][%s] Unable to locate any series in db. This is probably a FATAL error and an unrecoverable db.' % self.mode.upper()) return logger.info('[MAINTENANCE-MODE][%s] Successfully imported %s series into existing db.' % (self.mode.upper(), len(self.maintenance_success))) if len(self.maintenance_fail) > 0: logger.info('[MAINTENANCE-MODE][%s] Failed to import %s series into existing db: %s' % (self.mode.upper(), len(self.maintenance_success), self.maintenance_fail)) try: self.sql_attach() self.db.execute("UPDATE maintenance SET status=? WHERE id='1'", ["completed"]) self.sql_close() except Exception as e: logger.warn('[ERROR] %s' % e)
def importIT(self): #set startup... if len(self.comiclist) > 0: self.sql_attach() query = "DELETE FROM maintenance" self.db.execute(query) query = "INSERT INTO maintenance (id, mode, total, status) VALUES (%s,'%s',%s,'%s')" % ( '1', self.mode, len(self.comiclist), "running") self.db.execute(query) self.sql_close() logger.info( '[MAINTENANCE-MODE][%s] Found %s series in previous db. Preparing to migrate into existing db.' % (self.mode.upper(), len(self.comiclist))) count = 1 for x in self.comiclist: logger.info( '[MAINTENANCE-MODE][%s] [%s/%s] now attempting to add %s to watchlist...' % (self.mode.upper(), count, len( self.comiclist), x['ComicID'])) try: self.sql_attach() self.db.execute( "UPDATE maintenance SET progress=?, total=?, current=? WHERE id='1'", (count, len(self.comiclist), re.sub('4050-', '', x['ComicID'].strip()))) self.sql_close() except Exception as e: logger.warn('[ERROR] %s' % e) maintenance_info = importer.addComictoDB( re.sub('4050-', '', x['ComicID']).strip(), calledfrom='maintenance') try: logger.info('MAINTENANCE: %s' % maintenance_info) if maintenance_info['status'] == 'complete': logger.fdebug( '[MAINTENANCE-MODE][%s] Successfully added %s [%s] to watchlist.' % (self.mode.upper(), maintenance_info['comicname'], maintenance_info['year'])) else: logger.fdebug( '[MAINTENANCE-MODE][%s] Unable to add %s [%s] to watchlist.' % (self.mode.upper(), maintenance_info['comicname'], maintenance_info['year'])) raise IOError self.maintenance_success.append(x) try: self.sql_attach() self.db.execute( "UPDATE maintenance SET progress=?, last_comicid=?, last_series=?, last_seriesyear=? WHERE id='1'", (count, re.sub('4050-', '', x['ComicID'].strip()), maintenance_info['comicname'], maintenance_info['year'])) self.sql_close() except Exception as e: logger.warn('[ERROR] %s' % e) except IOError as e: logger.warn( '[MAINTENANCE-MODE][%s] Unable to add series to watchlist: %s' % (self.mode.upper(), e)) self.maintenance_fail.append(x) count += 1 else: logger.warn( '[MAINTENANCE-MODE][%s] Unable to locate any series in db. This is probably a FATAL error and an unrecoverable db.' % self.mode.upper()) return logger.info( '[MAINTENANCE-MODE][%s] Successfully imported %s series into existing db.' % (self.mode.upper(), len(self.maintenance_success))) if len(self.maintenance_fail) > 0: logger.info( '[MAINTENANCE-MODE][%s] Failed to import %s series into existing db: %s' % (self.mode.upper(), len( self.maintenance_success), self.maintenance_fail)) try: self.sql_attach() self.db.execute("UPDATE maintenance SET status=? WHERE id='1'", ["completed"]) self.sql_close() except Exception as e: logger.warn('[ERROR] %s' % e)
def refreshArtist(self, ComicID): importer.addComictoDB(ComicID) raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % ComicID)