def test_model_001_get_propertymodels_by_classtype_and_property(self):

        # get the model types defined in the global custom enums
        model_types = global_enums.get_enum(_MODEL_CLASSTYPES_TAG_)

        def_props = get_default_propertyvalues_by_classtype_and_property('CRYPTO_MINER','hashrate')
        self.assertGreater(len(def_props), 2)
Beispiel #2
0
def get_coin_index(coin):
    """
    Retrieves coin INDEX when passed a coin SYMBOL

    Returns:
        Integer

    """

    # this method assumes SYMBOL is passed in
    coins = global_enums.get_enum('_COINS_')

    try:
        # coin symbol keys are stored in UPPERCASE
        coin_index = coins[coin.upper()].value
    except KeyError:
        coin_index = -1
    except Exception as ex:
        logger.exception(ex)

    if coin_index == -1:
        coin_index = get_coin_index_by_name(coin)

        if coin_index == -1 and len(coins) <= 100:

            # By default when we load up initially, we just retrieve the top 100 coins
            # now we need to get ALL the coins since this coin is obviously not loaded
            # we will have to wait about 5 seconds to pull the data and parse

            global_enums.reload_api_enum("_COINS_", True)

            # now try again, with ALL the coins
            coin_index = get_coin_index_by_name(coin)

    return coin_index
Beispiel #3
0
    def __init__(self):

        super(PoweredObject, self).__init__()

        # this is a powered object
        self.is_powered = True

        # default to INFO
        self.log_level = logging.INFO

        # should we notify each time the POWER is ON/OFF/CYCLE
        self.notify_on_power_change = config_helpers.get_config_value(
            "MISC", "notify_on_power_change", True)

        # TODO - move these out of main class

        self.STATES = global_enums.get_enum('_STATE_TYPES_')
        self.STATES_REV = global_enums.get_reverse_map_enum('_STATE_TYPES_')

        self.CONST_STATE_OFF = self.STATES['OFF'].value
        self.CONST_STATE_ON = self.STATES['ON'].value
        self.CONST_STATE_CYCLE = self.STATES['CYCLE'].value
        self.CONST_STATE_UNKNOWN = self.STATES['UNKNOWN'].value
Beispiel #4
0
def get_algo_index(algo):
    """
    Retrieves algo INDEX when passed an algo

    Returns:
        Integer

    """

    # get the algos enum
    enum_algos = global_enums.get_enum('_ALGOS_')

    # clean the algo string
    algo_str_clean = algo.replace("-", "").lower()

    try:
        algo_idx = enum_algos[algo_str_clean].value
    except KeyError:
        logger.warning("There is no Algo '{}' defined. "
                       "Check the _ALGOS_ ENUM for the key {}.".format(
                           algo, algo_str_clean))
        algo_idx = -1

    return algo_idx
Beispiel #5
0
 def get_subclasstypes(self):
     # TODO - add filter
     return global_enums.get_enum('_MODEL_SUBCLASSTYPES_')