Skip to content

Commit

Permalink
Merge pull request #78 from duncanmmacleod/default_segment_server
Browse files Browse the repository at this point in the history
Use DEFAULT_SEGMENT_SERVER to get default segments location
  • Loading branch information
Duncan Macleod committed Nov 14, 2018
2 parents 2e393b2 + cdf69bf commit 833aa61
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions omicron/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import shutil
import json
import os
import re
from math import (floor, ceil)
from tempfile import mkdtemp
Expand Down Expand Up @@ -57,6 +58,9 @@
}
RAW_TYPE_REGEX = re.compile('[A-Z]1_R')

DEFAULT_SEGMENT_SERVER = os.getenv('DEFAULT_SEGMENT_SERVER',
'https://segments.ligo.org')


def integer_segments(f):
@wraps(f)
Expand All @@ -82,7 +86,7 @@ def write_segments(segmentlist, outfile, coltype=int):


@integer_segments
def query_state_segments(flag, start, end, url='https://segments.ligo.org',
def query_state_segments(flag, start, end, url=DEFAULT_SEGMENT_SERVER,
pad=(0, 0)):
"""Query a segment database for active segments associated with a flag
"""
Expand Down Expand Up @@ -172,13 +176,13 @@ def get_flag_coverage(flag, url=DEFAULT_SEGMENT_SERVER):
return json.loads(raw.read().decode('utf-8'))['results'][flagu]


def get_latest_active_gps(flag, url='https://segments.ligo.org'):
def get_latest_active_gps(flag, url=DEFAULT_SEGMENT_SERVER):
"""Return the end time of the latest active segment for this flag
"""
return get_flag_coverage(flag, url=url)['latest_active_segment']


def get_latest_known_gps(flag, url='https://segments.ligo.org'):
def get_latest_known_gps(flag, url=DEFAULT_SEGMENT_SERVER):
"""Return the end time of the latest known segment for this flag
"""
return get_flag_coverage(flag, url=url)['latest_known_segment']
Expand Down

0 comments on commit 833aa61

Please sign in to comment.