Exemplo n.º 1
0
    def run(self):
        self.current_status = u"Checking Tribler version..."
        failed, has_to_upgrade = self.check_should_upgrade()
        if has_to_upgrade and not failed:
            self.notify_starting()
            self.upgrade_database_to_current_version()

            # Convert old (pre 6.3 Tribler) pickle files to the newer .state format
            pickle_converter = PickleConverter(self.session)
            pickle_converter.convert()

        if self.failed:
            self.notify_starting()
            self.stash_database()
Exemplo n.º 2
0
    def test_convert_session_config(self):
        old_pickle_dict = {
            "state_dir": "/",
            "mainline_dht_port": 1337,
            "torrent_checking": "false",
            "torrent_collecting": "true",
            "libtorrent": False,
            "dispersy_port": 1337,
            "minport": 1234
        }
        self.write_pickle_file(old_pickle_dict, "sessconfig.pickle")

        PickleConverter(self.mock_session).convert_session_config()

        self.assertTrue(
            os.path.exists(
                os.path.join(self.session_base_dir, TRIBLER_CONFIG_FILENAME)))
        self.assertFalse(
            os.path.exists(
                os.path.join(self.session_base_dir, "sessconfig.pickle")))

        # Check the content of the config file
        config = TriblerConfig.load(config_path=os.path.join(
            self.session_base_dir, TRIBLER_CONFIG_FILENAME))
        self.assertEqual(config.get_state_dir(), '/')
        self.assertEqual(config.get_mainline_dht_port(), 1337)
        self.assertEqual(config.get_torrent_checking_enabled(), False)
        self.assertEqual(config.get_torrent_collecting_enabled(), True)
        self.assertFalse(config.get_libtorrent_enabled())
        self.assertEqual(config.get_dispersy_port(), 1337)
        self.assertEqual(config.get_libtorrent_port(), 1234)
Exemplo n.º 3
0
    def test_convert_default_download_config(self):
        old_pickle_dict = {"saveas": "dunno", "max_upload_rate": 33, "unrelatedkey": "test"}
        self.write_pickle_file(old_pickle_dict, "dlconfig.pickle")

        PickleConverter(self.mock_session).convert_default_download_config()

        self.assertTrue(os.path.exists(get_default_dscfg_filename(self.session_base_dir)))
Exemplo n.º 4
0
    def test_convert_session_config(self):
        old_pickle_dict = {"state_dir": "/", "mainline_dht_port": 1337, "torrent_checking": "maybe",
                           "torrent_collecting": "maybe", "libtorrent": 1337, "dispersy_port": 1337}
        self.write_pickle_file(old_pickle_dict, "sessconfig.pickle")

        PickleConverter(self.mock_session).convert_session_config()

        self.assertTrue(os.path.exists(SessionConfigInterface.get_default_config_filename(self.session_base_dir)))
        self.assertFalse(os.path.exists(os.path.join(self.session_base_dir, "sessconfig.pickle")))
Exemplo n.º 5
0
    def test_convert_download_checkpoints(self):
        with open(os.path.join(self.session_base_dir, 'corrupt.pickle'), 'wb') as corrupt_file:
            corrupt_file.write("This is not a pickle file!")

        old_pickle_dict = {"dlconfig": {"saveas": "dunno", "abc": "def"}, "engineresumedata": "test",
                           "dlstate": "test", "metainfo": "none"}
        self.write_pickle_file(old_pickle_dict, "download.pickle")

        PickleConverter(self.mock_session).convert_download_checkpoints()

        self.assertTrue(os.path.exists(os.path.join(self.session_base_dir, 'download.state')))
        self.assertFalse(os.path.exists(os.path.join(self.session_base_dir, 'corrupt.pickle')))
Exemplo n.º 6
0
    def test_convert_main_config(self):
        pickle_dict = {"download_state": {"abc": "stop"}}
        self.write_pickle_file(pickle_dict, "user_download_choice.pickle")

        PickleConverter(self.mock_session).convert_main_config()

        self.assertFalse(
            os.path.exists(
                os.path.join(self.session_base_dir,
                             "user_download_choice.pickle")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.session_base_dir, TRIBLER_CONFIG_FILENAME)))
Exemplo n.º 7
0
    def run(self):
        """
        Run the upgrader if it is enabled in the config.

        Note that by default, upgrading is enabled in the config. It is then disabled
        after upgrading to Tribler 7.
        """
        self.current_status = u"Checking Tribler version..."
        failed, has_to_upgrade = self.check_should_upgrade_database()
        if has_to_upgrade and not failed:
            self.notify_starting()
            self.upgrade_database_to_current_version()

            # Convert old (pre 6.3 Tribler) pickle files to the newer .state format
            pickle_converter = PickleConverter(self.session)
            pickle_converter.convert()

        if self.failed:
            self.notify_starting()
            self.stash_database()

        self.upgrade_to_tribler7()
Exemplo n.º 8
0
    def run(self):
        """
        Run the upgrader if it is enabled in the config.

        Note that by default, upgrading is enabled in the config. It is then disabled
        after upgrading to Tribler 7.
        """
        self.current_status = u"Checking Tribler version..."
        failed, has_to_upgrade = self.check_should_upgrade_database()
        if has_to_upgrade and not failed:
            self.notify_starting()
            self.upgrade_database_to_current_version()

            # Convert old (pre 6.3 Tribler) pickle files to the newer .state format
            pickle_converter = PickleConverter(self.session)
            pickle_converter.convert()

        if self.failed:
            self.notify_starting()
            self.stash_database()

        self.upgrade_to_tribler7()
Exemplo n.º 9
0
    def test_convert_main_config(self):
        pickle_dict = {"download_state": {"abc": "stop"}}
        self.write_pickle_file(pickle_dict, "user_download_choice.pickle")

        conf_filepath = os.path.join(self.session_base_dir, 'abc.conf')
        with open(conf_filepath, 'wb') as conf_file:
            conf_file.write("[ABC]")

        gui_filepath = os.path.join(self.session_base_dir, 'gui_settings')
        with open(gui_filepath, 'wb') as gui_settings_file:
            gui_settings_file.write("a=b\nc=d")

        history_filepath = os.path.join(self.session_base_dir, 'recent_download_history')
        with open(history_filepath, 'wb') as history_file:
            history_file.write("a=b\nc=d\ne=\n")

        PickleConverter(self.mock_session).convert_main_config()

        self.assertFalse(os.path.exists(os.path.join(self.session_base_dir, "user_download_choice.pickle")))
        self.assertFalse(os.path.exists(conf_filepath))
        self.assertFalse(os.path.exists(gui_filepath))
        self.assertFalse(os.path.exists(history_filepath))
        self.assertTrue(os.path.exists(os.path.join(self.session_base_dir, "tribler.conf")))