コード例 #1
0
    def change_storage_root(self, store):
        """ 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
        for path_type, path in store_paths.iteritems():
            try: mmp.create_dir(path)
            except mmp.FailedToCreateDir as e: self.unexpected_exception(e)

        os.chmod(store_paths['organize'], 0775) 

        self.set_problem_files_path(store_paths['problem_files'])
        self.set_imported_path(store_paths['imported'])
        self.set_recorded_path(store_paths['recorded'])
        self.set_organize_path(store_paths['organize'])
コード例 #2
0
    def reload_directories(self):
        """ this is the 'real' constructor, should be called if you ever
        want the class reinitialized. there's not much point to doing
        it yourself however, you should just create a new AirtimeDB
        instance. """

        saas = user().root_path

        try:
            # dirs_setup is a dict with keys:
            # u'watched_dirs' and u'stor' which point to lists of corresponding
            # dirs
            dirs_setup = self.apc.setup_media_monitor()
            dirs_setup[u'stor'] = normpath(join(saas, dirs_setup[u'stor']))
            dirs_setup[u'watched_dirs'] = map(
                lambda p: normpath(join(saas, p)), dirs_setup[u'watched_dirs'])
            dirs_with_id = dict([(k, normpath(v))
                                 for k, v in self.apc.list_all_watched_dirs()
                                 ['dirs'].iteritems()])

            self.id_to_dir = dirs_with_id
            self.dir_to_id = dict([(v, k)
                                   for k, v in dirs_with_id.iteritems()])

            self.base_storage = dirs_setup[u'stor']
            self.storage_paths = mmp.expand_storage(self.base_storage)
            self.base_id = self.dir_to_id[self.base_storage]

            # hack to get around annoying schema of airtime db
            self.dir_to_id[self.recorded_path()] = self.base_id
            self.dir_to_id[self.import_path()] = self.base_id

            # We don't know from the x_to_y dict which directory is watched or
            # store...
            self.watched_directories = set(
                [os.path.normpath(p) for p in dirs_setup[u'watched_dirs']])
        except Exception, e:
            self.logger.info(str(e))
コード例 #3
0
ファイル: syncdb.py プロジェクト: Robbt/Airtime
    def reload_directories(self):
        """ this is the 'real' constructor, should be called if you ever
        want the class reinitialized. there's not much point to doing
        it yourself however, you should just create a new AirtimeDB
        instance. """

        saas = user().root_path

        try:
            # dirs_setup is a dict with keys:
            # u'watched_dirs' and u'stor' which point to lists of corresponding
            # dirs
            dirs_setup = self.apc.setup_media_monitor()
            dirs_setup[u'stor'] = normpath( join(saas, dirs_setup[u'stor'] ) )
            dirs_setup[u'watched_dirs'] = map(lambda p: normpath(join(saas,p)),
                dirs_setup[u'watched_dirs'])
            dirs_with_id = dict([ (k,normpath(v)) for k,v in
                self.apc.list_all_watched_dirs()['dirs'].iteritems() ])

            self.id_to_dir = dirs_with_id
            self.dir_to_id = dict([ (v,k) for k,v in dirs_with_id.iteritems() ])

            self.base_storage = dirs_setup[u'stor']
            self.storage_paths = mmp.expand_storage( self.base_storage )
            self.base_id = self.dir_to_id[self.base_storage]

            # hack to get around annoying schema of airtime db
            self.dir_to_id[ self.recorded_path() ] = self.base_id
            self.dir_to_id[ self.import_path() ] = self.base_id

            # We don't know from the x_to_y dict which directory is watched or
            # store...
            self.watched_directories = set([ os.path.normpath(p) for p in
                dirs_setup[u'watched_dirs'] ])
        except Exception, e:
            self.logger.info(str(e))