def onSubmit(self): self.frame.place_forget() # hide login frame username = self.username.get() # get user input apikey = self.apikey.get() # get user input user = labstep.authenticate(username,apikey) # Login via labstep API messagebox.showinfo('Login Success', f'You have successfully authenticated as {user.first_name} {user.last_name}') self.onSuccess(user)
def uploadDataToLabstep(user): user = labstep.authenticate(user['username'], user['apikey']) experiment = user.newExperiment('Python Test') experiment.addComment('Raw data from the plate reader', 'cache/plate_data_raw.csv') experiment.addComment('Script used to analyse the data', 'analysis.py') experiment.addComment('Processed data', 'cache/plate_data_processed.csv') experiment.addComment('Plot of processed data', 'cache/plot.png') print('Data Uploaded!')
def run(self): try: user = "" key = "" with open("key.cfg", "r") as kf: user = kf.readline().rstrip("\n") key = kf.readline().rstrip("\n") self.user = labstep.authenticate(user, key) print(self.user.name) except Exception as ex: self.user = None print(ex)
def getExperiment(self): """ Get Experiment based on Jupyter environment variables. """ if ('LABSTEP_API_KEY' not in os.environ.keys() or 'LABSTEP_JUPYTER_EXPERIMENT_GUID' not in os.environ.keys()): raise Exception("Not in jupyter") user = labstep.authenticate() experimentGuid = os.environ['LABSTEP_JUPYTER_EXPERIMENT_GUID'] return experimentProtocolRepository.getExperimentProtocolByGuid( user, experimentGuid)
def __init__(self): self.observers = [] for user in users: path = user['folder'] lsUser = labstep.authenticate(user['username'], user['apikey']) handler = CustomHandler(self, lsUser) observer = Observer() observer.schedule(handler, path, recursive=True) observer.start() self.observers.append(observer) self.queue = Queue() self.gui = GUI() self.gui.window.bind("<Destroy>", self.shutdown) self.gui.window.bind("<<WatchdogEvent>>", self.handle_watchdog_event)
def test_authenticate(self): authUser = labstep.authenticate(LABSTEP_API_USERNAME, LABSTEP_API_APIKEY) assert authUser.id is not None
def authUser(): return labstep.authenticate(LABSTEP_API_USERNAME, LABSTEP_API_APIKEY)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import labstep import serial # Authenticate Labstep User user = labstep.authenticate('*****@*****.**', 'APIKEY') # Select device device = user.getDevice(2314) print(f'Connected to {device.name}') # Open Serial Port to Device ser = serial.Serial(port='/dev/ttyACM0', timeout=2) # Flush input to avoid data overlap and start fresh ser.flushInput() # Set up loop to continuously monitor data from device try: while True: # Read line of data stream raw_input = ser.readline() # Strip new line characters from the end of the data. stripped_input = raw_input[0:len(raw_input)-2] # Decode the raw bytes data to a float
import labstep import schedule import time import smtplib from prettytable import PrettyTable, ALL from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from string import Template ## Login to Labstep Workspace user = labstep.authenticate('YOUR_USER_NAME', 'YOUR_API_KEY') workspace = user.getWorkspace(13934) def getNewOrderRequests(): ## Get the latest order requests return workspace.getOrderRequests(status='new') def getOrderRow(order): name = order.resource['name'] resource = user.getResource(order.resource['id']) metadata = resource.getMetadata() account_number = "MY_ACCOUNT_NUMBER" vat_status = 'No' try: code = list(filter(lambda x: x.label == 'Product Code', metadata))[0].value except: code = '?' print('Product Code not found for ', name)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import os import labstep import time from watchdog.observers import Observer from watchdog.events import RegexMatchingEventHandler USER_NAME = os.getenv('LABSTEP_USERNAME') API_KEY = os.getenv('LABSTEP_API_KEY') # Authenticate Labstep User user = labstep.authenticate(USER_NAME, API_KEY) # Select device device = user.getDevice(2314) print(f'Connected to {device.name}') # Define what to do when data is detected def onDataDetected(event): device.addData(fieldName='Raw Data File', fieldType='file', filepath=event.src_path) # Use watchdog built in regex event handler # This will detect files that end in .csv my_event_handler = RegexMatchingEventHandler([r".*\.csv$"])