Skip to content

Instantly share code, notes, and snippets.

@cpascual
cpascual / .env
Last active July 9, 2020 11:54
Run `python tangobug-371.py` to reproduce https://github.com/tango-controls/pytango/issues/371
DOCKER_REGISTRY_HOST=nexus.engageska-portugal.pt
DOCKER_REGISTRY_USER=ska-docker
@cpascual
cpascual / taurusbug-1118.py
Last active July 7, 2020 17:03
taurusbug-1118.py
"""
Automated test for https://github.com/taurus-org/taurus/issues/1118
It requires docker-compose to be installed.
- If the bug is not present, it finishes in after counting to 30 and
printing "SUCCESS!"
- If the bug is present, crashes (non-zero exit value) at some point of the
count (~15)
@cpascual
cpascual / taurus_label_sum2.py
Created May 12, 2020 09:41
Using eval to display the sum of two attributes
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.display import TaurusLabel
if __name__ == "__main__":
import sys
app = TaurusApplication(cmd_line_parser=None)
w = TaurusLabel()
w.setModel("eval:m1={sys/tg_test/1/};m2={asdasdasd};m1+m2")
@cpascual
cpascual / taurus_label_2models.py
Last active May 12, 2020 09:46
a taurus-ified QLabel accepting 2 models
import sys
import taurus
from taurus.external.qt import Qt
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.base import TaurusBaseComponent
class MyLabel(Qt.QLabel, TaurusBaseComponent):
"""A taurus-ified QLabel that sums 2 attributes"""
@cpascual
cpascual / get_tg_devs_for_class.py
Created May 4, 2020 18:12
Tango recipe: obtain all device names of a given class (using tango)
# Inspired in https://tango-controls.readthedocs.io/en/latest/tutorials-and-howtos/how-tos/how-to-pytango.html#using-database-object
import tango
class_name = 'TangoTest'
db = tango.Database()
devnames = []
for name in db.get_instance_name_list(class_name):
server_name = '/'.join((class_name, name))
@cpascual
cpascual / mycalc.py
Created March 25, 2020 18:44
Simple calculator made with pyqt5 (for basic qt training)
import os
import sys
from PyQt5 import Qt, uic
class MyCalc(Qt.QWidget):
"""A specialized QLineEdit (implemented using signal connections declared
in the loaded .ui file)
"""
@cpascual
cpascual / FooBar.py
Created February 6, 2020 17:28
FooBar DS (A DS to test taurus issue https://github.com/taurus-org/taurus/issues/1060
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Basic DS for testing events"""
import numpy
from tango import DevState
from tango.server import Device, attribute
@cpascual
cpascual / monitor.py
Last active December 3, 2019 17:56
a simple attr monitor CLI done with taurus
# this is an example to answer the question in
# https://www.tango-controls.org/community/forum/c/development/python/quickest-way-to-write-a-command-line-taurus-client/
import taurus
import time
def print_attr_value(src, _type, value):
print("[{t:}] {name:}={rvalue:}".format(
t=value.time.isoformat(),
@cpascual
cpascual / offline_conda_recipe.md
Last active May 15, 2019 17:38
Offline installation with conda

Scenario:

we want to create a conda environment using packages from arbitrary channels in a machine with no internet access (let's say that we want a machine with keras, sklearn and all taurus dependencies installed)

first create the environment on a connected machine

It is better to use a clean conda installation, so we will use a miniconda docker container

@cpascual
cpascual / bootstrap.ps1
Last active December 16, 2020 23:41
recipe for installing taurus dependencies on Windows 10 using conda
# Powershell script for installing taurus dependencies on a windows10 machine using conda
# I use it for provisioning a vagrant win10 machine
# Install SSL as a workaround for conda bug https://github.com/conda/conda/issues/6064
echo "Installing SSL"
wget "https://slproweb.com/download/Win64OpenSSL-1_1_1a.msi" -OutFile "$env:TMP\SSL.msi"
msiexec /quiet /i "$env:TMP\SSL.msi"
echo "Downloading conda"
$condainstallerurl = "https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
$condainstaller = "$env:TMP\\Miniconda3-latest-Windows-x86_64.exe"