Merge branch '2.2.x' of dev.sourcefabric.org:airtime into 2.2.x
This commit is contained in:
commit
33b2520c14
21 changed files with 40 additions and 146 deletions
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import abc
|
||||
import re
|
||||
import media.monitor.pure as mmp
|
||||
import media.monitor.owners as owners
|
||||
from media.monitor.pure import LazyProperty
|
||||
|
@ -101,6 +102,12 @@ class BaseEvent(Loggable):
|
|||
self.path = os.path.normpath(raw_event.pathname)
|
||||
else: self.path = raw_event
|
||||
self.owner = owners.get_owner(self.path)
|
||||
owner_re = re.search('stor/imported/(?P<owner>\d+)/', self.path)
|
||||
if owner_re:
|
||||
self.logger.info("matched path: %s" % self.path)
|
||||
self.owner = owner_re.group('owner')
|
||||
else:
|
||||
self.logger.info("did not match path: %s" % self.path)
|
||||
self._pack_hook = lambda: None # no op
|
||||
# into another event
|
||||
|
||||
|
|
|
@ -5,26 +5,22 @@ log = get_logger()
|
|||
owners = {}
|
||||
|
||||
def reset_owners():
|
||||
"""
|
||||
Wipes out all file => owner associations
|
||||
"""
|
||||
""" Wipes out all file => owner associations """
|
||||
global owners
|
||||
owners = {}
|
||||
|
||||
|
||||
def get_owner(f):
|
||||
"""
|
||||
Get the owner id of the file 'f'
|
||||
"""
|
||||
return owners[f] if f in owners else -1
|
||||
""" Get the owner id of the file 'f' """
|
||||
o = owners[f] if f in owners else -1
|
||||
log.info("Received owner for %s. Owner: %s" % (f, o))
|
||||
return o
|
||||
|
||||
|
||||
def add_file_owner(f,owner):
|
||||
"""
|
||||
Associate file f with owner. If owner is -1 then do we will not record it
|
||||
because -1 means there is no owner. Returns True if f is being stored after
|
||||
the function. False otherwise.
|
||||
"""
|
||||
""" Associate file f with owner. If owner is -1 then do we will not record
|
||||
it because -1 means there is no owner. Returns True if f is being stored
|
||||
after the function. False otherwise. """
|
||||
if owner == -1: return False
|
||||
if f in owners:
|
||||
if owner != owners[f]: # check for fishiness
|
||||
|
@ -35,16 +31,12 @@ def add_file_owner(f,owner):
|
|||
return True
|
||||
|
||||
def has_owner(f):
|
||||
"""
|
||||
True if f is owned by somebody. False otherwise.
|
||||
"""
|
||||
""" True if f is owned by somebody. False otherwise. """
|
||||
return f in owners
|
||||
|
||||
def remove_file_owner(f):
|
||||
"""
|
||||
Try and delete any association made with file f. Returns true if the the
|
||||
association was actually deleted. False otherwise.
|
||||
"""
|
||||
""" Try and delete any association made with file f. Returns true if
|
||||
the the association was actually deleted. False otherwise. """
|
||||
if f in owners:
|
||||
del owners[f]
|
||||
return True
|
||||
|
|
|
@ -52,8 +52,6 @@ class RequestSync(Loggable):
|
|||
self.logger.info("ApiController.php probably crashed, we \
|
||||
diagnose this from the fact that it did not return \
|
||||
valid json")
|
||||
self.logger.info("Trying again after %f seconds" %
|
||||
self.request_wait)
|
||||
except Exception as e: self.unexpected_exception(e)
|
||||
else: self.logger.info("Request was successful")
|
||||
self.watcher.flag_done() # poor man's condition variable
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
import media.monitor.owners as owners
|
||||
from media.monitor import owners
|
||||
|
||||
class TestMMP(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue