Exemplo n.º 1
0
def check():
    """
    The method is the main function which should run periodically. It controls the behaviour of the agent,
    starting Tribler and buying servers.
    """
    global config, dna
    logger.log("Checking PlebNet", log_name)

    # Read general configuration
    if settings.wallets_testnet_created():
        os.environ['TESTNET'] = '1'
    config = PlebNetConfig()
    dna = DNA()
    dna.read_dictionary()

    # check if own vpn is installed before continuing
    if not check_vpn_install():
        logger.error("!!! VPN is not installed, child may get banned !!!",
                     "Plebnet Check")

    # Requires time to setup, continue in the next iteration.
    if not check_tribler():
        return

    if not settings.wallets_initiate_once():
        create_wallet()
    select_provider()

    # These need a matchmaker, otherwise agent will be stuck waiting.
    if market_controller.has_matchmakers():
        update_offer()
        attempt_purchase()
    install_vps()
Exemplo n.º 2
0
def check():
    """
    The method is the main function which should run periodically. It controls the behaviour of the agent,
    starting Tribler and buying servers.
    """
    global config, qtable
    global sold_mb_tokens, previous_mb_tokens
    logger.log("Checking PlebNet", log_name)

    # Read general configuration
    if settings.wallets_testnet_created():
        os.environ['TESTNET'] = '1'
    config = PlebNetConfig()
    qtable = QTable()
    qtable.read_dictionary()
    # check if own vpn is installed before continuing
    if not check_vpn_install():
        logger.error("!!! VPN is not installed, child may get banned !!!",
                     "Plebnet Check")

    # Requires time to setup, continue in the next iteration.
    if not check_tribler():
        return

    check_irc()

    if not settings.wallets_initiate_once():
        create_wallet()

    select_provider()

    # if is going to die, move all currency to a wallet
    if config.time_to_expiration() < plebnet_settings.TIME_IN_HOUR:
        save_all_currency()

    # These need a matchmaker, otherwise agent will be stuck waiting.
    if market_controller.has_matchmakers():
        strategies[plebnet_settings.get_instance().strategy_name()]().apply()

    install_vps()
 def test_has_matchmakers(self):
     responses.add(responses.GET, 'http://localhost:8085/market/matchmakers',
                   json={'matchmakers': ['test1', 'test2', 'test3']})
     assert Market.has_matchmakers()