cc-4105: Tweaked config params. Fixed error checking. Fixed unicode stuff. Removed redundant php
This commit is contained in:
parent
c97857a138
commit
5f1024bb7d
|
@ -559,6 +559,8 @@ class ApiController extends Zend_Controller_Action
|
|||
// Valid requests must start with mdXXX where XXX represents at least 1 digit
|
||||
if( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||
$info_json = json_decode($raw_json, $assoc=true);
|
||||
$recorded = $info_json["is_record"];
|
||||
unset( $info_json["is_record"] );
|
||||
if( !array_key_exists('mode', $info_json) ) { // Log invalid requests
|
||||
Logging::log("Received bad request(key=$k), no 'mode' parameter. Bad request is:");
|
||||
Logging::log( $info_json );
|
||||
|
@ -589,9 +591,6 @@ class ApiController extends Zend_Controller_Action
|
|||
// On recorded show requests we do some extra work here. Not sure what it actually is and it
|
||||
// was usually called from the python api client. Now we just call it straight from the controller to
|
||||
// save the http roundtrip
|
||||
if( $info_json['is_record'] and !array_key_exists('error', $response) ) {
|
||||
$this->uploadRecordedActionParam($info_json['showinstanceid'],$info_json['fileid'],$dry_run=$dry);
|
||||
}
|
||||
}
|
||||
die( json_encode($responses) );
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ class AirtimeNotifier(Loggable):
|
|||
except Exception as e:
|
||||
self.logger.info("Failed to initialize RabbitMQ consumer")
|
||||
self.logger.error(e)
|
||||
raise
|
||||
|
||||
def handle_message(self, body, message):
|
||||
"""
|
||||
|
|
|
@ -5,7 +5,7 @@ from media.monitor.toucher import RepeatTimer
|
|||
class EventDrainer(Loggable):
|
||||
def __init__(self, connection, interval=1):
|
||||
def cb():
|
||||
try: connection.drain_events(timeout=0.1)
|
||||
try: connection.drain_events(timeout=0.3)
|
||||
except socket.timeout: pass
|
||||
except Exception as e:
|
||||
self.logger.error("Error flushing events")
|
||||
|
|
|
@ -46,6 +46,7 @@ class FileMediator(object):
|
|||
|
||||
def mediate_ignored(fn):
|
||||
def wrapped(self, event, *args,**kwargs):
|
||||
event.pathname = unicode(event.pathname, "utf-8")
|
||||
if FileMediator.is_ignored(event.pathname):
|
||||
FileMediator.logger.info("Ignoring: '%s' (once)" % event.pathname)
|
||||
FileMediator.unignore(event.pathname)
|
||||
|
@ -93,6 +94,7 @@ class StoreWatchListener(BaseListener, Loggable, pyinotify.ProcessEvent):
|
|||
@mediate_ignored
|
||||
@IncludeOnly(mmp.supported_extensions)
|
||||
def process_delete(self, event):
|
||||
print(event)
|
||||
dispatcher.send(signal=self.signal, sender=self, event=DeleteFile(event))
|
||||
|
||||
def flush_events(self, path):
|
||||
|
|
|
@ -6,6 +6,7 @@ import copy
|
|||
from media.monitor.handler import ReportHandler
|
||||
from media.monitor.events import NewFile, DeleteFile
|
||||
from media.monitor.log import Loggable
|
||||
from media.monitor.listeners import FileMediator
|
||||
from media.monitor.exceptions import BadSongFile
|
||||
from media.monitor.pure import LazyProperty
|
||||
|
||||
|
@ -17,6 +18,7 @@ class RequestSync(threading.Thread,Loggable):
|
|||
self.watcher = watcher
|
||||
self.requests = requests
|
||||
self.retries = 3
|
||||
self.request_wait = 0.3
|
||||
|
||||
@LazyProperty
|
||||
def apiclient(self):
|
||||
|
@ -38,11 +40,13 @@ class RequestSync(threading.Thread,Loggable):
|
|||
try: make_req()
|
||||
except ValueError:
|
||||
self.logger.info("Api Controller is a piece of shit... will fix once I setup the damn debugger")
|
||||
self.logger.info("Trying again...")
|
||||
self.logger.info("Trying again after %f seconds" % self.request_wait)
|
||||
time.sleep( self.request_wait )
|
||||
else:
|
||||
self.logger.info("Request worked on the '%d' try" % (try_index + 1))
|
||||
break
|
||||
else: self.logger.info("Failed to send request after '%d' tries..." % self.retries)
|
||||
self.logger.info("Now ignoring: %d files" % len(FileMediator.ignored_set))
|
||||
self.watcher.flag_done()
|
||||
|
||||
class TimeoutWatcher(threading.Thread,Loggable):
|
||||
|
|
Loading…
Reference in New Issue