コード例 #1
0
    def autoset_equivalent_dest_folder(self, orig_paths):
        self.debugprint('Trying to create an eqivalent dest_folder for %s' %
                        (pjoin(self.dest_category, self.dest_series_folder)))

        if self.dest_category and not self.dest_series_folder == "":
            # let's create an equivalent dir on a different drive
            for cat_folder in self.dest_category_paths():
                possible_path = pjoin(cat_folder, self.dest_series_folder)

                self.debugprint('Checking:' + possible_path)
                self.debugprint('Equivalent candidate: ' + possible_path)

                if os.path.exists(possible_path) and enough_space(orig_paths, possible_path):
                    msg = 'Equivalent candidate exists already and has enough space: %s'
                    self.debugprint(msg % (possible_path,))

                    self.dest_folder = cat_folder
                    self.dest_dirpath = possible_path
                    return

            for cat_folder in self.dest_category_paths():
                self.debugprint('Equivalent candidate has enough space: ' + possible_path)
                possible_path = pjoin(cat_folder, self.dest_series_folder)

                if enough_space(orig_paths, possible_path):
                    self.dest_folder = cat_folder
                    self.dest_dirpath = possible_path
                    return

            # There are no drives in the list with enough disk space ... :(
            # TODO: Bail here.

        else:
            # we don't have enough info to make the dir on a different drive
            pass
コード例 #2
0
    def autoset_dest_dirpath(self, possible_series_foldernames, orig_paths):
        """
        dest_dirpath is the 'series name' or similar folder inside the
            category folder
        """

        self.debugprint('retorrenter.autoset_dest_dirpath(%r)' % (possible_series_foldernames,))

        if self.dest_category:
            # the dest category is already set from somewhere else
            categories = [(self.dest_category, self.categories[self.dest_category])]
        else:
            categories = self.categories.items()

        for category, details in categories:
            for cat_folder in details['content_paths']:
                for poss_series_folder in possible_series_foldernames:
                    possible_path = expanduser(pjoin(cat_folder, poss_series_folder))
                    self.debugprint('Looking for ' + possible_path)
                    if os.path.exists(possible_path) or possible_path in self.expected_dirs:
                        self.dest_category = category

                        self.dest_series_folder = poss_series_folder
                        if enough_space(orig_paths, possible_path):
                            self.dest_folder = cat_folder
                            self.dest_dirpath = possible_path
                        else:
                            # Not enough space, but we have the series_folder.
                            # Lets try another disk, or fail

                            # 2013-04: commenting this for testing...
                            # self.dest_category['paths'].remove(cat_folder)
                            self.autoset_equivalent_dest_folder(orig_paths)
                        return
コード例 #3
0
 def autoset_dest_folder_from_dest_category(self, orig_paths):
     if self.dest_category:
         for path in self.categories[self.dest_category]['content_paths']:
             self.debugprint('Possible path: ' + path)
             if not os.path.exists(path):
                 print "Warning: Config contains a path that doesn't exist: %s" % (path,)
             elif enough_space(orig_paths, path):
                 self.debugprint('Setting dest_folder to: ' + path)
                 self.dest_folder = path
                 return