예제 #1
0
def buyer_file_by_order_id(order_id):
    try:
        session = get_session()
        return session.query(BuyerFileInfo).filter(
            BuyerFileInfo.order_id == order_id)[0]
    except:
        logger.exception("error: no order %s", order_id)
예제 #2
0
def publish_file_update(market_hash, selected_id):
    try:
        session = get_session()
        session.query(FileInfo).filter(FileInfo.id == selected_id). \
            update({FileInfo.market_hash: market_hash, FileInfo.is_published: True}, synchronize_session=False)
        session.commit()
    except:
        logger.exception("error publish_file_update")
예제 #3
0
def buyer_file_update(file_title):
    try:
        session = get_session()
        session.query(BuyerFileInfo).filter(BuyerFileInfo.file_title == file_title). \
            update({BuyerFileInfo.is_downloaded: True}, synchronize_session=False)
        session.commit()
    except:
        logger.exception("error publish_file_update")
예제 #4
0
def update_file_info_version(public_key):
    try:
        session = get_session()
        public_key_list = []
        for key in session.query(FileInfoVersion).all():
            public_key_list.append(key.public_key)
        if public_key not in public_key_list:
            new_user_version = FileInfoVersion(version=1,
                                               public_key=public_key)
            add_file(new_user_version)
        else:
            cur_version = session.query(FileInfoVersion).filter(
                FileInfoVersion.public_key == public_key)
            session.query(FileInfoVersion).filter(FileInfoVersion.public_key == public_key). \
                update({FileInfoVersion.version: cur_version+1}, synchronize_session=False)
            session.commit()
    except:
        logger.exception("update_file_info_version error")
예제 #5
0
def add_file(new_file_info):
    session = get_session()
    session.add(new_file_info)
    session.commit()
예제 #6
0
def get_buyer_file_names():
    return list(zip(*get_session().query(BuyerFileInfo.name).all()))[0]
예제 #7
0
def get_buyer_file_list():
    return get_session().query(BuyerFileInfo).all()
예제 #8
0
def get_file_id_new(file_id):
    return get_session().query(FileInfo).filter(
        FileInfo.id == file_id).all()[0]
예제 #9
0
def get_file_by_data_type(data_type=None):
    from cpchain.wallet.pages import wallet
    return get_session().query(FileInfo).filter(FileInfo.public_key == wallet.market_client.public_key)\
        .filter(FileInfo.data_type == data_type).order_by(FileInfo.id.desc()).all()
예제 #10
0
def delete_collect_id(file_id):
    session = get_session()
    session.query(CollectInfo).filter(CollectInfo.id == file_id). \
        delete(synchronize_session=False)
    session.commit()
    logger.debug("Collect record (id = %s) has been deleted !", file_id)
예제 #11
0
def get_collect_list():
    """This returns a list of files.
    """
    session = get_session()
    return session.query(CollectInfo).all()
예제 #12
0
def decrypt_file(file_in_path, file_out_path):
    session = get_session()
    aes_key = session.query(
        FileInfo.aes_key).filter(FileInfo.path == file_in_path).first()[0]
    decrypter = AESCipher(aes_key)
    decrypter.decrypt(file_in_path, file_out_path)
예제 #13
0
def delete_buyer_file(file_name):
    session = get_session()
    session.query(BuyerFileInfo).filter(BuyerFileInfo.file_title == file_name). \
        delete(synchronize_session=False)
    session.commit()
예제 #14
0
def delete_file_by_msh(market_hash):
    session = get_session()
    session.query(FileInfo).filter(FileInfo.market_hash == market_hash). \
        delete(synchronize_session=False)
    session.commit()
예제 #15
0
def get_buy_file_by_market_hash(market_hash):
    return get_session().query(BuyerFileInfo).filter(
        BuyerFileInfo.market_hash == market_hash).all()
예제 #16
0
def delete_file(file_name):
    session = get_session()
    session.query(FileInfo).filter(FileInfo.name == file_name).\
        delete(synchronize_session=False)
    session.commit()
예제 #17
0
def delete_file_by_id(file_id):
    session = get_session()
    session.query(FileInfo).filter(FileInfo.id == file_id). \
        delete(synchronize_session=False)
    session.commit()
예제 #18
0
def get_file_by_hash(file_hash):
    return get_session().query(FileInfo).filter(FileInfo.hashcode == file_hash)