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(): def extractNew():
for f in ArchiveFile.select(ArchiveFile.q.extracted == False): for f in ArchiveFile.select(ArchiveFile.q.extracted == False):
f.extractAll() 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="file removed")
return dict(result="not in archive") return dict(result="not in archive")
#FIXME this fails for old frontends because it notifies the frontend
def importFrontend(self): def importFrontend(self):
if self.baseUrlFrontend: if self.baseUrlFrontend:
dto = socket.getdefaulttimeout() dto = socket.getdefaulttimeout()
@ -152,13 +153,22 @@ class Archive(SQLObject):
socket.setdefaulttimeout(dto) socket.setdefaulttimeout(dto)
for f in files: for f in files:
meta = files[f] meta = files[f]
meta['path'] = f fname = join(self.basePath, f)
meta = oxdb_import.oxdb_file_metadata(meta) if exists(fname):
meta['video'] = '' stats = oxdb_import.oxdb_file_stats(fname)
meta['audio'] = '' meta['date'] = stats['date']
meta['length'] = 0 meta['path'] = f
meta['bpp'] = 0 meta['video'] = ''
print self.addFile(meta), f 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): def importFiles(self):
stats = {'skipped': 0, 'added': 0, 'remove':0} stats = {'skipped': 0, 'added': 0, 'remove':0}
@ -189,7 +199,13 @@ class Archive(SQLObject):
stats['remove'] += 1 stats['remove'] += 1
print stats print stats
return 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): class ArchiveFile(SQLObject):
''' '''

View file

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