Skip to content

Instantly share code, notes, and snippets.

@klauer
klauer / cap.py
Created May 10, 2023 23:16
wurlitzer for capturing C-level stdout/stderr
import ctypes
import io
import os
from wurlitzer import STDOUT, pipes, sys_pipes
import ophyd
def test():
@klauer
klauer / kfe.pvlist.json
Created August 24, 2021 16:19
whatrecord-parsed kfe.pvlist in JSON
{
"filename": "whatrecord/tests/kfe.pvlist",
"evaluation_order": "ALLOW, DENY",
"rules": [
{
"context": [
[
"whatrecord/tests/kfe.pvlist",
9
]
@klauer
klauer / access.acf.json
Created August 24, 2021 16:17
PCDS access.acf parsed by whatrecord (JSON format)
{
"filename": "whatrecord/tests/access.acf",
"hash": "ed8f59899705560afb347aeffc6a8fecbe1f7775bafb05b905b74f657b9f2c7b",
"users": {},
"groups": {
"DEFAULT": {
"context": [
[
"whatrecord/tests/access.acf",
30
ioc-SDSPLC dupes compared to ioc-cxi-sds: 174 PVs
PLC:SDSPLC:01HZ_MODE
PLC:SDSPLC:01HZ_UPD_TIME
PLC:SDSPLC:02HZ_MODE
PLC:SDSPLC:02HZ_UPD_TIME
PLC:SDSPLC:05HZ_MODE
PLC:SDSPLC:05HZ_UPD_TIME
PLC:SDSPLC:10HZ_MODE
PLC:SDSPLC:10HZ_UPD_TIME
PLC:SDSPLC:1HZ_MODE
@klauer
klauer / gist:f9b6a8b2869df85abe7368f4f6d12e4e
Created February 22, 2021 23:32
bluesky-live -> databroker?
$ python -c 'import databroker'
2021-02-22 15:31:02,812 - intake - ERROR - discovery.py:autodiscover:L147 - Error while loading entrypoint bluesky-event-stream
Traceback (most recent call last):
File "/reg/g/pcds/pyps/conda/py36/envs/pcds-4.0.0/lib/python3.8/site-packages/intake/source/discovery.py", line 250, in _load_entrypoint
return entrypoint.load()
File "/reg/g/pcds/pyps/conda/py36/envs/pcds-4.0.0/lib/python3.8/site-packages/entrypoints.py", line 82, in load
mod = import_module(self.module_name)
File "/reg/g/pcds/pyps/conda/py36/envs/pcds-4.0.0/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
@klauer
klauer / issue_collector.html
Created January 28, 2021 01:31 — forked from kevinvalk/issue_collector.html
Can be used to integrate JIRA issue collector as a iframe form in a page where javascript is not allowed. Call like https://cdn.rawgit.com/kevinvalk/ae09e21a522c378b2ceb419cf09a36a7/raw/a57cb1cb788fa6c141893dd1fdcf185d541c22af/issue_collector.html?url=<JIRA URL>#<ISSUE COLLECTOR ID>.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
<script type="text/javascript">
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
@klauer
klauer / notes.md
Last active January 25, 2021 18:30
macOS installation of in-development slac-national-accelerator-laboratory-archiver-datasource-backend

Installing in-development slac-national-accelerator-laboratory-archiver-datasource-backend

Requires

  • macOS
  • homebrew
  • conda

Check out the right branch

@klauer
klauer / poller.py
Created January 21, 2021 19:50
Reusing the async caproto context
import caproto
import asyncio
from caproto.asyncio.client import Context
caproto.config_caproto_logging(level='DEBUG')
class Poller():
def __init__(self):
self.val = 0
@klauer
klauer / misaligned.py
Created November 25, 2020 18:27
EPICS CAS request errors "missaligned protocol rejected" packet reconstruction by way of caproto
lines = '''CAS: request from 172.23.120.148:38554 => CAS: Missaligned protocol rejected
CAS: Request from 172.23.120.148:38554 => cmmd=0 cid=0x9 type=32769 count=1 postsize=22
CAS: Request from 172.23.120.148:38554 => available=0x6765744c N=0 paddr=0x7fad1800d5f0
CAS: forcing disconnect from 172.23.120.148:38554
CAS: request from 172.23.120.148:38560 => CAS: Client version too old
CAS: Request from 172.23.120.148:38560 => cmmd=18245 cid=0x54502f31 type=12064 count=18516 postsize=21536
CAS: Request from 172.23.120.148:38560 => available=0x2e300d0a N=0 paddr=(nil)
CAS: request from 172.23.120.148:41978 => CAS: Client version too old
CAS: Request from 172.23.120.148:41978 => cmmd=768 cid=0x1 type=3808 count=0 postsize=19
CAS: Request from 172.23.120.148:41978 => available=0x80000 N=0 paddr=0x7fad1800d930
@klauer
klauer / ccm_calc.csv
Created October 16, 2020 22:37
CCM pseudopositioner calculations reported in XCS logs from September 2020
index energy_with_vernier energy alio energy_request
0 7.75 6.313978871724486 7750.0
1 7.75 6.313978871724486 7750.0
2 7.7 6.712128243816217 7700.0
3 7.7 6.712128243816217 7700.0
4 7.695 6.752240508439399 7695.0
5 7.695 6.752240508439399 7695.0
6 7.699981232400288 6.712278704216471 7699.981232400288
7 7.699981232400288 6.712278704216471 7699.981232400288
8 7.695 6.752240508439399 7695.0