Example #1
0
def run(params=[""],
        autoload_discovery=True,
        use_torrent_search=True,
        use_channel_search=True):

    from .hacks import patch_crypto_be_discovery
    patch_crypto_be_discovery()

    if len(sys.argv) > 1:
        if sys.platform.startswith("win"):
            from .hacks import get_unicode_sys_argv
            params = get_unicode_sys_argv()[1:]
        else:
            params = sys.argv[1:]
    try:
        # Create single instance semaphore
        single_instance_checker = SingleInstanceChecker("tribler")

        installdir = determine_install_dir()

        if not ALLOW_MULTIPLE and single_instance_checker.IsAnotherRunning():
            statedir = SessionStartupConfig().get_state_dir()

            # Send  torrent info to abc single instance
            if params[0] != "":
                torrentfilename = params[0]
                i2i_port = Utility(installdir,
                                   statedir).read_config('i2ilistenport')
                Instance2InstanceClient(i2i_port, 'START', torrentfilename)

            logger.info("Client shutting down. Detected another instance.")
        else:
            # Launch first abc single instance
            app = wx.GetApp()
            if not app:
                app = TriblerApp(redirect=False)

            abc = ABCApp(params,
                         installdir,
                         autoload_discovery=autoload_discovery,
                         use_torrent_search=use_torrent_search,
                         use_channel_search=use_channel_search)
            app.set_abcapp(abc)
            if abc.frame:
                app.SetTopWindow(abc.frame)
                abc.frame.set_wxapp(app)
                app.MainLoop()

            # since ABCApp is not a wx.App anymore, we need to call OnExit explicitly.
            abc.OnExit()

            # Niels: No code should be present here, only executed after gui closes

        logger.info(
            "Client shutting down. Sleeping for a few seconds to allow other threads to finish"
        )
        sleep(5)

    except:
        print_exc()
Example #2
0
 def get_install_dir(self):
     """ Returns the directory the Tribler Core software is installed in.
     @return An absolute path name. """
     install_dir = self.sessconfig.get(u'general', u'install_dir')
     if install_dir == '.':
         install_dir = determine_install_dir()
         self.set_install_dir(install_dir)
     return install_dir
Example #3
0
 def get_install_dir(self):
     """ Returns the directory the Tribler Core software is installed in.
     @return An absolute path name. """
     install_dir = self.sessconfig.get(u'general', u'install_dir')
     if install_dir == '.':
         install_dir = determine_install_dir()
         self.set_install_dir(install_dir)
     return install_dir
Example #4
0
def run(params=[""],
        autoload_discovery=True,
        use_torrent_search=True,
        use_channel_search=True):

    from .hacks import patch_crypto_be_discovery
    patch_crypto_be_discovery()

    if len(sys.argv) > 1:
        if sys.platform.startswith("win"):
            from .hacks import get_unicode_sys_argv
            params = get_unicode_sys_argv()[1:]
        else:
            params = sys.argv[1:]
    try:
        # Create single instance semaphore
        process_checker = ProcessChecker()

        installdir = determine_install_dir()

        if not ALLOW_MULTIPLE and process_checker.already_running:
            logger.info("Client shutting down. Detected another instance.")
        else:
            # Launch first abc single instance
            app = wx.GetApp()
            if not app:
                app = TriblerApp(redirect=False)

            abc = ABCApp(params,
                         installdir,
                         autoload_discovery=autoload_discovery,
                         use_torrent_search=use_torrent_search,
                         use_channel_search=use_channel_search)
            app.set_abcapp(abc)
            if abc.frame:
                app.SetTopWindow(abc.frame)
                abc.frame.set_wxapp(app)
                app.MainLoop()

            # since ABCApp is not a wx.App anymore, we need to call OnExit explicitly.
            abc.OnExit()

            # Niels: No code should be present here, only executed after gui closes

        process_checker.remove_lock_file()

        logger.info(
            "Client shutting down. Sleeping for a few seconds to allow other threads to finish"
        )
        sleep(5)

    except:
        print_exc()
Example #5
0
def run(params=[""], autoload_discovery=True, use_torrent_search=True, use_channel_search=True):

    from .hacks import patch_crypto_be_discovery
    patch_crypto_be_discovery()

    if len(sys.argv) > 1:
        if sys.platform.startswith("win"):
            from .hacks import get_unicode_sys_argv
            params = get_unicode_sys_argv()[1:]
        else:
            params = sys.argv[1:]
    try:
        # Create single instance semaphore
        single_instance_checker = SingleInstanceChecker("tribler")

        installdir = determine_install_dir()

        if not ALLOW_MULTIPLE and single_instance_checker.IsAnotherRunning():
            statedir = SessionStartupConfig().get_state_dir()

            # Send  torrent info to abc single instance
            if params[0] != "":
                torrentfilename = params[0]
                i2i_port = Utility(installdir, statedir).read_config('i2ilistenport')
                Instance2InstanceClient(i2i_port, 'START', torrentfilename)

            logger.info("Client shutting down. Detected another instance.")
        else:
            # Launch first abc single instance
            app = wx.GetApp()
            if not app:
                app = TriblerApp(redirect=False)

            abc = ABCApp(params, installdir, autoload_discovery=autoload_discovery,
                         use_torrent_search=use_torrent_search, use_channel_search=use_channel_search)
            app.set_abcapp(abc)
            if abc.frame:
                app.SetTopWindow(abc.frame)
                abc.frame.set_wxapp(app)
                app.MainLoop()

            # since ABCApp is not a wx.App anymore, we need to call OnExit explicitly.
            abc.OnExit()

            # Niels: No code should be present here, only executed after gui closes

        logger.info("Client shutting down. Sleeping for a few seconds to allow other threads to finish")
        sleep(5)

    except:
        print_exc()
Example #6
0
 def test_install_dir(self):
     install_dir = determine_install_dir()
     self.assertIsInstance(install_dir, six.string_types)
     self.assertTrue(os.path.isdir(install_dir))
     self.assertTrue(os.path.exists(os.path.join(install_dir, 'Tribler')))
Example #7
0
 def test_install_dir(self):
     install_dir = determine_install_dir()
     self.assertIsInstance(install_dir, (unicode, str))
     self.assertTrue(os.path.isdir(install_dir))
     self.assertTrue(os.path.exists(os.path.join(install_dir, 'Tribler')))
Example #8
0
#!/usr/bin/env python
import logging.config
import sys
import os

from Tribler.Core.Utilities.install_dir import determine_install_dir
# This should work for Linux, Windows and OSX
TRIBLER_ROOT = determine_install_dir()
LOGGER_CONF = os.path.join(TRIBLER_ROOT, "logger.conf")

# Add TRIBLER_ROOT to the PYTHONPATH so imports work fine wherever Tribler is
# running from.
if TRIBLER_ROOT not in sys.path:
    sys.path.insert(0, TRIBLER_ROOT)

# tribler_exe.py: does this for windows in an uglier way.
if sys.platform != 'win32':
    # Make sure the installation dir is on the PATH
    os.environ['PATH'] = os.path.abspath(
        TRIBLER_ROOT) + os.pathsep + os.environ['PATH']

try:
    logging.config.fileConfig(LOGGER_CONF)
except Exception as e:
    print >> sys.stderr, u"Unable to load logging config from '%s' file: %s" % (
        repr(LOGGER_CONF), repr(e))
    print >> sys.stderr, u"Current working directory: %s" % repr(
        os.path.abspath(u'.'))
    if not os.path.exists(LOGGER_CONF):
        print >> sys.stderr, "File doesn't exist"
    elif not os.path.isfile(LOGGER_CONF):
Example #9
0
 def test_install_dir(self):
     install_dir = determine_install_dir()
     self.assertIsInstance(install_dir, (unicode, str))
     self.assertTrue(os.path.isdir(install_dir))
     self.assertTrue(os.path.exists(os.path.join(install_dir, 'Tribler')))
Example #10
0
#!/usr/bin/env python
import logging.config
import sys
import os


from Tribler.Core.Utilities.install_dir import determine_install_dir
# This should work for Linux, Windows and OSX
TRIBLER_ROOT = determine_install_dir()
LOGGER_CONF = os.path.join(TRIBLER_ROOT, "logger.conf")

# Add TRIBLER_ROOT to the PYTHONPATH so imports work fine wherever Tribler is
# running from.
if TRIBLER_ROOT not in sys.path:
    sys.path.insert(0, TRIBLER_ROOT)

# tribler_exe.py: does this for windows in an uglier way.
if sys.platform != 'win32':
    # Make sure the installation dir is on the PATH
    os.environ['PATH'] = os.path.abspath(TRIBLER_ROOT) + os.pathsep + os.environ['PATH']

try:
    logging.config.fileConfig(LOGGER_CONF)
except Exception as e:
    print >> sys.stderr, u"Unable to load logging config from '%s' file: %s" % (repr(LOGGER_CONF), repr(e))
    print >> sys.stderr, u"Current working directory: %s" % repr(os.path.abspath(u'.'))
    if not os.path.exists(LOGGER_CONF):
        print >> sys.stderr, "File doesn't exist"
    elif not os.path.isfile(LOGGER_CONF):
        print >> sys.stderr, "It is not a file"
    else: