]> git.parisson.com Git - telemeta-data.git/commitdiff
test existence of the wav file before uploading
authoryomguy <yomguy@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Tue, 3 May 2011 14:32:41 +0000 (14:32 +0000)
committeryomguy <yomguy@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Tue, 3 May 2011 14:32:41 +0000 (14:32 +0000)
git-svn-id: http://svn.parisson.org/svn/crem@176 3bf09e05-f825-4182-b9bc-eedd7160adf0

trunk/import/audio_import/wav_import.py

index 898ed7afabb2853021ef61e7d8453bdb9542e7bc..8d7683ef1b7b600208412063bb23ac0ef51dfda6 100644 (file)
@@ -67,12 +67,17 @@ class TelemetaWavImport:
                     if len(items) != 0:
                         item = items[0]
                         print item.old_code + ' : id = ' + str(item.id) + " : title = " + item.title
-                        f = open(wav_file, 'r')
-                        file_content = ContentFile(f.read())
-                        item.file.save(filename, file_content)
-                        f.close()
-                        item.code = new_ref
-                        item.save()
+                        if os.path.exists(wav_file):
+                            f = open(wav_file, 'r')
+                            file_content = ContentFile(f.read())
+                            item.file.save(filename, file_content)
+                            f.close()
+                            item.code = new_ref
+                            item.save()
+                        else:
+                            msg = old_ref + ' : fichier audio ' + wav_file + ' inexistant !'
+                            print msg
+                            self.logger.write_error(collection, msg)
                     else:
                         msg = old_ref + ' : item inexistant dans la base de donnĂ©es !'
                         print msg