From ce313a5b22ca0cd3f8a1dbb3678661671b148642 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 5 Nov 2012 13:29:10 -0500 Subject: [PATCH] docstring formatting --- .../media-monitor2/media/monitor/manager.py | 98 +++++++------------ 1 file changed, 34 insertions(+), 64 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/manager.py b/python_apps/media-monitor2/media/monitor/manager.py index 548590f38..2c5512ec6 100644 --- a/python_apps/media-monitor2/media/monitor/manager.py +++ b/python_apps/media-monitor2/media/monitor/manager.py @@ -13,11 +13,10 @@ import media.monitor.pure as mmp class ManagerTimeout(threading.Thread,Loggable): - """ - The purpose of this class is to flush the organize directory every 3 - secnods. This used to be just a work around for cc-4235 but recently - became a permanent solution because it's "cheap" and reliable - """ + """ The purpose of this class is to flush the organize directory + every 3 secnods. This used to be just a work around for cc-4235 + but recently became a permanent solution because it's "cheap" and + reliable """ def __init__(self, manager, interval=1.5): # TODO : interval should be read from config and passed here instead # of just using the hard coded value @@ -30,11 +29,9 @@ class ManagerTimeout(threading.Thread,Loggable): self.manager.flush_organize() class Manager(Loggable): - """ - An abstraction over media monitors core pyinotify functions. These - include adding watched,store, organize directories, etc. Basically - composes over WatchManager from pyinotify - """ + """ An abstraction over media monitors core pyinotify functions. + These include adding watched,store, organize directories, etc. + Basically composes over WatchManager from pyinotify """ def __init__(self): self.wm = pyinotify.WatchManager() # These two instance variables are assumed to be constant @@ -76,23 +73,19 @@ class Manager(Loggable): # through dedicated handler objects. Because we must have access to a # manager instance. Hence we must slightly break encapsulation. def watch_move(self, watch_dir, sender=None): - """ - handle 'watch move' events directly sent from listener - """ + """ handle 'watch move' events directly sent from listener """ self.logger.info("Watch dir '%s' has been renamed (hence removed)" % watch_dir) self.remove_watch_directory(normpath(watch_dir)) def watch_signal(self): - """ - Return the signal string our watch_listener is reading events from - """ + """ Return the signal string our watch_listener is reading + events from """ return self.watch_listener.signal def __remove_watch(self,path): - """ - Remove path from being watched (first will check if 'path' is watched) - """ + """ Remove path from being watched (first will check if 'path' + is watched) """ # only delete if dir is actually being watched if path in self.__wd_path: wd = self.__wd_path[path] @@ -100,10 +93,8 @@ class Manager(Loggable): del(self.__wd_path[path]) def __add_watch(self,path,listener): - """ - Start watching 'path' using 'listener'. First will check if directory - is being watched before adding another watch - """ + """ Start watching 'path' using 'listener'. First will check if + directory is being watched before adding another watch """ self.logger.info("Attempting to add listener to path '%s'" % path) self.logger.info( 'Listener: %s' % str(listener) ) @@ -114,9 +105,8 @@ class Manager(Loggable): if wd: self.__wd_path[path] = wd.values()[0] def __create_organizer(self, target_path, recorded_path): - """ - creates an organizer at new destination path or modifies the old one - """ + """ creates an organizer at new destination path or modifies the + old one """ # TODO : find a proper fix for the following hack # We avoid creating new instances of organize because of the way # it interacts with pydispatch. We must be careful to never have @@ -134,23 +124,17 @@ class Manager(Loggable): recorded_path=recorded_path) def get_problem_files_path(self): - """ - returns the path where problem files should go - """ + """ returns the path where problem files should go """ return self.organize['problem_files_path'] def set_problem_files_path(self, new_path): - """ - Set the path where problem files should go - """ + """ Set the path where problem files should go """ self.organize['problem_files_path'] = new_path self.organize['problem_handler'] = \ ProblemFileHandler( PathChannel(signal='badfile',path=new_path) ) def get_recorded_path(self): - """ - returns the path of the recorded directory - """ + """ returns the path of the recorded directory """ return self.organize['recorded_path'] def set_recorded_path(self, new_path): @@ -160,17 +144,14 @@ class Manager(Loggable): self.__add_watch(new_path, self.watch_listener) def get_organize_path(self): - """ - returns the current path that is being watched for organization - """ + """ returns the current path that is being watched for + organization """ return self.organize['organize_path'] def set_organize_path(self, new_path): - """ - sets the organize path to be new_path. Under the current scheme there - is only one organize path but there is no reason why more cannot be - supported - """ + """ sets the organize path to be new_path. Under the current + scheme there is only one organize path but there is no reason + why more cannot be supported """ # if we are already organizing a particular directory we remove the # watch from it first before organizing another directory self.__remove_watch(self.organize['organize_path']) @@ -188,19 +169,15 @@ class Manager(Loggable): return self.organize['imported_path'] def set_imported_path(self,new_path): - """ - set the directory where organized files go to. - """ + """ set the directory where organized files go to. """ self.__remove_watch(self.organize['imported_path']) self.organize['imported_path'] = new_path self.__create_organizer( new_path, self.organize['recorded_path']) self.__add_watch(new_path, self.watch_listener) def change_storage_root(self, store): - """ - hooks up all the directories for you. Problem, recorded, imported, - organize. - """ + """ hooks up all the directories for you. Problem, recorded, + imported, organize. """ store_paths = mmp.expand_storage(store) # First attempt to make sure that all paths exist before adding any # watches @@ -217,18 +194,14 @@ class Manager(Loggable): mmp.create_dir(p) def has_watch(self, path): - """ - returns true if the path is being watched or not. Any kind of watch: - organize, store, watched. - """ + """ returns true if the path is being watched or not. Any kind + of watch: organize, store, watched. """ return path in self.__wd_path def add_watch_directory(self, new_dir): - """ - adds a directory to be "watched". "watched" directories are + """ adds a directory to be "watched". "watched" directories are those that are being monitored by media monitor for airtime in - this context and not directories pyinotify calls watched - """ + this context and not directories pyinotify calls watched """ if self.has_watch(new_dir): self.logger.info("Cannot add '%s' to watched directories. It's \ already being watched" % new_dir) @@ -237,9 +210,8 @@ class Manager(Loggable): self.__add_watch(new_dir, self.watch_listener) def remove_watch_directory(self, watch_dir): - """ - removes a directory from being "watched". Undoes add_watch_directory - """ + """ removes a directory from being "watched". Undoes + add_watch_directory """ if self.has_watch(watch_dir): self.logger.info("Removing watched directory: '%s'", watch_dir) self.__remove_watch(watch_dir) @@ -250,9 +222,7 @@ class Manager(Loggable): self.logger.info( self.__wd_path ) def loop(self): - """ - block until we receive pyinotify events - """ + """ block until we receive pyinotify events """ notifier = pyinotify.Notifier(self.wm) notifier.coalesce_events() notifier.loop()