cc-4105: added event packing to event objects
This commit is contained in:
parent
be00cc6990
commit
3422eb3cc0
|
@ -468,6 +468,7 @@ class ApiController extends Zend_Controller_Action
|
|||
);
|
||||
}
|
||||
Application_Model_Preference::SetImportTimestamp();
|
||||
Logging::log("--->Mode: $mode and file: {$md['MDATA_KEY_FILEPATH']} ");
|
||||
if ($mode == "create") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
$filepath = Application_Common_OsPath::normpath($filepath);
|
||||
|
@ -539,6 +540,7 @@ class ApiController extends Zend_Controller_Action
|
|||
return $return_hash;
|
||||
}
|
||||
$return_hash['fileid'] = $file->getId();
|
||||
Logging::log("Have we returned jack shit???");
|
||||
return $return_hash;
|
||||
}
|
||||
|
||||
|
@ -591,6 +593,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$this->uploadRecordedActionParam($info_json['showinstanceid'],$info_json['fileid'],$dry_run=$dry);
|
||||
}
|
||||
}
|
||||
Logging::log("returning response ><<><><><><><><");
|
||||
die( json_encode($responses) );
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ class AirtimeApiClient():
|
|||
# file
|
||||
@staticmethod
|
||||
def create_right_config(log=None,config_path=None):
|
||||
if config_path: default_config = config_path
|
||||
return AirtimeApiClient( logger=None, config_path=default_config )
|
||||
if config_path: AirtimeApiClient.default_config = config_path
|
||||
return AirtimeApiClient( logger=None, config_path=AirtimeApiClient.default_config )
|
||||
|
||||
def __init__(self, logger=None,config_path='/etc/airtime/api_client.cfg'):
|
||||
if logger is None:
|
||||
|
@ -403,7 +403,7 @@ class AirtimeApiClient():
|
|||
# debugging
|
||||
for action in action_list:
|
||||
if not 'mode' in action:
|
||||
self.logger.debug("Warning: Sending a request element without a 'mode'")
|
||||
self.logger.debug("Warning: Trying to send a request element without a 'mode'")
|
||||
self.logger.debug("Here is the the request: '%s'" % str(action) )
|
||||
else:
|
||||
# We alias the value of is_record to true or false no
|
||||
|
@ -428,6 +428,7 @@ class AirtimeApiClient():
|
|||
response = json.loads(response)
|
||||
return response
|
||||
except Exception, e:
|
||||
import ipdb; ipdb.set_trace()
|
||||
logger.error('Exception: %s', e)
|
||||
logger.error("traceback: %s", traceback.format_exc())
|
||||
raise
|
||||
|
|
|
@ -35,7 +35,24 @@ class BaseEvent(object):
|
|||
|
||||
class OrganizeFile(BaseEvent, HasMetaData):
|
||||
def __init__(self, *args, **kwargs): super(OrganizeFile, self).__init__(*args, **kwargs)
|
||||
def pack(self):
|
||||
raise AttributeError("What the hell are you doing? You can't send organize events to airtime!!!")
|
||||
|
||||
class NewFile(BaseEvent, HasMetaData):
|
||||
def __init__(self, *args, **kwargs): super(NewFile, self).__init__(*args, **kwargs)
|
||||
def pack(self):
|
||||
"""
|
||||
packs turns an event into a media monitor request
|
||||
"""
|
||||
req_dict = self.metadata.extract()
|
||||
req_dict['mode'] = 'create'
|
||||
req_dict['MDATA_KEY_FILEPATH'] = self.path
|
||||
return req_dict
|
||||
|
||||
class DeleteFile(BaseEvent):
|
||||
def __init__(self, *args, **kwargs): super(DeleteFile, self).__init__(*args, **kwargs)
|
||||
def pack(self):
|
||||
req_dict = {}
|
||||
req_dict['mode'] = 'delete'
|
||||
req_dict['MDATA_KEY_FILEPATH'] = self.path
|
||||
return req_dict
|
||||
|
|
|
@ -92,6 +92,7 @@ def truncate_to_length(item, length):
|
|||
else: return item
|
||||
|
||||
class Metadata(Loggable):
|
||||
|
||||
@staticmethod
|
||||
def write_unsafe(path,md):
|
||||
if not os.path.exists(path):
|
||||
|
|
|
@ -28,7 +28,7 @@ class RequestSync(threading.Thread,Loggable):
|
|||
# Not forget to attach the 'is_record' to any requests that are related
|
||||
# to recorded shows
|
||||
# A simplistic request would like:
|
||||
self.apiclient.send_media_monitor_requests(self.requests)
|
||||
self.apiclient.send_media_monitor_requests([ req.pack() for req in self.requests ])
|
||||
self.watcher.flag_done()
|
||||
|
||||
class TimeoutWatcher(threading.Thread,Loggable):
|
||||
|
|
Loading…
Reference in New Issue