Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/70 #117

Merged
merged 10 commits into from
Mar 29, 2023
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## unreleased
### Added
- Added check for updated version [70](https://github.com/podaac/data-subscriber/issues/70)

## 1.12.0
### Fixed
- Added EDL based token downloading, removing CMR tokens [98](https://github.com/podaac/data-subscriber/issues/98),
Expand Down
240 changes: 155 additions & 85 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions subscriber/podaac_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from datetime import datetime
import time
from requests.auth import HTTPBasicAuth
from packaging import version



Expand Down Expand Up @@ -550,3 +551,18 @@ def create_citation_file(short_name, provider, data_path, token=None, verbose=Fa

with open(data_path + "/" + short_name + ".citation.txt", "w") as text_file:
text_file.write(citation)

def get_latest_release():
github_url = "https://api.github.com/repos/podaac/data-subscriber/releases/latest"
mike-gangl marked this conversation as resolved.
Show resolved Hide resolved
return requests.get(github_url).json()['tag_name']

def release_is_current(latest_release, this_version):
return not (version.parse(this_version) < version.parse(latest_release))

def check_for_latest():
try:
latest_version = get_latest_release()
if not release_is_current(latest_version,__version__):
print(f'You are currently using version {__version__} of the PO.DAAC Data Subscriber/Downloader. Please run:\n\n pip install podaac-data-subscriber --upgrade \n\n to upgrade to the latest version.')
except:
print("Error checking for new version of the po.daac data subscriber. Continuing")
1 change: 1 addition & 0 deletions subscriber/podaac_data_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,5 @@ def main():


if __name__ == '__main__':
pa.check_for_latest()
main()
1 change: 1 addition & 0 deletions subscriber/podaac_data_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,5 @@ def main():


if __name__ == '__main__':
pa.check_for_latest()
main()
16 changes: 16 additions & 0 deletions tests/test_subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
import json
import tempfile
from os.path import exists
from packaging import version



def test_temporal_range():

Expand Down Expand Up @@ -206,3 +209,16 @@ def validate(args):
args2 = parser.parse_args(args)
pa.validate(args2)
return args2

def test_check_updates():
version.parse(pa.get_latest_release())

def test_compare_release():
tag="1.11.0"
assert pa.release_is_current(tag,"1.11.0")
assert pa.release_is_current(tag,"2.10.0")
assert pa.release_is_current(tag,"1.11.1")

assert not pa.release_is_current(tag,"1.10.0")
assert not pa.release_is_current(tag,"1.10.5")
assert not pa.release_is_current(tag,"0.9000.5")