Example #1
0
def add_miner(miner_ip, miner_model_id, miner_remarks):
    try:
        miner = Miner(
            ip=miner_ip, model_id=miner_model_id, remarks=miner_remarks)
        db_session.add(miner)
        db_session.commit()
        current_app.logger.info("Miner with IP Address {} added successfully".format(miner.ip))
        flash("Miner with IP Address {} added successfully".format(miner.ip),
              "success")
    except IntegrityError:
        db_session.rollback()
        current_app.logger.info("IP Address {} already added".format(miner.ip))
        flash("IP Address {} already added".format(miner.ip), "error")
Example #2
0
def add_miner():
    miner_ip = request.form['ip']
    miner_model_id = request.form.get('model_id')
    miner_remarks = request.form['remarks']

    # exists = Miner.query.filter_by(ip="").first()
    # if exists:
    #    return "IP Address already added"

    try:
        miner = Miner(ip=miner_ip,
                      model_id=miner_model_id,
                      remarks=miner_remarks)
        db.session.add(miner)
        db.session.commit()
        flash("Miner with IP Address {} added successfully".format(miner.ip),
              "success")
    except IntegrityError:
        db.session.rollback()
        flash("IP Address {} already added".format(miner_ip), "error")

    return redirect(url_for('antminer.miners'))