Skip to content
Snippets Groups Projects
Commit 296a704d authored by Nathan Bockisch's avatar Nathan Bockisch
Browse files

WS-1807: Utility to copy GMVA directories to the VLBI staging area for ingestion

parent b191f52a
No related branches found
No related tags found
2 merge requests!1452Merge 2.8.2 to main,!1420WS-1807: Utility for copying GMVA directories to staging area for ingestion
module ssa/gmva_ingester
go 1.20
require gitlab.nrao.edu/ssa/gocapo v0.0.0-20230307183307-91ffd4356566
require (
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.13.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
/*
* Copyright (C) 2023 Associated Universities, Inc. Washington DC, USA.
*
* This file is part of NRAO Workspaces.
*
* Workspaces is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Workspaces is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Workspaces. If not, see <https://www.gnu.org/licenses/>.
*/
package main
import (
"flag"
"log"
"os"
"ssa/gmva_ingester/pkg/copy"
)
func main() {
var gmvaDir string
flag.StringVar(&gmvaDir, "dir", "", "Name of the GMVA directory within the GMVA source directory to be copied to the VLBI staging directory")
flag.Parse()
if gmvaDir == "" {
log.Println("GMVA directory argument required!")
flag.Usage()
os.Exit(1)
}
copy.CopyGmva(gmvaDir)
}
/*
* Copyright (C) 2023 Associated Universities, Inc. Washington DC, USA.
*
* This file is part of NRAO Workspaces.
*
* Workspaces is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Workspaces is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Workspaces. If not, see <https://www.gnu.org/licenses/>.
*/
package copy
import (
"os"
"os/exec"
"strings"
"gitlab.nrao.edu/ssa/gocapo/capo/config"
"gitlab.nrao.edu/ssa/gocapo/helpers"
)
//checkError
/**
* Check if an error happened and panic on it if so
*
* @param err An error object to report
**/
func checkError(err error) {
if err != nil {
panic(err)
}
}
/**
* Copy a given GMVA directory from the GMVA source directory to the VLBI
* staging directory
*
* @param dir A string with the name of the GMVA directory
**/
func CopyGmva(dir string) {
capoProperties, err := config.InitConfig(os.Getenv("CAPO_PROFILE"), helpers.DefaultCapoPath)
checkError(err)
ingestionSettings := capoProperties.SettingsForPrefix("edu.nrao.workspaces.IngestionSettings")
gmvaSourcePath := ingestionSettings.GetString("gmvaSourceDirectory")
vlbiStagingPath := ingestionSettings.GetString("vlbiStagingDirectory")
// GMVA source only copies files starting with GMVA
gmvaSourceFiles := strings.Join([]string{gmvaSourcePath, dir, "GMVA*"}, "/")
vlbiTargetDir := strings.Join([]string{vlbiStagingPath, dir}, "/")
// First make the directory to copy files to
mkdirCmd := exec.Command("mkdir", vlbiTargetDir)
err = mkdirCmd.Run()
checkError(err)
copyCmd := exec.Command("cp", "-LR", gmvaSourceFiles, vlbiTargetDir)
err = copyCmd.Run()
checkError(err)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment