Skip to content

Commit

Permalink
Upstream updates (#147)
Browse files Browse the repository at this point in the history
* Upstream updates
  • Loading branch information
andamian authored Jul 12, 2021
1 parent a7f91fc commit 7cb1c6a
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 37 deletions.
93 changes: 93 additions & 0 deletions caom2repo/caom2repo/data/plugins/cadcschemeplugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env python2.7
# # -*- coding: utf-8 -*-
# ***********************************************************************
# ****************** CANADIAN ASTRONOMY DATA CENTRE *******************
# ************* CENTRE CANADIEN DE DONNÉES ASTRONOMIQUES **************
#
# (c) 2021. (c) 2021.
# Government of Canada Gouvernement du Canada
# National Research Council Conseil national de recherches
# Ottawa, Canada, K1A 0R6 Ottawa, Canada, K1A 0R6
# All rights reserved Tous droits réservés
#
# NRC disclaims any warranties, Le CNRC dénie toute garantie
# expressed, implied, or énoncée, implicite ou légale,
# statutory, of any kind with de quelque nature que ce
# respect to the software, soit, concernant le logiciel,
# including without limitation y compris sans restriction
# any warranty of merchantability toute garantie de valeur
# or fitness for a particular marchande ou de pertinence
# purpose. NRC shall not be pour un usage particulier.
# liable in any event for any Le CNRC ne pourra en aucun cas
# damages, whether direct or être tenu responsable de tout
# indirect, special or general, dommage, direct ou indirect,
# consequential or incidental, particulier ou général,
# arising from the use of the accessoire ou fortuit, résultant
# software. Neither the name de l'utilisation du logiciel. Ni
# of the National Research le nom du Conseil National de
# Council of Canada nor the Recherches du Canada ni les noms
# names of its contributors may de ses participants ne peuvent
# be used to endorse or promote être utilisés pour approuver ou
# products derived from this promouvoir les produits dérivés
# software without specific prior de ce logiciel sans autorisation
# written permission. préalable et particulière
# par écrit.
#
# This file is part of the Ce fichier fait partie du projet
# OpenCADC project. OpenCADC.
#
# OpenCADC is free software: OpenCADC est un logiciel libre ;
# you can redistribute it and/or vous pouvez le redistribuer ou le
# modify it under the terms of modifier suivant les termes de
# the GNU Affero General Public la “GNU Affero General Public
# License as published by the License” telle que publiée
# Free Software Foundation, par la Free Software Foundation
# either version 3 of the : soit la version 3 de cette
# License, or (at your option) licence, soit (à votre gré)
# any later version. toute version ultérieure.
#
# OpenCADC is distributed in the OpenCADC est distribué
# hope that it will be useful, dans l’espoir qu’il vous
# but WITHOUT ANY WARRANTY; sera utile, mais SANS AUCUNE
# without even the implied GARANTIE : sans même la garantie
# warranty of MERCHANTABILITY implicite de COMMERCIALISABILITÉ
# or FITNESS FOR A PARTICULAR ni d’ADÉQUATION À UN OBJECTIF
# PURPOSE. See the GNU Affero PARTICULIER. Consultez la Licence
# General Public License for Générale Publique GNU Affero
# more details. pour plus de détails.
#
# You should have received Vous devriez avoir reçu une
# a copy of the GNU Affero copie de la Licence Générale
# General Public License along Publique GNU Affero avec
# with OpenCADC. If not, see OpenCADC ; si ce n’est
# <http://www.gnu.org/licenses/>. pas le cas, consultez :
# <http://www.gnu.org/licenses/>.
#
# $Revision: 4 $
#
# ***********************************************************************
#
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from caom2.observation import Observation


class ObservationUpdater(object):
"""ObservationUpdater that adds a plane to the observation."""

def update(self, observation, **kwargs):
"""
Processes an observation and updates it
"""
assert isinstance(observation, Observation), (
"observation %s is not an Observation".format(observation))
print("Observation: {}".format(observation.observation_id))
for plane in observation.planes.values():
for artifact in plane.artifacts.values():
if artifact.uri.startswith('ad:'):
olduri = artifact.uri
newuri = artifact.uri.replace('ad:', 'cadc:')
artifact.uri = newuri
print('\t{} -> {}'.format(olduri, artifact.uri))
return True
6 changes: 1 addition & 5 deletions caom2repo/caom2repo/tests/data/create_help.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
usage: caom2-repo create [-h]
[--cert CERT | -n | --netrc-file NETRC_FILE | -u USER]
[--host HOST] [--resource-id RESOURCE_ID]
[-d | -q | -v]
[--resource-id RESOURCE_ID] [-q | -v]
observation

Create a new observation
Expand All @@ -12,10 +11,7 @@ positional arguments:
optional arguments:
--cert CERT location of your X509 certificate to use for
authentication (unencrypted, in PEM format)
-d, --debug debug messages
-h, --help show this help message and exit
--host HOST base hostname for services - used mainly for testing
(default: www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca)
-n use .netrc in $HOME for authentication
--netrc-file NETRC_FILE
netrc file to use for authentication
Expand Down
6 changes: 1 addition & 5 deletions caom2repo/caom2repo/tests/data/delete_help.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
usage: caom2-repo delete [-h]
[--cert CERT | -n | --netrc-file NETRC_FILE | -u USER]
[--host HOST] [--resource-id RESOURCE_ID]
[-d | -q | -v]
[--resource-id RESOURCE_ID] [-q | -v]
collection observationID

Delete an existing observation
Expand All @@ -13,10 +12,7 @@ positional arguments:
optional arguments:
--cert CERT location of your X509 certificate to use for
authentication (unencrypted, in PEM format)
-d, --debug debug messages
-h, --help show this help message and exit
--host HOST base hostname for services - used mainly for testing
(default: www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca)
-n use .netrc in $HOME for authentication
--netrc-file NETRC_FILE
netrc file to use for authentication
Expand Down
6 changes: 1 addition & 5 deletions caom2repo/caom2repo/tests/data/read_help.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
usage: caom2-repo read [-h]
[--cert CERT | -n | --netrc-file NETRC_FILE | -u USER]
[--host HOST] [--resource-id RESOURCE_ID]
[-d | -q | -v] [--output OUTPUT]
[--resource-id RESOURCE_ID] [-q | -v] [--output OUTPUT]
collection observationID

Read an existing observation
Expand All @@ -13,10 +12,7 @@ positional arguments:
optional arguments:
--cert CERT location of your X509 certificate to use for
authentication (unencrypted, in PEM format)
-d, --debug debug messages
-h, --help show this help message and exit
--host HOST base hostname for services - used mainly for testing
(default: www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca)
-n use .netrc in $HOME for authentication
--netrc-file NETRC_FILE
netrc file to use for authentication
Expand Down
6 changes: 1 addition & 5 deletions caom2repo/caom2repo/tests/data/update_help.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
usage: caom2-repo update [-h]
[--cert CERT | -n | --netrc-file NETRC_FILE | -u USER]
[--host HOST] [--resource-id RESOURCE_ID]
[-d | -q | -v]
[--resource-id RESOURCE_ID] [-q | -v]
observation

Update an existing observation
Expand All @@ -12,10 +11,7 @@ positional arguments:
optional arguments:
--cert CERT location of your X509 certificate to use for
authentication (unencrypted, in PEM format)
-d, --debug debug messages
-h, --help show this help message and exit
--host HOST base hostname for services - used mainly for testing
(default: www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca)
-n use .netrc in $HOME for authentication
--netrc-file NETRC_FILE
netrc file to use for authentication
Expand Down
8 changes: 2 additions & 6 deletions caom2repo/caom2repo/tests/data/visit_help.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
usage: caom2-repo visit [-h]
[--cert CERT | -n | --netrc-file NETRC_FILE | -u USER]
[--host HOST] [--resource-id RESOURCE_ID]
[-d | -q | -v] --plugin PLUGIN [--start START]
[--end END] [--obs_file OBS_FILE]
[--resource-id RESOURCE_ID] [-q | -v] --plugin PLUGIN
[--start START] [--end END] [--obs_file OBS_FILE]
[--threads {2,3,4,5,6,7,8,9}] [--halt-on-error]
collection

Expand All @@ -14,14 +13,11 @@ positional arguments:
optional arguments:
--cert CERT location of your X509 certificate to use for
authentication (unencrypted, in PEM format)
-d, --debug debug messages
--end END latest observation to visit (UTC IVOA format: YYYY-mm-
ddTH:M:S)
--halt-on-error stop visitor on first update exception raised by
plugin
-h, --help show this help message and exit
--host HOST base hostname for services - used mainly for testing
(default: www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca)
-n use .netrc in $HOME for authentication
--netrc-file NETRC_FILE
netrc file to use for authentication
Expand Down
8 changes: 2 additions & 6 deletions caom2utils/caom2utils/tests/data/help.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
usage: fits2caom2 [-h] [--cert CERT | -n | --netrc-file NETRC_FILE | -u USER]
[--host HOST] [--resource-id RESOURCE_ID] [-d | -q | -v]
[-V] [--dumpconfig] [--not_connected] [--no_validate]
[-o OUT_OBS_XML]
[--resource-id RESOURCE_ID] [-q | -v] [-V] [--dumpconfig]
[--not_connected] [--no_validate] [-o OUT_OBS_XML]
(-i IN_OBS_XML | --observation collection observationID)
[--local LOCAL [LOCAL ...]] [--productID PRODUCTID]
[--config CONFIG] [--default DEFAULT] [--override OVERRIDE]
Expand All @@ -17,12 +16,9 @@ optional arguments:
authentication (unencrypted, in PEM format)
--config CONFIG optional CAOM2 utype to keyword config file to merge
with the internal configuration
-d, --debug debug messages
--default DEFAULT file with default values for keywords
--dumpconfig output the utype to keyword mapping to the console
-h, --help show this help message and exit
--host HOST base hostname for services - used mainly for testing
(default: www.cadc-ccda.hia-iha.nrc-cnrc.gc.ca)
-i, --in IN_OBS_XML input of observation to be augmented in XML
--local LOCAL [LOCAL ...]
list of files in local filesystem (same order as uri)
Expand Down
4 changes: 0 additions & 4 deletions caom2utils/caom2utils/tests/data/too_few_arguments_help.txt
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
usage: fits2caom2 [-h] [-V] [-d | -q | -v] [-o OUT_OBS_XML]
(-i IN_OBS_XML | --observation collection observationID)
productID fileURI [fileURI ...]
fits2caom2: error: too few arguments
2 changes: 1 addition & 1 deletion caom2utils/caom2utils/tests/test_fits2caom2.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ def _get_obs(from_xml_string):
<caom2:productType>thumbnail</caom2:productType>
<caom2:releaseType>data</caom2:releaseType>
<caom2:contentType>text/plain</caom2:contentType>
<caom2:contentLength>2709</caom2:contentLength>
<caom2:contentLength>2484</caom2:contentLength>
<caom2:contentChecksum>md5:e6c08f3b8309f05a5a3330e27e3b44eb</caom2:contentChecksum>
<caom2:uri>file://""" + text_file + """</caom2:uri>
</caom2:artifact>
Expand Down

0 comments on commit 7cb1c6a

Please sign in to comment.