bootstrap

This commit is contained in:
j 2007-07-11 12:08:00 +00:00
parent e8e5a492e9
commit b7f8d1fe8a
3 changed files with 35 additions and 9 deletions

View file

@ -11,3 +11,13 @@ def findeNew():
def extractNew():
for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
f.extractAll()
#possible fuctions:
'''
def extractSubtitles():
#look for rar / sub or vob / sub subtitles and extract them with
#tools/subtitles.py path_to_file
#import srt after
'''

View file

@ -142,6 +142,7 @@ class Archive(SQLObject):
return dict(result="file removed")
return dict(result="not in archive")
#FIXME this fails for old frontends because it notifies the frontend
def importFrontend(self):
if self.baseUrlFrontend:
dto = socket.getdefaulttimeout()
@ -152,13 +153,22 @@ class Archive(SQLObject):
socket.setdefaulttimeout(dto)
for f in files:
meta = files[f]
meta['path'] = f
meta = oxdb_import.oxdb_file_metadata(meta)
meta['video'] = ''
meta['audio'] = ''
meta['length'] = 0
meta['bpp'] = 0
print self.addFile(meta), f
fname = join(self.basePath, f)
if exists(fname):
stats = oxdb_import.oxdb_file_stats(fname)
meta['date'] = stats['date']
meta['path'] = f
meta['video'] = ''
meta['audio'] = ''
meta['length'] = 0
meta['bpp'] = 0
for key in ('bpp', 'size', 'length', 'date'):
meta[key] = int(float(meta[key]))
meta['date'] = datetime.fromtimestamp(meta['date'])
print self.addFile(meta), f
else:
print "remove", f
self.removeFile({'md5sum':meta['md5sum']})
def importFiles(self):
stats = {'skipped': 0, 'added': 0, 'remove':0}
@ -190,6 +200,12 @@ class Archive(SQLObject):
print stats
return stats
'''
notify frontend about each file we have.
'''
def bootstrapFrontend(self):
for f in self.files:
self.notifyFrontend('add', f.md5sum)
class ArchiveFile(SQLObject):
'''

View file

@ -41,7 +41,7 @@ class OXDb:
def oxdb_md5sum(fname):
'''Returns an md5 hash for file'''
msum = None
md5sum = None
if os.path.exists(fname):
f = file(fname, 'rb')
m = md5.new()