Esempio n. 1
0
def get_default_bsp_repo_path():
    if get_switch_model() == constants.bf2556x_1t:
        return get_abs_path('/bsp/bf-reference-bsp-9.2.0-BF2556')
    elif get_switch_model() == constants.bf6064x_t:
        return get_abs_path('/bsp/bf-reference-bsp-9.2.0-BF6064')
    else:
        print('Development BSp can\'t be retrieved for switch model'.format(
            get_switch_model()))
Esempio n. 2
0
def get_bsp_repo_abs_path():
    path_from_adv_setting = get_from_advance_setting_dict(
        constants.BSP_node, constants.bsp_repo_node_name)
    if path_from_adv_setting is None:
        return get_default_bsp_repo_path()
    else:
        return get_abs_path(path_from_adv_setting)
Esempio n. 3
0
def get_stratum_config_dir_absolute():
    stratum_config_dir = get_stratum_profile_details_dict().get(
        'stratum_config')
    if stratum_config_dir is None:
        return common.dname + '/stratum_config/'
    else:
        return get_abs_path(
            get_stratum_profile_details_dict().get('stratum_config'))
Esempio n. 4
0
def build_sde():
    #install_sde_deps()
    sde_tar = tarfile.open(get_sde_pkg_abs_path())
    sde_home_absolute = get_sde_home_absolute()
    sde_build_flags = get_sde_build_flags()

    # Deletion is required otherwise moving the directories
    # in further steps might create issues.
    # And delete only when user have opted for not to resume build
    # if sde_build_flags is not None and '-rb' not in sde_build_flags \
    #         and '-bm' not in sde_build_flags:
    try:
        print(
            "Deleting previous installation at {}.".format(sde_home_absolute))
        os.system('sudo rm -rf {}'.format(sde_home_absolute))
    except FileNotFoundError:
        print('{} already deleted.'.format(sde_home_absolute))

    # Extract tar here i.e. in APS one touch directory
    sde_tar.extractall()
    # In case SDE home is configured in yaml other than this directory,
    # If both paths are same following line doesn't cause any problem.
    if not os.path.exists(sde_home_absolute):
        shutil.move(get_sde_dir_name_in_tar(), sde_home_absolute)
    sde_tar.close()
    os.chdir(sde_home_absolute)
    p4studio_build_profile = get_abs_path(get_p4_studio_build_profile_name())

    sde_install_cmd = "{0}/p4studio/p4studio profile apply {1}".format(
        sde_home_absolute, p4studio_build_profile)

    os.environ[
        constants.
        path_env_var_name] += os.pathsep + sde_home_absolute + '/install/bin/'
    print('Building sde with command {}'.format(sde_install_cmd))
    os.system(sde_install_cmd)
    return True
Esempio n. 5
0
#!/usr/bin/python3

from flask import Flask, request, redirect, abort, jsonify, render_template
from datetime import timedelta
import json
import os

import storage
from storage import Mode
import common
from hardware import Client, Sensor
import validator

app = Flask(__name__, template_folder=common.get_abs_path('templates'))

LOCAL_ENV = os.getenv('ENVIRONMENT', '') == 'local'
SECRET = common.read_line_from('secret.txt')

if LOCAL_ENV: print('Running in local/test mode...')


@app.route('/', methods=['GET'])
def home():
    return redirect('/get', code=302)


@app.route('/update', methods=['POST'])
def update():
    if 'secret' not in request.json or request.json['secret'] != SECRET:
        return abort(403)
Esempio n. 6
0
# TODO: update this to new sensor class style

import sys, time

from common import get_abs_path
from hardware import Sensor

sys.path.insert(1, get_abs_path('rasp_b/libs'))
# I'd like to thank Frank Heuer and Teus Hagen for creating and updating this
# library - it's been a huge help in making the SDS011 work correctly on short
# notice. The webpage for their project is as follows:
#    https://gitlab.com/frankrich/sds011_particle_sensor
from sds011 import SDS011

DEVICE_FILE = '/dev/ttyUSB0'  # let's hope it stays there
BAUD_RATE = 9600

# Sensor is sometimes slow, hence the generous read timeout:
READ_TIMEOUT = 20  # in secs

# As in, how long are we gonna wait before collecting the sensors' readings:
WARMUP_PERIOD = 120  # in secs


def get():
    print('Initiating connection with SDS011...')
    sensor = SDS011(
        DEVICE_FILE,
        timeout=READ_TIMEOUT,
        unit_of_measure=SDS011.UnitsOfMeasure.MassConcentrationEuropean)
Esempio n. 7
0
from apiclient import discovery
from google.oauth2 import service_account
from datetime import datetime, timedelta
from itertools import zip_longest
from enum import Enum, auto
import pytz

import common as c

# from aqi import aqi

CREDS_FILE = c.get_abs_path('credentials.json')
SCOPES = [
        "https://www.googleapis.com/auth/drive",
        "https://www.googleapis.com/auth/drive.file",
        "https://www.googleapis.com/auth/spreadsheets",
]
TIMEZONE = 'Europe/Sofia'
TS_FMT = "%Y%m%d_%H%M%S"
TS_FMT_PRETTY = "%Y-%m-%d %H:%M:%S" # parsable by Sheets

def build_sheets():
    credentials = service_account.Credentials \
            .from_service_account_file(CREDS_FILE, scopes=SCOPES)

    max_exception_count = 3

    # Let's try a couple of times, just to be sure
    for i in range(max_exception_count):
        try:
            return discovery.build(
Esempio n. 8
0
def get_tp_install_path_absolute():
    return get_abs_path(get_tp_install_path_from_settings())
Esempio n. 9
0
def get_sal_repo_absolute():
    return get_abs_path(get_sal_repo_from_config())
Esempio n. 10
0
def get_sal_home_absolute():
    return get_abs_path(get_sal_home_from_config())
Esempio n. 11
0
def get_stratum_home_absolute():
    return get_abs_path(get_stratum_profile_details_dict().get('stratum_home'))