diff --git a/Tribler/Main/tribler_main.py b/Tribler/Main/tribler_main.py index 2bd5432c488..0e0e7e23aa4 100644 --- a/Tribler/Main/tribler_main.py +++ b/Tribler/Main/tribler_main.py @@ -127,6 +127,10 @@ DEBUG_DOWNLOADS = False ALLOW_MULTIPLE = os.environ.get("TRIBLER_ALLOW_MULTIPLE", "False").lower() == "true" +SKIP_TUNNEL_DIALOG = os.environ.get("TRIBLER_SKIP_OPTIN_DLG", "False") == "True" +# used by the anon tunnel tests as there's no way to mess with the Session before running the test ATM. +FORCE_ENABLE_TUNNEL_COMMUNITY = False + # # # Class : ABCApp @@ -138,13 +142,12 @@ class ABCApp(object): - def __init__(self, params, installdir, is_unit_testing=False, autoload_discovery=True): + def __init__(self, params, installdir, autoload_discovery=True): assert not isInIOThread(), "isInIOThread() seems to not be working correctly" self._logger = logging.getLogger(self.__class__.__name__) self.params = params self.installdir = installdir - self.is_unit_testing = is_unit_testing self.state_dir = None self.error = None @@ -402,11 +405,10 @@ def InitStage1(self, installdir, autoload_discovery=True): if not self.sconfig.get_torrent_collecting_dir(): self.sconfig.set_torrent_collecting_dir(os.path.join(defaultDLConfig.get_dest_dir(), STATEDIR_TORRENTCOLL_DIR)) - - #TODO(emilon): Quick hack to get 6.4.1 out the door, (re tunnel_community tests disabling is_unit_testing flag) - if os.environ.get("TRIBLER_SKIP_OPTIN_DLG", "False") == "True": + if FORCE_ENABLE_TUNNEL_COMMUNITY: self.sconfig.set_tunnel_community_enabled(True) - elif not self.sconfig.get_tunnel_community_optin_dialog_shown() and not self.is_unit_testing: + + if not self.sconfig.get_tunnel_community_optin_dialog_shown() and not SKIP_TUNNEL_DIALOG: optin_dialog = wx.MessageDialog(None, 'If you are not familiar with proxy technology, please opt-out.\n\n' 'This experimental anonymity feature using Tor-inspired onion routing ' @@ -518,7 +520,7 @@ def define_communities(*args): dispersy.define_auto_load(ChannelCommunity, session.dispersy_member, load=True, kargs=default_kwargs) dispersy.define_auto_load(PreviewChannelCommunity, session.dispersy_member, kargs=default_kwargs) - if self.sconfig.get_tunnel_community_enabled() and not self.is_unit_testing: + if self.sconfig.get_tunnel_community_enabled(): keypair = dispersy.crypto.generate_key(u"NID_secp160k1") dispersy_member = dispersy.get_member(private_key=dispersy.crypto.key_to_bin(keypair),) settings = TunnelSettings(session.get_install_dir()) @@ -1096,7 +1098,7 @@ def start_asked_download(): # # @attach_profiler -def run(params=None, is_unit_testing=False, autoload_discovery=True): +def run(params=None, autoload_discovery=True): if params is None: params = [""] @@ -1134,7 +1136,7 @@ def run(params=None, is_unit_testing=False, autoload_discovery=True): app = wx.GetApp() if not app: app = wx.PySimpleApp(redirect=False) - abc = ABCApp(params, installdir, is_unit_testing, autoload_discovery=autoload_discovery) + abc = ABCApp(params, installdir, autoload_discovery=autoload_discovery) if abc.frame: app.SetTopWindow(abc.frame) abc.frame.set_wxapp(app) diff --git a/Tribler/Test/test_as_server.py b/Tribler/Test/test_as_server.py index 3dacc8f749d..57d55c42523 100644 --- a/Tribler/Test/test_as_server.py +++ b/Tribler/Test/test_as_server.py @@ -141,6 +141,8 @@ def setUp(self): def setUpPreSession(self): """ Should set self.config_path and self.config """ self.config = SessionStartupConfig() + self.config.set_tunnel_community_enabled(False) + self.config.set_tunnel_community_optin_dialog_shown(True) self.config.set_state_dir(self.getStateDir()) self.config.set_torrent_checking(False) self.config.set_multicast_local_peer_discovery(False) @@ -263,10 +265,11 @@ def assert_(self, boolean, reason, do_assert=True): if do_assert: assert boolean, reason - def startTest(self, callback, min_timeout=5, force_is_unit_testing=True, autoload_discovery=True): + def startTest(self, callback, min_timeout=5, autoload_discovery=True): from Tribler.Main.vwxGUI.GuiUtility import GUIUtility from Tribler.Main import tribler_main tribler_main.ALLOW_MULTIPLE = True + tribler_main.SKIP_TUNNEL_DIALOG = True self.hadSession = False starttime = time.time() @@ -305,7 +308,7 @@ def wait_for_instance(): # modify argv to let tribler think its running from a different directory sys.argv = [os.path.abspath('./.exe')] - tribler_main.run(is_unit_testing=force_is_unit_testing, autoload_discovery=autoload_discovery) + tribler_main.run(autoload_discovery=autoload_discovery) assert self.hadSession, 'Did not even create a session' diff --git a/Tribler/Test/test_tunnel_community.py b/Tribler/Test/test_tunnel_community.py index cdd45ee2ab7..d2a61f5deaa 100644 --- a/Tribler/Test/test_tunnel_community.py +++ b/Tribler/Test/test_tunnel_community.py @@ -16,9 +16,6 @@ from Tribler.dispersy.util import blockingCallFromThread -#TODO(emilon): Quick hack to get 6.4.1 out the door, (re tunnel_community tests disabling is_unit_testing flag) -environ["TRIBLER_SKIP_OPTIN_DLG"] = "True" - class TestTunnelCommunity(TestGuiAsServer): def test_anon_download(self): @@ -204,6 +201,9 @@ def cb_dht(info_hash, peers, source): self.startTest(setup_seeder) def startTest(self, callback, min_timeout=5): + from Tribler.Main import tribler_main + tribler_main.FORCE_ENABLE_TUNNEL_COMMUNITY = True + self.getStateDir() # getStateDir copies the bootstrap file into the statedir def setup_proxies(): @@ -261,7 +261,7 @@ def load_community(session): return blockingCallFromThread(reactor, load_community, session) - TestGuiAsServer.startTest(self, setup_proxies, force_is_unit_testing=False, autoload_discovery=False) + TestGuiAsServer.startTest(self, setup_proxies, autoload_discovery=False) def setupSeeder(self): from Tribler.Core.Session import Session diff --git a/Tribler/community/channel/community.py b/Tribler/community/channel/community.py index e9e6f5f3de2..4c93f2f90d8 100644 --- a/Tribler/community/channel/community.py +++ b/Tribler/community/channel/community.py @@ -353,7 +353,6 @@ def _disp_on_torrent(self, messages): torrentlist.append((self._channel_id, dispersy_id, peer_id, message.payload.infohash, message.payload.timestamp, message.payload.name, message.payload.files, message.payload.trackers)) - # TODO: schedule a request for roothashes self._channelcast_db.on_torrents_from_dispersy(torrentlist) else: for message in messages: