Skip to content

Instantly share code, notes, and snippets.

View gist:0a84c22be978e1435cab
def find_root(self, node):
"""
find the node whose parent is the invisible root item
Parameters
----------
node : QtGui.QTreeWidgetItem
The node whose top level parent you wish to find
Returns
View tmp.py
def foo(var1=None, var2=False, var3=None, var4=None):
# get the number of input arguments
argcount = foo.func_code.co_argcount
# get the names of those input arguments
varnames = search.func_code.co_varnames[:argcount]
# get the values of those input arguments
# ???
# I can programatically do it by:
varvals = [var1, var2, var3, var4]
# and then create a dictionary by:
View gist:16f3520717ebdddea7ee
C:\dev\my_src\python\metadataStore [master]> python .\example\sample_code_raw.py
Header insert time is 5.00011444092 ms
Descriptor insert time is 3.99994850159 ms
Event insert time is 11.9998455048 ms
Traceback (most recent call last):
File ".\example\sample_code_raw.py", line 32, in <module>
print db.header.find({'tags': {'$in': ['CSX_Experiment1']}})[0]
File "C:\Users\edill\AppData\Local\Continuum\Anaconda\lib\site-packages\pymong
o\cursor.py", line 597, in __getitem__
@ericdill
ericdill / gist:1bbedb5046dfb5534f03
Created Dec 11, 2014
Error in metadataStore/example/sample_collection_code.py 2014-12-11
View gist:1bbedb5046dfb5534f03
Traceback (most recent call last):
File "/home/edill/dev/python/metadataStore/example/sample_collection_code.py", line 71, in <module>
create_event(event)
File "/home/edill/dev/python/metadataStore/metadataStore/collectionapi/commands.py", line 106, in create_event
owner=owner, data=data)
File "/home/edill/dev/python/metadataStore/metadataStore/dataapi/commands.py", line 271, in insert_event
__validate_keys(formatted_data_keys, desc_data_keys)
File "/home/edill/dev/python/metadataStore/metadataStore/dataapi/commands.py", line 293, in __validate_keys
raise ValueError('Data keys for event data and descriptor data do not match! Check ' + str(key))
View gist:f42650110f121086afda
__author__ = 'arkilic'
import six
import random
import time
from metadataStore.api.collection import (create_event,
create_header,
create_event_descriptor)
from metadataStore.api.collection import search_and_compose as search
import numpy as np
View read_pvs.py
"CSX-1 Scalars":
EpicsScaler:
pimte_tot1:
record: XF:23ID1-ES{Dif-Cam:PIMTE}Stats1:Total_RBV
numchan: 32
EpicsSignal:
sclr_trig:
read_pv: XF:23ID1-ES{Sclr:1}.CNT
sclr_ch1:
read_pv: XF:23ID1-ES{Sclr:1}.S1
@ericdill
ericdill / gist:cccadfe4e5f2aec87a6d
Created Feb 12, 2015
Adding datetimes back into BrokerStruct objects
View gist:cccadfe4e5f2aec87a6d
try:
# get the time
time = self.time
try:
# get the timestamp represented as datetime
time_as_datetime = getattr(mongo_document, 'time_as_datetime')
except AttributeError:
# convert the timestamp into a datetime object
time_as_datetime = datetime.datetime.fromtimestamp(time)
# and set the object attribute
View gist:bd883734d9b7fe009014
{
"metadata": {
"name": "",
"signature": "sha256:e2605b210ae12f03dc1edcc0d0f9ee37e92ea29878dc6281fa7f9cec614dd86c"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
View gist:cdf8fb1b86f4210ba451
{
"metadata": {
"name": "",
"signature": "sha256:99ca63ecc5c9fe998ed4fd04b1399099f64b62a231cec3d72c27eb8c921dc740"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@ericdill
ericdill / gist:8fa995c1ca8f786b0645
Created Mar 31, 2015
v0.0.6 dataportal changelog
View gist:8fa995c1ca8f786b0645
# Change Log
## [Unreleased](https://github.com/NSLS-II/dataportal/tree/HEAD)
[Full Changelog](https://github.com/NSLS-II/dataportal/compare/v0.0.5...HEAD)
**Closed issues:**
- Teach DataBroker\[key\] about uids [\#130](https://github.com/NSLS-II/dataportal/issues/130)