Merge branch '2.2.x' into 2.2.x-saas

Conflicts:
	airtime_mvc/application/controllers/PreferenceController.php
	airtime_mvc/application/controllers/ScheduleController.php
	airtime_mvc/application/forms/EmailServerPreferences.php
	airtime_mvc/application/forms/GeneralPreferences.php
	airtime_mvc/application/forms/LiveStreamingPreferences.php
	airtime_mvc/application/forms/Preferences.php
	airtime_mvc/application/forms/SupportSettings.php
	airtime_mvc/application/models/Schedule.php
	airtime_mvc/application/views/scripts/form/preferences.phtml
	airtime_mvc/application/views/scripts/form/preferences_email_server.phtml
	airtime_mvc/application/views/scripts/form/preferences_livestream.phtml
	airtime_mvc/application/views/scripts/form/support-setting.phtml
	airtime_mvc/application/views/scripts/menu.phtml
	airtime_mvc/application/views/scripts/schedule/add-
show-form.phtml
This commit is contained in:
Martin Konecny 2012-11-06 17:23:32 -05:00
commit 272e428fa7
19 changed files with 118 additions and 53 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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):