Index: jamu.py =================================================================== --- jamu.py (revision 24947) +++ jamu.py (working copy) @@ -510,7 +510,7 @@ else: print u'\n! Warning - Check that (%s) is correctly configured\n' % filename except Exception, e: - print u"\n! Warning - Creating an instance caused an error for one of: MythDBConn or MythVideo, error(%s)\n" % e + print u"\n! Warning - Creating an instance caused an error for one of: MythDB or MythVideo, error(%s)\n" % e try: MythLog._setlevel('none') # Some non option -M cannot have any logging on stdout mythbeconn = MythBE(backend=localhostname, db=mythdb) @@ -584,29 +584,19 @@ _where = 'intid=%s' _setwheredat = 'self.intid,' _logmodule = 'Python VideoType' - @staticmethod - def getAll(db=None): - db = MythDB(db) - c = db.cursor() - c.execute("""SELECT * FROM videotypes""") - types = [] - for row in c.fetchall(): - types.append(VideoTypes(db=db, raw=row)) - c.close() - return types def __str__(self): return "" % self.extension def __repr__(self): return str(self).encode('utf-8') - def __init__(self, id=None, ext=None, db=None, raw=None): - if raw is not None: - DBData.__init__(self, db=db, raw=raw) - elif id is not None: + def __init__(self, id=None, ext=None, db=None): + if id is not None: DBData.__init__(self, data=(id,), db=db) elif ext is not None: self.__dict__['_where'] = 'extension=%s' self.__dict__['_wheredat'] = 'self.extension,' DBData.__init__(self, data=(ext,), db=db) + else: + DBData.__init__(self, None, db=db) # end VideoTypes() def isValidPosixFilename(name, NAME_MAX=255): @@ -759,24 +749,23 @@ return nothing ''' records = mythdb.getStorageGroup(hostname=localhostname) - if records: - for record in records: - # Only include Video, coverfile, banner, fanart, screenshot and trailers storage groups - if record.groupname in storagegroupnames.keys(): - dirname = record.dirname - try: - dirname = unicode(record.dirname, 'utf8') - except (UnicodeDecodeError): - sys.stderr.write(u"\n! Error: The local Storage group (%s) directory contained\ncharacters that caused a UnicodeDecodeError. This storage group has been rejected.'\n" % (record['groupname'])) - continue # Skip any line that has non-utf8 characters in it - except (UnicodeEncodeError, TypeError): - pass - # Strip the trailing slash so it is consistent with all other directory paths in Jamu - if dirname[-1:] == u'/': - storagegroups[storagegroupnames[record.groupname]].append(dirname[:-1]) - else: - storagegroups[storagegroupnames[record.groupname]].append(dirname) - continue + for record in records: + # Only include Video, coverfile, banner, fanart, screenshot and trailers storage groups + if record.groupname in storagegroupnames.keys(): + dirname = record.dirname + try: + dirname = unicode(record.dirname, 'utf8') + except (UnicodeDecodeError): + sys.stderr.write(u"\n! Error: The local Storage group (%s) directory contained\ncharacters that caused a UnicodeDecodeError. This storage group has been rejected.'\n" % (record['groupname'])) + continue # Skip any line that has non-utf8 characters in it + except (UnicodeEncodeError, TypeError): + pass + # Strip the trailing slash so it is consistent with all other directory paths in Jamu + if dirname[-1:] == u'/': + storagegroups[storagegroupnames[record.groupname]].append(dirname[:-1]) + else: + storagegroups[storagegroupnames[record.groupname]].append(dirname) + continue any_storage_group = False tmp_storagegroups = dict(storagegroups) @@ -1657,22 +1646,21 @@ """ # Get videotypes table field names: try: - records = VideoTypes.getAll() + records = VideoTypes.getAllEntries(mythdb) except MythError, e: sys.stderr.write(u"\n! Error: Reading videotypes MythTV table: %s\n" % e.args[0]) return False - if records: - for record in records: - # Remove any extentions that are in Jamu's list but the user wants ignore - if record.f_ignore: - if record.extension in self.config['video_file_exts']: - self.config['video_file_exts'].remove(record.extension) - if record.extension.lower() in self.config['video_file_exts']: - self.config['video_file_exts'].remove(record.extension.lower()) - else: # Add extentions that are not in the Jamu list - if not record.extension in self.config['video_file_exts']: - self.config['video_file_exts'].append(record.extension) + for record in records: + # Remove any extentions that are in Jamu's list but the user wants ignore + if record.f_ignore: + if record.extension in self.config['video_file_exts']: + self.config['video_file_exts'].remove(record.extension) + if record.extension.lower() in self.config['video_file_exts']: + self.config['video_file_exts'].remove(record.extension.lower()) + else: # Add extentions that are not in the Jamu list + if not record.extension in self.config['video_file_exts']: + self.config['video_file_exts'].append(record.extension) # Make sure that all video file extensions are lower case for index in range(len(self.config['video_file_exts'])): self.config['video_file_exts'][index] = self.config['video_file_exts'][index].lower()