예제 #1
0
    def run(self):
        self.index_create()
        manager = Manager()
        apiclient = apc()
        config = user().mm_config
        WatchSyncer(signal=getsig('watch'),
                    chunking_number=config['chunking_number'],
                    timeout=config['request_max_wait'])
        airtime_receiver = AirtimeMessageReceiver(config, manager)
        airtime_notifier = AirtimeNotifier(config, airtime_receiver)

        adb = AirtimeDB(apiclient)
        store = {
            u'stor': adb.storage_path(),
            u'watched_dirs': adb.list_watched(),
        }

        self.logger.info("initializing mm with directories: %s" % str(store))

        self.logger.info("Initing with the following airtime response:%s" %
                         str(store))

        airtime_receiver.change_storage({'directory': store[u'stor']})

        for watch_dir in store[u'watched_dirs']:
            if not os.path.exists(watch_dir):
                # Create the watch_directory here
                try:
                    os.makedirs(watch_dir)
                except Exception:
                    self.logger.error("Could not create watch directory: '%s' \
                            (given from the database)." % watch_dir)
            if os.path.exists(watch_dir):
                airtime_receiver.new_watch({'directory': watch_dir},
                                           restart=True)
            else:
                self.logger.info("Failed to add watch on %s" % str(watch_dir))

        EventDrainer(airtime_notifier,
                     interval=float(config['rmq_event_wait']))

        # Launch the toucher that updates the last time when the script was
        # ran every n seconds.
        # TODO : verify that this does not interfere with bootstrapping because the
        # toucher thread might update the last_ran variable too fast
        ToucherThread(path=user().touch_file_path(),
                      interval=int(config['touch_interval']))

        success = False
        while not success:
            try:
                apiclient.register_component('media-monitor')
                success = True
            except Exception, e:
                self.logger.error(str(e))
                import time
                time.sleep(10)
예제 #2
0
파일: launcher.py 프로젝트: AtomLaw/Airtime
    def run(self):
        self.index_create()
        manager = Manager()
        apiclient = apc()
        config = user().mm_config
        WatchSyncer(signal=getsig('watch'),
                chunking_number=config['chunking_number'],
                timeout=config['request_max_wait'])
        airtime_receiver = AirtimeMessageReceiver(config,manager)
        airtime_notifier = AirtimeNotifier(config, airtime_receiver)


        adb = AirtimeDB(apiclient)
        store = {
                u'stor' : adb.storage_path(),
                u'watched_dirs' : adb.list_watched(),
        }

        self.logger.info("initializing mm with directories: %s" % str(store))

        self.logger.info(
                "Initing with the following airtime response:%s" % str(store))

        airtime_receiver.change_storage({ 'directory':store[u'stor'] })

        for watch_dir in store[u'watched_dirs']:
            if not os.path.exists(watch_dir):
                # Create the watch_directory here
                try: os.makedirs(watch_dir)
                except Exception:
                    self.logger.error("Could not create watch directory: '%s' \
                            (given from the database)." % watch_dir)
            if os.path.exists(watch_dir):
                airtime_receiver.new_watch({ 'directory':watch_dir }, restart=True)
            else: self.logger.info("Failed to add watch on %s" % str(watch_dir))

        EventDrainer(airtime_notifier,
                interval=float(config['rmq_event_wait']))

        # Launch the toucher that updates the last time when the script was
        # ran every n seconds.
        # TODO : verify that this does not interfere with bootstrapping because the
        # toucher thread might update the last_ran variable too fast
        ToucherThread(path=user().touch_file_path(),
                interval=int(config['touch_interval']))

        success = False
        while not success:
            try:
                apiclient.register_component('media-monitor')
                success = True
            except Exception, e:
                self.logger.error(str(e))
                import time
                time.sleep(10)
예제 #3
0
파일: airtime.py 프로젝트: Cougar/Airtime
 def __request_now_bootstrap(self, directory_id=None, directory=None,
         all_files=True):
     if (not directory_id) and (not directory):
         raise ValueError("You must provide either directory_id or \
                 directory")
     sdb = AirtimeDB(apc())
     if directory            : directory = os.path.normpath(directory)
     if directory_id == None : directory_id = sdb.to_id(directory)
     if directory    == None : directory = sdb.to_directory(directory_id)
     try:
         bs = Bootstrapper( sdb, self.manager.watch_signal() )
         bs.flush_watch( directory=directory, last_ran=self.cfg.last_ran() )
     except Exception as e:
         self.fatal_exception("Exception bootstrapping: (dir,id)=(%s,%s)" %
                              (directory, directory_id), e)
         raise DirectoryIsNotListed(directory, cause=e)
예제 #4
0
 def __request_now_bootstrap(self,
                             directory_id=None,
                             directory=None,
                             all_files=True):
     if (not directory_id) and (not directory):
         raise ValueError("You must provide either directory_id or \
                 directory")
     sdb = AirtimeDB(apc())
     if directory: directory = os.path.normpath(directory)
     if directory_id == None: directory_id = sdb.to_id(directory)
     if directory == None: directory = sdb.to_directory(directory_id)
     try:
         bs = Bootstrapper(sdb, self.manager.watch_signal())
         bs.flush_watch(directory=directory, last_ran=self.cfg.last_ran())
     except Exception as e:
         self.fatal_exception(
             "Exception bootstrapping: (dir,id)=(%s,%s)" %
             (directory, directory_id), e)
         raise DirectoryIsNotListed(directory, cause=e)
예제 #5
0
파일: request.py 프로젝트: Gambiit/airtime
 def create_with_api_client(cls, watcher, requests):
     apiclient = apc()
     self = cls(watcher, requests, apiclient)
     return self
예제 #6
0
파일: request.py 프로젝트: AtomLaw/Airtime
 def create_with_api_client(cls, watcher, requests):
     apiclient = apc()
     self = cls(watcher, requests, apiclient)
     return self