Пример #1
0
def radio():
    if request.method == 'POST':
        f = request.files['file']
        f.save(os.path.join(app.config['CACHE_ROOT'], 'br.bin'))
        try:
            load_radio()
        except IOError:
            return render_mako('radio.html', error={'badupload':['resetcmd']} )
    return render_mako('radio.html', error={})
Пример #2
0
def login():
    error = None

    if request.method == 'POST':
        try:
            user = LoginUser()
            if bcrypt.check_password_hash(user.password, request.form['password']):
                doLogin(user)
                return redirect(url_for('index'))
            else:
                raise ValueError            
        except ValueError:
            return render_mako('login.html', name=mako, error=error)
    return render_mako('login.html', name=mako, error=error)
Пример #3
0
def login():
    error = None

    if request.method == 'POST':
        try:
            user = LoginUser()
            if bcrypt.check_password_hash(user.password, request.form['password']):
                doLogin(user)
                return redirect(url_for('index'))
            else:
                raise ValueError            
        except ValueError:
            return render_mako('login.html', name=mako, error=error)
    return render_mako('login.html', name=mako, error=error)
Пример #4
0
def radio():
    if request.method == 'POST':
        f = request.files['file']
        f.save(os.path.join(app.config['CACHE_ROOT'], 'br.bin'))
        # try:
        #     broadcastStatus("radio", json.dumps(dict(task = "uploadingFirmware")))
        #     load_radio()
        # except IOError:
        #     return render_mako('radio.html', error={'badupload':['resetcmd']} )
        radio = json.loads(db.get('conf/radio'))            
        return render_mako('radio.html', error = {}, radio = radio, forceReload="true")

    # GET
    radio = json.loads(db.get('conf/radio'))            
    return render_mako('radio.html', error={}, radio = radio, forceReload="false")
Пример #5
0
def brSetup():
    if request.method == 'GET':
        return render_mako('brSetup.html')

    elif request.method == 'POST':

        br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'])
        
        lowpan.createDefaultConf()
        lowpanConf = json.loads(db.get('conf/lowpan'))
        lowpanConf['eui'] = request.form['eui']
        lowpanConf['password'] = request.form['brkey']
        lowpanConf['url'] = BASE_URL + request.form['eui']

        db.store('conf/lowpan', json.dumps(lowpanConf))
        db.store('conf/br', json.dumps(br))

        # change root password
        os.system('echo "root:%s" | chpasswd' % (br['pin']))
        # also set login password to pin
        conf['password'] = bcrypt.generate_password_hash(br['pin'])
        db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4))
        # set the hostname
        os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui']))

        os.system('sleep 3 && systemctl restart bramble')

        return "Now you need to restart BRamble"
Пример #6
0
def settings():
    release = {}
    try:
        release = json.loads(db.get("conf/release"))
    except IOError:
        release = {"distro": "br12", "release": "testing", "url": "distro.lowpan.com/distro"}
        db.store("conf/release", json.dumps(release))
    return render_mako("settings.html", release=release)
Пример #7
0
def radio():
    if request.method == 'POST':
        f = request.files['file']
        f.save(os.path.join(app.config['CACHE_ROOT'], 'br.bin'))
        # try:
        #     broadcastStatus("radio", json.dumps(dict(task = "uploadingFirmware")))
        #     load_radio()
        # except IOError:
        #     return render_mako('radio.html', error={'badupload':['resetcmd']} )
        radio = json.loads(db.get('conf/radio'))
        return render_mako('radio.html',
                           error={},
                           radio=radio,
                           forceReload="true")

    # GET
    radio = json.loads(db.get('conf/radio'))
    return render_mako('radio.html',
                       error={},
                       radio=radio,
                       forceReload="false")
Пример #8
0
def settings():
    release = {}
    try:
        release = json.loads(db.get('conf/release'))
    except IOError:
        release = {
            "distro": "br12",
            "release": "testing",
            "url": "distro.lowpan.com/distro"
        }
        db.store('conf/release', json.dumps(release))
    return render_mako('settings.html', release=release)
Пример #9
0
def brSetup():
    if request.method == 'GET':
        return render_mako('brSetup.html', url=BASE_URL)

    elif request.method == 'POST':

        baseurl = BASE_URL
        br = {}
        if request.form['url'] != '':
            baseurl = request.form['url']
            if baseurl[-1] != '/':
                baseurl = baseurl + '/'
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'],
                                  baseurl)
        else:
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'])

        lowpan.createDefaultConf()
        lowpanConf = json.loads(db.get('conf/lowpan'))
        lowpanConf['eui'] = request.form['eui']
        lowpanConf['password'] = request.form['brkey']
        lowpanConf['url'] = baseurl + request.form['eui']

        db.store('conf/lowpan', json.dumps(lowpanConf))
        db.store('conf/lowpan.factory', json.dumps(lowpanConf))
        db.store('conf/br', json.dumps(br))
        db.store('conf/br.factory', json.dumps(br))

        lowpan.syncConfig()
        lowpan.updateGogoc()

        # set the radio's serial (which also sets the eui)
        try:
            radio.setSerial(br['m12serial'])
        except KeyError:
            print "Warning: no m12 serial number set"
    # change root password
        os.system('echo "root:%s" | chpasswd' % (br['pin']))
        # also set login password to pin
        conf['password'] = bcrypt.generate_password_hash(br['pin'])
        db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4))
        db.store('conf/bradmin.factory',
                 json.dumps(conf, sort_keys=True, indent=4))
        # set the hostname
        os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui']))

        return "Now you need to restart BRamble"
Пример #10
0
def brSetup():
    if request.method == 'GET':
        return render_mako('brSetup.html', url=BASE_URL)

    elif request.method == 'POST':

	baseurl = BASE_URL
        br = {}
	if request.form['url'] != '':
	    baseurl = request.form['url']
	    if baseurl[-1] != '/':
	        baseurl = baseurl + '/'
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'], baseurl)
        else: 
            br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'])

        lowpan.createDefaultConf()
        lowpanConf = json.loads(db.get('conf/lowpan'))
        lowpanConf['eui'] = request.form['eui']
        lowpanConf['password'] = request.form['brkey']
        lowpanConf['url'] = baseurl + request.form['eui']

        db.store('conf/lowpan', json.dumps(lowpanConf))
        db.store('conf/lowpan.factory', json.dumps(lowpanConf))
        db.store('conf/br', json.dumps(br))
        db.store('conf/br.factory', json.dumps(br))

        lowpan.syncConfig()
        lowpan.updateGogoc()

        # set the radio's serial (which also sets the eui)
        try:
            radio.setSerial(br['m12serial'])
        except KeyError:
            print "Warning: no m12 serial number set"
        # change root password
        os.system('echo "root:%s" | chpasswd' % (br['pin']))
        # also set login password to pin
        conf['password'] = bcrypt.generate_password_hash(br['pin'])
        db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4))
        db.store('conf/bradmin.factory', json.dumps(conf, sort_keys=True, indent=4))
        # set the hostname
        os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui']))

        return "Now you need to restart BRamble"
Пример #11
0
def mesh():
    return render_mako('mesh.html')
Пример #12
0
def mesh():
    return render_mako("mesh.html")
Пример #13
0
def index():
    if current_user.is_anonymous() is True:
        return redirect(url_for('login'))
    return render_mako('index.html', user=current_user)
Пример #14
0
def settings():
    return render_mako('settings.html')
Пример #15
0
def index():
    if current_user.is_anonymous() is True:
        return redirect(url_for('login'))
    return render_mako('mesh.html', user=current_user)
Пример #16
0
def clouds():
    return render_mako('clouds.html')