Skip to content

Instantly share code, notes, and snippets.

@shreyb
shreyb / parse_voms_production.py
Last active March 2, 2021 16:30
This is a little script to parse the VOMS logs at Fermilab (notice the regexes look for fnal.gov VOMS servers) to grab all the production users.
import argparse
from collections import Counter, defaultdict, namedtuple
from datetime import datetime, timedelta
from functools import partial
import gzip
import pathlib
import re
# Regexes
pid_production_line_regex = re.compile('^(\w{3} \w{3}(?: ){1,2}\d{1,2} \d{2}\:\d{2}\:\d{2} \d{4})\:voms\d\.fnal\.gov\:vomsd\[(\d+)\].+Issued FQAN: .+\/Role=Production\/Capability=NULL\"$')

Keybase proof

I hereby claim:

  • I am shreyb on github.
  • I am sbhat (https://keybase.io/sbhat) on keybase.
  • I have a public key ASDekFSrE2NiV3z8Ikq2xuGimbAE19jOrwQLE8N5_hgb7Qo

To claim this, I am signing this object:

@shreyb
shreyb / test_unique_arg_parse.py
Last active March 9, 2020 17:06
jobsub_client arg parser (next version) that can support unique flags.
#!/usr/bin/python
import argparse
from collections import defaultdict
import pytest
num_changes_limit = 1
class JobsubClientNamespace(argparse.Namespace):
@shreyb
shreyb / double_optparse.py
Created November 19, 2018 22:10
Quick mockup for checking for doubled command line options
from optparse import Option, OptionParser
# Adapted from https://stackoverflow.com/questions/23032514/argparse-disable-same-argument-occurences and optparse docs
class MyOption(Option):
ACTIONS = Option.ACTIONS + ("unique_store",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("unique_store",)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("unique_store",)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("unique_store",)
@shreyb
shreyb / rebuild_all_images.sh
Created September 21, 2017 20:16
Script to rebuild all GRACC reporting images where dockerfiles live
#!/bin/sh
# This script is to rebuild all the images (assuming no version bump) with a new RPM. This is useful, for example, if there's a minor bug found in testing. We can rebuild all the Docker images and push them automatically
# The script also commits the changed rpm to the git repo master branch
# Constants
DOCKERDIR=${HOME}/Project/email_reports-docker
RPMDIR=${HOME}/RPMDocker/rpm_out
BASEDIR=${DOCKERDIR}/base
FIFEBASEDIR=${DOCKERDIR}/fife
@shreyb
shreyb / build_gracc_rpm.sh
Last active July 6, 2017 17:41
Build the gracc-reporting RPM automatically from tarball
#!/bin/sh
TARFILEPATH=`ls -t ${HOME}/rpmbuild/SOURCES/*.tar.gz | head -n 1`
TARFILE=${TARFILEPATH##*/}
SOURCESDIR=${HOME}/rpmbuild/SOURCES
SPECSDIR=${HOME}/rpmbuild/SPECS
RELEASE=`echo ${TARFILE%.tar.gz}`
TMPDIR=/tmp/${RELEASE}
PATH_TO_SPEC=src/graccreports/config/gracc-reporting.spec # Within the tarball
@shreyb
shreyb / install_gracc_rep.sh
Created July 6, 2017 15:57
Script for installing a new gracc-reporting tarball on GRACC
#!/bin/sh
# VARIABLES
SYMLINKNAME=${HOME}/gracc-reporting
GREPGRACCSTRING="^gracc-reporting-[0-9]\.[0-9]+(\.[0-9]+)?$"
ARCHIVEDIR=${HOME}/gracc-reporting-old
VENVNAME=gracc_venv
# Part 1: Setup of dir structure
cd $HOME
@shreyb
shreyb / copypics.py
Created June 20, 2017 21:58
Quick script to go through JPEGS and copy files created after a certain date to a new subdirectory
#!/usr/bin/python
import subprocess
import sys
import os
from datetime import datetime
from time import sleep
from shutil import copy2, rmtree
import re
import json
@shreyb
shreyb / putdoc.sh
Last active December 16, 2016 22:45
Put a VO Correction Record into GRACC
#!/bin/sh
function checklength {
if [[ ${#1} -ne 0 ]];
then
VARCOUNT=$((VARCOUNT+1))
fi
}
CURTIME=`date +%s`