Skip to content

Commit

Permalink
Merge pull request #208 from simontorres/version_check_and_athorized_…
Browse files Browse the repository at this point in the history
…API_access

Implemented Authorized GITHUB API access and  version check at start up.
closes #207
  • Loading branch information
Simon Torres committed Aug 13, 2018
2 parents 029bc9b + b5ab07b commit 783dad1
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@

import logging
import requests
import os
import re

from distutils.version import LooseVersion

logger = logging.getLogger(__name__)


LATEST_URL = \
'https://api.github.com/repos/soar-telescope/goodman/releases/latest'
try:
ACCESS_TOKEN = os.environ['GITHUB_ACCESS_TOKEN']
LATEST_URL = \
'https://api.github.com/repos/soar-telescope/goodman/releases/latest' \
'?access_token={:s}'.format(ACCESS_TOKEN)
except KeyError:
LATEST_URL = \
'https://api.github.com/repos/soar-telescope/goodman/releases/latest'


def get_last(url=LATEST_URL):
Expand Down
55 changes: 38 additions & 17 deletions pipeline/core/core.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import calendar
import datetime
import glob
import logging
import math
import os
import re
import shutil
import subprocess
import sys
import time
import glob
import logging
import calendar
from threading import Timer

import ccdproc
import datetime
import numpy as np
import math
import pandas
import scipy
import shutil
import subprocess

from threading import Timer
# matplotlib.use('Qt5Agg')
from matplotlib import pyplot as plt
from ccdproc import CCDData, ImageFileCollection
from astroscrappy import detect_cosmics
from astropy.coordinates import EarthLocation
from astropy.time import Time
from astropy.stats import sigma_clip
from astroplan import Observer
from astropy import units as u
from astropy.coordinates import EarthLocation
from astropy.modeling import (models, fitting, Model)
from astropy.stats import sigma_clip
from astropy.time import Time
from astroscrappy import detect_cosmics
from ccdproc import CCDData, ImageFileCollection
# matplotlib.use('Qt5Agg')
from matplotlib import pyplot as plt
from scipy import signal

from . import check_version

__version__ = __import__('pipeline').__version__

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -1884,7 +1887,25 @@ def setup_logging():
datetime.datetime.now()))
log.info("Universal Time: {:}".format(
datetime.datetime.utcnow()))
log.info("Pipeline Version: {:s}".format(__version__))

try:
latest_release = check_version.get_last()

if "dev" in __version__:
log.warning("Running Development version: {:s}".format(__version__))
log.info("Latest Release: {:s}".format(latest_release))
elif check_version.am_i_updated(__version__):
if __version__ == latest_release:
log.info("Pipeline Version: {:s} (latest)".format(__version__))
else:
log.warning("Current Version: {:s}".format(__version__))
log.info("Latest Release: {:s}".format(latest_release))
else:
log.warning("Current Version '{:s}' is outdated.".format(__version__))
log.info("Latest Release: {:s}".format(latest_release))
except ConnectionRefusedError:
log.error('Unauthorized GitHub API Access reached maximum')
log.info("Current Version: {:s}".format(__version__))


def trace(ccd, model, trace_model, model_fitter, sampling_step, nsigmas=2):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import unittest

from ...tools import check_version
from pipeline.core import check_version

__version__ = __import__('pipeline').__version__

Expand Down
1 change: 0 additions & 1 deletion pipeline/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
unicode_literals)

from . import reference_lamp_factory
from . import check_version
14 changes: 7 additions & 7 deletions pipeline/tools/reference_lamp_factory/create_reference_lamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from pipeline.tools.reference_lamp_factory.wcs_model_calculator import \
GSPWcsCalculator

from pipeline.core import (read_fits,
write_fits,
identify_targets,
trace,
extraction,
SpectroscopicMode,
combine_data)
from ...core import (read_fits,
write_fits,
identify_targets,
trace,
extraction,
SpectroscopicMode,
combine_data)

from pipeline.spectroscopy.new_wavelength import WavelengthCalibration

Expand Down

0 comments on commit 783dad1

Please sign in to comment.