Skip to content

Commit

Permalink
Testing updated / new packages functions
Browse files Browse the repository at this point in the history
  • Loading branch information
katieb1 committed Dec 5, 2023
1 parent d9830bd commit f529074
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rsyncrosim
Type: Package
Title: The R Interface to 'SyncroSim'
Version: 1.4.13
Version: 2.0.0
Authors@R: c(
person("Colin", "Daniel", email = "colin.daniel@apexrms.com",
role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# rsyncrosim 1.4.13
# rsyncrosim 2.0.0

## Breaking changes

Expand Down
2 changes: 1 addition & 1 deletion R/addPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ setMethod("addPackage", signature(ssimLibrary = "SsimLibrary"), function(ssimLib

tt <- command(list(add = NULL, package = NULL, lib = .filepath(ssimLibrary),
pkg = cVal), .session(ssimLibrary))
if (tt == "saved"){
if (tt[1] == "saved"){
message(paste0("Package <", cVal, "> added"))
retList[[cVal]] <- TRUE
} else {
Expand Down
18 changes: 14 additions & 4 deletions R/installPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ setMethod("installPackage", signature(session = "missingOrNULL"), function(name,
#' @rdname installPackage
setMethod("installPackage", signature(session = "Session"), function(name, session) {
success <- FALSE
progName <- "SyncroSim.PackageManager.exe"

if (is.null(name)) {
stop("A package name or file path is required")
Expand All @@ -58,20 +59,29 @@ setMethod("installPackage", signature(session = "Session"), function(name, sessi
if (grepl(".ssimpkg", name)) {
if (!file.exists(name)) {
tt <- paste0("Cannot find file: ", name)
} else{
tt <- command(args = list(finstall = name), session, program = "SyncroSim.PackageManager.exe")
} else {
tt <- command(args = list(finstall = name), session, program = progName)
if (tt == "saved"){
success <- TRUE
tt <- paste0("Package installed from file <", name, ">")
}
}
} else if (dir.exists(name)){
if (!file.exists(file.path(name, "package.xml"))){
tt <- paste0("Package folder is not valid")
}
tt <- command(args = list(xinstall = name), session, program = progName)
if (tt[1] == "saved"){
success <- TRUE
tt <- paste0("Package installed from folder <", name, ">")
}
} else {
pkgs <- packages(session)
if (is.element(name, pkgs$name)) {
tt <- (paste0("Package <", name, "> is already installed"))
} else {
tt <- command(args = list(install = name), session, program = "SyncroSim.PackageManager.exe")
if (tt == "saved"){
tt <- command(args = list(install = name), session, program = progName)
if (tt[1] == "saved"){
tt <- paste0("Package <", name, "> installed")
success <- TRUE
}
Expand Down
31 changes: 16 additions & 15 deletions R/packages.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ setMethod("packages", signature(ssimObject = "Session"), function(ssimObject, in
tt <- command(c(arg), ssimObject, program = "SyncroSim.PackageManager.exe")

if (tt[1] == "saved") {
out <- data.frame(name = NA, displayName = NA, version = NA)
out <- subset(out, !is.na(name))
# out <- data.frame(name = NA, displayName = NA, version = NA)
out <- subset(out, !is.na(Name))
} else if (grepl("The remote name could not be resolved", tt[1])) {
out <- "Could not connect to the package server."
} else {
out <- .dataframeFromSSim(tt, colNames = c("name", "description", "version"), csv = FALSE)
# out <- .dataframeFromSSim(tt, colNames = c("name", "description", "version"), csv = FALSE)
out <- .dataframeFromSSim(tt, csv = FALSE)
}
return(out)
} else {
Expand All @@ -95,20 +96,22 @@ setMethod("packages", signature(ssimObject = "Session"), function(ssimObject, in
# Make sure package is installed
pkgList <- command(c("installed"), ssimObject,
program = "SyncroSim.PackageManager.exe")
pkgDf <- .dataframeFromSSim(pkgList,
colNames = c("name", "description", "version"),
csv = FALSE)
if (listTemplates %in% pkgDf$name == FALSE) {
# pkgDf <- .dataframeFromSSim(pkgList,
# colNames = c("name", "description", "version"),
# csv = FALSE)
pkgDf <- .dataframeFromSSim(pkgList, csv = FALSE)
if (listTemplates %in% pkgDf$Name == FALSE) {
stop("SyncroSim package not installed")
}

# Retrieve list of templates
args <- list(list = NULL, templates = NULL, noheaders = NULL,
package = listTemplates)
tt <- command(args, program = "SyncroSim.Console.exe")
out <- .dataframeFromSSim(tt,
colNames =c("name", "displayName", "installed"),
csv = F)
tt <- command(args, ssimObject, program = "SyncroSim.Console.exe")
# out <- .dataframeFromSSim(tt,
# colNames =c("name", "displayName", "installed"),
# csv = F)
out <- .dataframeFromSSim(tt, csv = F)
return(out)
} else {
stop("listTemplates must be a character name of a SyncroSim Package")
Expand All @@ -120,10 +123,8 @@ setMethod("packages", signature(ssimObject = "Session"), function(ssimObject, in
setMethod("packages", signature(ssimObject = "SsimLibrary"), function(ssimObject) {

# Retrieve list of packages in library
#TODO: change to --packages when update to next version of SyncroSim v3
args <- list(list = NULL, pkgvers = NULL, lib = filepath(ssimObject), csv = NULL)
tt <- command(args, program = "SyncroSim.Console.exe",
progName=filepath(.session(ssimObject)))
args <- list(list = NULL, packages = NULL, lib = filepath(ssimObject), csv = NULL)
tt <- command(args, .session(ssimObject), program = "SyncroSim.Console.exe")
out <- .dataframeFromSSim(tt, csv = T)

return(out)
Expand Down
2 changes: 1 addition & 1 deletion R/uninstallPackage.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ setMethod("uninstallPackage", signature(session = "Session"), function(name, ses

if (answer == "y") {
tt <- command(args = list(uninstall = name), session, program = "SyncroSim.PackageManager.exe")
if (tt == "saved"){
if (tt[1] == "saved"){
tt <- paste0("Package <", name,"> removed")
success <- TRUE
}
Expand Down
5 changes: 2 additions & 3 deletions man/info.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f529074

Please sign in to comment.