CC-3784: Some media files can be added twice when trying to upload 200 media files
-should be fixed
This commit is contained in:
parent
56fa147b6f
commit
7376e16077
5 changed files with 21 additions and 21 deletions
|
@ -39,7 +39,7 @@ php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \
|
||||||
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
||||||
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
||||||
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
||||||
libpulse0 vorbis-tools lsb-release lsof
|
libpulse0 vorbis-tools lsb-release lsof sudo
|
||||||
|
|
||||||
#install packages with --force-yes option (this is useful in the case
|
#install packages with --force-yes option (this is useful in the case
|
||||||
#of Debian, where these packages are unauthorized)
|
#of Debian, where these packages are unauthorized)
|
||||||
|
|
|
@ -42,7 +42,7 @@ php-pear php5-gd postgresql odbc-postgresql python libsoundtouch-ocaml \
|
||||||
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \
|
||||||
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \
|
||||||
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \
|
||||||
libpulse0 vorbis-tools lsb-release lsof
|
libpulse0 vorbis-tools lsb-release lsof sudo
|
||||||
|
|
||||||
#install packages with --force-yes option (this is useful in the case
|
#install packages with --force-yes option (this is useful in the case
|
||||||
#of Debian, where these packages are unauthorized)
|
#of Debian, where these packages are unauthorized)
|
||||||
|
|
|
@ -406,9 +406,6 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
logger = self.logger
|
logger = self.logger
|
||||||
response = None
|
response = None
|
||||||
try:
|
try:
|
||||||
|
|
||||||
start = time.time()
|
|
||||||
|
|
||||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_media_url"])
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_media_url"])
|
||||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
url = url.replace("%%mode%%", mode)
|
url = url.replace("%%mode%%", mode)
|
||||||
|
@ -422,9 +419,6 @@ class AirTimeApiClient(ApiClientInterface):
|
||||||
logger.info("update media %s, filepath: %s, mode: %s", response, md['MDATA_KEY_FILEPATH'], mode)
|
logger.info("update media %s, filepath: %s, mode: %s", response, md['MDATA_KEY_FILEPATH'], mode)
|
||||||
response = json.loads(response)
|
response = json.loads(response)
|
||||||
|
|
||||||
elapsed = (time.time() - start)
|
|
||||||
logger.info("time taken to get response %s", elapsed)
|
|
||||||
|
|
||||||
if("error" not in response and is_record):
|
if("error" not in response and is_record):
|
||||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_recorded"])
|
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["upload_recorded"])
|
||||||
url = url.replace("%%fileid%%", str(response[u'id']))
|
url = url.replace("%%fileid%%", str(response[u'id']))
|
||||||
|
|
|
@ -117,15 +117,15 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.logger.info("event: %s", event)
|
self.logger.info("event: %s", event)
|
||||||
self.logger.info("create_dict: %s", self.create_dict)
|
self.logger.info("create_dict: %s", self.create_dict)
|
||||||
|
|
||||||
if event.pathname in self.create_dict:
|
try:
|
||||||
# detele corresponding entry from create_dict
|
del self.create_dict[event.pathname]
|
||||||
self.create_dict.pop(event.pathname)
|
|
||||||
self.handle_created_file(event.dir, event.pathname, event.name)
|
self.handle_created_file(event.dir, event.pathname, event.name)
|
||||||
|
except KeyError, e:
|
||||||
|
self.logger.error("%s does not exist in create_dict", event.pathname)
|
||||||
|
|
||||||
def handle_created_file(self, dir, pathname, name):
|
def handle_created_file(self, dir, pathname, name):
|
||||||
if not dir:
|
if not dir:
|
||||||
self.logger.debug("PROCESS_IN_CLOSE_WRITE: %s, name: %s, pathname: %s ", dir, name, pathname)
|
self.logger.debug("PROCESS_IN_CLOSE_WRITE: %s, name: %s, pathname: %s ", dir, name, pathname)
|
||||||
#event is because of a created file
|
|
||||||
|
|
||||||
if self.mmc.is_temp_file(name) :
|
if self.mmc.is_temp_file(name) :
|
||||||
#file created is a tmp file which will be modified and then moved back to the original filename.
|
#file created is a tmp file which will be modified and then moved back to the original filename.
|
||||||
|
@ -150,8 +150,11 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.error('Exception: %s', e)
|
self.logger.error('Exception: %s', e)
|
||||||
self.logger.error("traceback: %s", traceback.format_exc())
|
self.logger.error("traceback: %s", traceback.format_exc())
|
||||||
|
finally:
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
# only append to self.file_events if the file isn't going to be altered by organize_new_file(). If file is going
|
||||||
|
# to be altered by organize_new_file(), then process_IN_MOVED_TO event will handle appending it to self.file_events
|
||||||
is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory)
|
is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory)
|
||||||
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
|
self.file_events.append({'mode': self.config.MODE_CREATE, 'filepath': pathname, 'is_recorded_show': is_recorded})
|
||||||
|
|
||||||
|
@ -239,7 +242,7 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
self.file_events.append({'filepath': event.pathname, 'mode': self.config.MODE_MODIFY})
|
self.file_events.append({'filepath': event.pathname, 'mode': self.config.MODE_MODIFY})
|
||||||
del self.temp_files[event.cookie]
|
del self.temp_files[event.cookie]
|
||||||
elif event.cookie in self.cookies_IN_MOVED_FROM:
|
elif event.cookie in self.cookies_IN_MOVED_FROM:
|
||||||
#files original location was also in a watched directory
|
#file's original location was also in a watched directory
|
||||||
del self.cookies_IN_MOVED_FROM[event.cookie]
|
del self.cookies_IN_MOVED_FROM[event.cookie]
|
||||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||||
filepath = self.mmc.organize_new_file(event.pathname)
|
filepath = self.mmc.organize_new_file(event.pathname)
|
||||||
|
@ -263,17 +266,18 @@ class AirtimeProcessEvent(ProcessEvent):
|
||||||
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
if self.mmc.is_parent_directory(event.pathname, self.config.organize_directory):
|
||||||
filepath = self.mmc.organize_new_file(event.pathname)
|
filepath = self.mmc.organize_new_file(event.pathname)
|
||||||
|
|
||||||
#delete files from organize if they can not be read properly.
|
#delete files from organize if they cannot be read properly.
|
||||||
if filepath is None:
|
if filepath is None:
|
||||||
try:
|
try:
|
||||||
self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname)
|
self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname)
|
||||||
os.remove(event.pathname)
|
os.remove(event.pathname)
|
||||||
return
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.logger.error('Exception: %s', e)
|
self.logger.error('Exception: %s', e)
|
||||||
self.logger.error("traceback: %s", traceback.format_exc())
|
self.logger.error("traceback: %s", traceback.format_exc())
|
||||||
|
finally:
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
#show dragged from unwatched folder into a watched folder. Do not "organize".:q!
|
#show moved from unwatched folder into a watched folder. Do not "organize".
|
||||||
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
|
if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory):
|
||||||
is_recorded = True
|
is_recorded = True
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -335,7 +335,9 @@ def test_file_playability(pathname):
|
||||||
|
|
||||||
#when there is an single apostrophe inside of a string quoted by apostrophes, we can only escape it by replace that apostrophe
|
#when there is an single apostrophe inside of a string quoted by apostrophes, we can only escape it by replace that apostrophe
|
||||||
#with '\''. This breaks the string into two, and inserts an escaped single quote in between them.
|
#with '\''. This breaks the string into two, and inserts an escaped single quote in between them.
|
||||||
command = "liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))'" % pathname.replace("'", "'\\''")
|
#We run the command as pypo because otherwise the target file is opened with write permissions, and this causes an ON_CLOSE_WRITE event
|
||||||
|
#to be fired :/
|
||||||
|
command = "sudo -u pypo liquidsoap -c 'output.dummy(audio_to_stereo(single(\"%s\")))'" % pathname.replace("'", "'\\''")
|
||||||
return_code = subprocess.call(command, shell=True)
|
return_code = subprocess.call(command, shell=True)
|
||||||
else:
|
else:
|
||||||
return_code = 0
|
return_code = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue