Exemple #1
0
    def __init__(self):
        self.logger = get_logger("Backend")
        self.run = True
        self.socket_path = SPREADSHEET_SOCKET_PATH
        self.socket_timeout = SERVER_SOCKET_TIMEOUT
        self.thread = threading.Thread(target=self.listen, daemon=True)

        self.sheetsData: Dict[SheetName, dict] = {}
Exemple #2
0
#!/usr/bin/env python3

from typing import Dict

import pandas
import numpy

from conscommon import get_logger
from conscommon.spreadsheet import SheetName

logger = get_logger("Parser")


def normalizeAgilent(sheet) -> dict:
    return normalize(sheet, ["C1", "C2", "C3", "C4"])


def normalizeMKS(sheet) -> dict:
    return normalize(sheet, ["A1", "A2", "B1", "B2", "C1", "C2"])


def normalizeMBTemp(sheet) -> dict:
    # ENABLE	IP	Rack	ADDR	Dev	Location
    return normalize(
        sheet,
        ["CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8"],
        device_col="Dev",
    )


def normalize(
Exemple #3
0
from flask import Blueprint, request

from conscommon import get_logger
from conscommon.spreadsheet import SheetName

from .client import BackendClient, InvalidDevice, InvalidCommand

# Set up a Blueprint
spreadsheet_bp = Blueprint("spreadsheet_bp",
                           __name__,
                           template_folder="templates",
                           static_folder="static")

logger = get_logger("Spreadsheet Routes")


@spreadsheet_bp.route("/reload")
def reload():
    try:
        client = BackendClient()
        client.reloadData()
        return f"Data reloaded succesfully!", 200

    except Exception:
        logger.exception("reload entries failed.")
        return (
            f"Unable to update entries from spreadsheet.",
            400,
        )

Exemple #4
0
#!/usr/bin/env python3
import requests
import logging
from typing import List, Iterable, Tuple
from conscommon import get_logger

logger = get_logger(level=logging.INFO)
TIMEFMT = "%d/%m/%Y %H:%M:%S"
API_CANDIDATES = ["10.0.38.42:26001", "localhost:8080"]


class RemoteAPI(Exception):
    pass


def checkCandidates() -> str:
    for ip in API_CANDIDATES:
        url = "http://{}".format(ip)
        try:
            if requests.get(url + "/status", timeout=2).text == "Healthy!":
                logger.info('Using remote url "{}"'.format(url))
                return url + "/devices"
        except:
            logger.warning('Remote url "{}" unavailable'.format(url))
            pass
    raise RemoteAPI("No remote API available")


_TIMEOUT = 5

Exemple #5
0
import select
from enum import Enum, unique

from flask import current_app
from conscommon import get_logger

logger = get_logger("Spreadsheet Common")


@unique
class Command(Enum):
    GET_DEVICE = 1
    RELOAD_DATA = 2
    SHUTDOWN = 3


class InvalidCommand(Exception):
    pass


class InvalidDevice(Exception):
    pass


class BasicComm:
    def __init__(self):
        self.socket_timeout = 0

    def sendBytes(self, s, payload):
        LEN = len(payload)
        _num = 0
Exemple #6
0
    def __init__(self):
        self.socket_path = SPREADSHEET_SOCKET_PATH
        self.socket_timeout = CLIENT_SOCKET_TIMEOUT

        self.logger = get_logger("Client")
        self.logger.debug("BackendClient created")
Exemple #7
0
 def __init__(self):
     self.logger = get_logger("SyncService")
     self.thread = threading.Thread(target=self.doWork, daemon=True)
     self.update_time = None