<commit_before>#!/usr/bin/python
usage       = "segLogic.py [--options] config.ini"
description = "look for segments around a GraceDB event and upload them to GraceDB"
author      = "<NAME> (<EMAIL>), <NAME> (<EMAIL>)"

#-------------------------------------------------

import json
import sys
import os
import glob

from collections import defaultdict

import time
from lal import gpstime as lal_gpstime

from glue.ligolw import ligolw
from glue.ligolw import table
from glue.ligolw import lsctables
from glue.ligolw import utils as ligolw_utils

from ligo.gracedb.rest import GraceDb

import subprocess as sp

from ConfigParser import SafeConfigParser
from optparse import OptionParser

#-------------------------------------------------

def flag2filename( flag, start, dur, output_dir="." ):
    flag = flag.split(":")
    flag = "%s-%s"%(flag[0], "_".join(f.replace("-","_") for f in flag[1:]))
    return "%s/%s-%d-%d.xml.gz"%(output_dir, flag, start, dur)

def segDBcmd( url, flag, start, end, outfilename, dmt=False ):
    ### ligolw_segment_query_dqsegdb -t https://segments.ligo.org -q -a H1:DMT-ANALYSIS_READY:1 -s 1130950800 -e 1131559200
    if dmt:
        return "ligolw_segment_query_dqsegdb --dmt-files -q -a %s -s %d -e %d -o %s"%(flag, start, end, outfilename)
    else:
        return "ligolw_segment_query_dqsegdb -t %s -q -a %s -s %d -e %d -o %s"%(url, flag, start, end, outfilename)
<commit_msg>updated command line generation to better match odd behavior observed with segDb clients. It appears that ligolw_segment_query works with --dmt-files but not actually querying the database. However, ligolw_segment_query_dqsegdb works with the database, but not with --dmt-files.<commit_after>#!/usr/bin/python
usage       = "segLogic.py [--options] config.ini"
description = "look for segments around a GraceDB event and upload them to GraceDB"
author      = "<NAME> (<EMAIL>), <NAME> (<EMAIL>)"

#-------------------------------------------------

import json
import sys
import os
import glob

from collections import defaultdict

import time
from lal import gpstime as lal_gpstime

from glue.ligolw import ligolw
from glue.ligolw import table
from glue.ligolw import lsctables
from glue.ligolw import utils as ligolw_utils

from ligo.gracedb.rest import GraceDb

import subprocess as sp

from ConfigParser import SafeConfigParser
from optparse import OptionParser

#-------------------------------------------------

def flag2filename( flag, start, dur, output_dir="." ):
    flag = flag.split(":")
    flag = "%s-%s"%(flag[0], "_".join(f.replace("-","_") for f in flag[1:]))
    return "%s/%s-%d-%d.xml.gz"%(output_dir, flag, start, dur)

def segDBcmd( url, flag, start, end, outfilename, dmt=False ):
    ### ligolw_segment_query_dqsegdb -t https://segments.ligo.org -q -a H1:DMT-ANALYSIS_READY:1 -s 1130950800 -e 1131559200
    if dmt:
        return "ligolw_segment_query --dmt-files -q -a %s -s %d -e %d -o %s"%(flag, start, end, outfilename)
    else:
        return "ligolw_segment_query_dqsegdb -t %s -q -a %s -s %d -e %d -o %s"%(url, flag, start, end, outfilename)

{'fraction_non_alphanumeric': 0.17932148626817448, 'fraction_numerical': 0.01615508885298869, 'mean_word_length': 2.9641485275288093, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2164469', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1027, 'n_words': 335}