From: Guillaume Pellerin Date: Mon, 9 Mar 2015 17:01:20 +0000 (+0100) Subject: fix backup path X-Git-Tag: 1.6a^2~60 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b09c4a92dc1c2920892d8900ab6d3032620df3c2;p=telemeta.git fix backup path --- diff --git a/telemeta/backup/core.py b/telemeta/backup/core.py index 16f3b9b5..833a4bbc 100644 --- a/telemeta/backup/core.py +++ b/telemeta/backup/core.py @@ -44,11 +44,8 @@ from telemeta.models import MediaItem class CollectionSerializer(object): """Provide backup-related features""" - def __init__(self, collection, dest_dir='.'): + def __init__(self, collection, dest_dir='/tmp/'): self.collection = collection - self.coll_dir = dest_dir + "/" + str(self.collection.id) - if not os.path.exists(self.coll_dir): - os.makedirs(self.coll_dir) def __get_file_md5(self, path): "Compute the MD5 hash of a file (Python version of md5sum)" @@ -65,6 +62,14 @@ class CollectionSerializer(object): def __get_media_filename(self, item): return str(item.id) + ".wav" + def backup(self, dest_dir): + self.coll_dir = dest_dir + "/" + str(self.collection.id) + if not os.path.exists(self.coll_dir): + os.makedirs(self.coll_dir) + self.store_json() + self.store_xml() + self.store_files() + def store_files(self): if self.collection.has_mediafile(): md5_file = open(self.coll_dir + "/MD5SUM", "wb") diff --git a/tools/scripts/telemeta-backup.py b/tools/scripts/telemeta-backup.py index 2ccf0094..0a314998 100755 --- a/tools/scripts/telemeta-backup.py +++ b/tools/scripts/telemeta-backup.py @@ -75,7 +75,7 @@ def backup(dest_dir): % (i, count, i*100/count, collection.id), sys.stdout.flush() serializer = CollectionSerializer(collection) - serializer.store(set_dir) + serializer.backup(set_dir) print "Done" def run(): @@ -89,6 +89,6 @@ def run(): import settings setup_environ(settings) backup(backup_dir) - + if __name__ == '__main__': run()