Exemplo n.º 1
0
def set_up_data_files():
    import openexchangelib.types as oel_types
    from openexchangelib import util

    asic_miner = oel_types.Asset(total_shares=400000,
                                 limit_buy_address='asm_limit_buy',
                                 limit_sell_address='asm_limit_sell',
                                 market_buy_address='asm_market_buy',
                                 market_sell_address='asm_market_sell',
                                 clear_order_address='asm_clear_order',
                                 transfer_address='asm_transfer',
                                 pay_address='asm_pay',
                                 create_vote_address='asm_create_vote',
                                 vote_address='asm_user_vote',
                                 state_control_address='asm_state_control',
                                 issuer_address='asm_issuer',
                                 users={
                                     'captain_miao':
                                     oel_types.User(initial_asset=400000),
                                 })
    #make sure that asset folder is empty
    current_ids = [
        int(f) for f in os.listdir(ASSET_DIR)
        if os.path.isfile(os.path.join(ASSET_DIR, f)) and f.isdigit()
    ]
    if current_ids:
        raise AssetFolderNotEmptyError(
            'please back up your data before running this test')
    full_name = os.path.join(ASSET_DIR, str(ASICMINER_CREATION_FILE_ID))
    util.save_obj(['ASICMINER', asic_miner], full_name)
Exemplo n.º 2
0
def set_up_static_data():
    from openexchangelib import util
    from server.models import StaticData
    static_file_name = os.path.join(DATA_DIR, 'static_data')

    if os.path.isfile(static_file_name):
        raise StaticDataAlreadyExistsError()
    else:
        util.save_obj(StaticData(), static_file_name)
Exemplo n.º 3
0
def save_data(obj, file_name, base):
    """
    :type file_name: str
    :type base: str
    """
    assert isinstance(file_name, str)
    assert isinstance(base, str)

    full_name = os.path.join(base, file_name)
    return util.save_obj(obj, full_name)
Exemplo n.º 4
0
def set_up_data():
    asic_miner = Asset(
        total_shares=400000,
        limit_buy_address='asm_limit_buy',
        limit_sell_address='asm_limit_sell',
        market_buy_address='asm_market_buy',
        market_sell_address='asm_market_sell',
        clear_order_address='asm_clear_order',
        transfer_address='asm_transfer',
        pay_address='asm_pay',
        create_vote_address='asm_create_vote',
        vote_address='asm_user_vote',
        state_control_address='asm_state_control',
        issuer_address='asm_issuer',
        users={
            'captain_miao': User(initial_asset=400000)
        }
    )
    util.save_obj(['ASICMINER', asic_miner], os.path.join(ASSETS_DIR, '../data/assets/1'))
    util.write_log(logger, 'ASICMINER data saved')
Exemplo n.º 5
0
def save_data(obj, file_name, base):
    assert isinstance(file_name, str)
    file_name = os.path.join(base, file_name)
    return util.save_obj(obj, file_name)