Ejemplo n.º 1
0
def add_miner():
    miner_ip = request.form['ip']
    miner_model_id = request.form.get('model_id')
    miner_remarks = request.form['remarks']
    container_id = request.form['container_id']

    # 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,
                      container_id=container_id,
                      remarks=miner_remarks)
        db.session.add(miner)
        db.session.commit()
        flash("Miner with IP Address {} added successfully".format(miner.ip),
              "success")
    except IntegrityError as e:
        db.session.rollback()
        flash("IP Address {} already added".format(miner_ip), "error")

    try:
        miner.check_stats()
    except TypeError:
        pass
    return redirect(url_for('miners'))
Ejemplo n.º 2
0
def add_miner():
    miner_ip = request.form['ip']

    model = None
    try:
        model = detect_model(miner_ip)
    except Exception as e:
        logger.error("Error while detecting miner. message: {}".format(
            e.message))
        flash(message=e.message, category="error")

    if not model is None:
        try:
            miner_remarks = request.form['remarks']
            miner = Miner(ip=miner_ip,
                          model_id=model.id,
                          remarks=miner_remarks,
                          count=1)
            db.session.add(miner)
            db.session.commit()
            flash(
                "Miner with IP Address {} added successfully".format(miner.ip),
                "info")
        except IntegrityError as e:
            db.session.rollback()
            logger.error("Error while adding miner. Message: {}".format(
                e.message))
            flash("IP Address {} already added".format(miner_ip), "error")

    return redirect(url_for('miners'))
Ejemplo n.º 3
0
def add_miner():

    miner_ip = request.form['ip']
    miner_model_id = request.form.get('model_id')
    miner_remarks = request.form['remarks']

    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 as e:
        db.session.rollback()
        flash("IP Address {} already added".format(miner_ip), "error")

    return redirect(url_for('miners'))
Ejemplo n.º 4
0
from app.models import Miner, MinerModel, Settings
from app import db

print("[INFO] Starting DB update...")
# backup Miner data
miners = []
backup = Miner.query.all()

print("[INFO] Backing up miners...")
for miner in backup:
    miners.append(
        Miner(ip=str(miner.ip),
              model_id=int(miner.model.id),
              remarks=str(miner.remarks)))

# drop all tables
print("[INFO] Dropping tables...")
db.drop_all()
# create all tables
print("[INFO] Recreating all tables...")
db.create_all()

# add supported MinerModels
models = []
models.append(
    MinerModel(model='L3+',
               chips='72,72,72,72',
               temp_keys='temp2_',
               description='Litecoin Miner 504 MH/s'))
models.append(
    MinerModel(model='S7',