コード例 #1
0
ファイル: helpers_tests.py プロジェクト: youdroid/SickChill
 def test_is_subdirectory(self):
     """
     Test is_subdirectory
     """
     self.assertTrue(helpers.is_subdirectory(subdir_path='/usr/SickChill/Downloads/Unpack', topdir_path='/usr/SickChill/Downloads'))
     self.assertTrue(helpers.is_subdirectory(subdir_path='/usr/SickChill/Downloads/testfile.tst', topdir_path='/usr/SickChill/Downloads/'))
     self.assertFalse(helpers.is_subdirectory(subdir_path='/usr/SickChill/Unpack', topdir_path='/usr/SickChill/Downloads'))
コード例 #2
0
ファイル: helpers_tests.py プロジェクト: magicseb/SickRage
 def test_is_subdirectory(self):
     """
     Test is_subdirectory
     """
     self.assertTrue(helpers.is_subdirectory(subdir_path='/usr/SickRage/Downloads/Unpack', topdir_path='/usr/SickRage/Downloads'))
     self.assertTrue(helpers.is_subdirectory(subdir_path='/usr/SickRage/Downloads/testfile.tst', topdir_path='/usr/SickRage/Downloads/'))
     self.assertFalse(helpers.is_subdirectory(subdir_path='/usr/SickRage/Unpack', topdir_path='/usr/SickRage/Downloads'))
コード例 #3
0
ファイル: config.py プロジェクト: billwurles/SportRage
def change_unpack_dir(unpack_dir):
    """
    Change UNPACK directory (used by postprocessor)

    :param unpack_dir: New unpack directory
    :return: True on success, False on failure
    """
    if unpack_dir == '':
        sickbeard.UNPACK_DIR = ''
        return True

    if ek(os.path.normpath, sickbeard.UNPACK_DIR) != ek(os.path.normpath, unpack_dir):
        if bool(sickbeard.ROOT_DIRS) and \
                any(map(lambda rd: helpers.is_subdirectory(unpack_dir, rd), sickbeard.ROOT_DIRS.split('|')[1:])):
            # don't change if it's in any of the TV root directories
            logger.log("Unable to change unpack directory to a sub-directory of a TV root dir")
            return False

        if helpers.makeDir(unpack_dir):
            sickbeard.UNPACK_DIR = ek(os.path.normpath, unpack_dir)
            logger.log("Changed unpack directory to " + unpack_dir)
        else:
            logger.log("Unable to create unpack directory " + ek(os.path.normpath, unpack_dir) + ", dir not changed.")
            return False

    return True