Skip to content

Commit

Permalink
Merge pull request #5 from snoweye/master
Browse files Browse the repository at this point in the history
0.2-0
  • Loading branch information
snoweye authored Feb 2, 2018
2 parents de8a9d0 + 0ac2bb4 commit 6f232d7
Show file tree
Hide file tree
Showing 47 changed files with 1,112 additions and 473 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*~
*.swp

config.status
src/Makevars
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ env:
global:
- CRAN: https://cran.rstudio.com

# os:
# - linux
os:
- linux

# dist: trusty
dist: trusty

# r_check_args: --no-build-vignettes --no-manual
r_check_args: --no-build-vignettes --no-manual

os:
- osx
# os:
# - osx

before_install:
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
Expand Down
17 changes: 17 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
2018-02-01: Ver. 0.2-0
*

2017-01-15: Ver. 0.2-0
* Fix rpc_ps() and tunnel().
* Modify port forwarding example in vignettes via tunnel().

2017-01-14: Ver. 0.2-0
* Rename original rpc() to srpc().
* Add tunnel().
* Print pid when intern and wait are both FALSE.
* Add machine information section in vignettes.

2017-01-12: Ver. 0.2-0
* Change API to operate on machine configurations, generated by machine().
* Add some type checks/safety.

======================= Log Before Release =====================================
2016-12-31: Ver. 0.1-1
* Add one more advance application with pbdMPI to vignettes.
Expand Down
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: pbdRPC
Version: 0.1-1
Date: 2017-01-01
Version: 0.2-0
Date: 2018-02-01
Title: Programming with Big Data -- Remote Procedure Call
Authors@R: c(person("Wei-Chen", "Chen", role = c("aut", "cre"), email =
"[email protected]"))
Depends: R (>= 3.2.0)
Enhances: pbdZMQ, remoter, pbdMPI, pbdCS
"[email protected]"), person("Drew", "Schmidt", role="aut"))
Depends: R (>= 3.2.0), tools
Enhances: pbdZMQ, remoter, pbdMPI
LazyLoad: yes
LazyData: yes
Copyright: See pbdRPC/inst/putty_LICENCE for files in src/putty/.
Expand All @@ -18,6 +18,6 @@ URL: http://r-pbd.org/
BugReports: http://group.r-pbd.org/
MailingList: Please send questions and comments regarding pbdR to
[email protected]
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
NeedsCompilation: yes
Maintainer: Wei-Chen Chen <[email protected]>
10 changes: 10 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Generated by roxygen2: do not edit by hand

S3method(print,machine)
export(.rpcopt_init)
export(RPC.CT)
export(RPC.LI)
export(RPC.RR)
export(check_cs)
export(check_exec)
export(check_rr)
export(checkx_rr)
export(find_plink)
export(kill_cs)
export(kill_rr)
export(killx_rr)
export(machine)
export(plink)
export(rpc)
export(rpc_kill)
export(rpc_ps)
export(rpcopt_get)
export(rpcopt_set)
export(run_args)
export(srpc)
export(ssh)
export(start_cs)
export(start_rr)
export(startx_rr)
export(tunnel)
importFrom(tools,pskill)
25 changes: 16 additions & 9 deletions R/111_control.r
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
#' e.g. continuously port forwarding without sending commands to background.
#'
#' @param exec.type,args,pport,user,hostname,priv.key,priv.key.ppk
#' RPC login information used by \code{\link{rpc}()}, \code{\link{ssh}()}, or
#' RPC login information used by \code{\link{srpc}()}, \code{\link{ssh}()}, or
#' \code{\link{plink}()}.
#'
# #' @param unix,macos,windows
#'
#' @param check,kill,start,preload
#' @param check,kill,start,preload,checkx,killx,startx
#' RPC remoter commands used by \code{\link{check_rr}()},
#' \code{\link{kill_rr}()}, or \code{\link{start_rr}()}.
#' \code{\link{kill_rr}()}, or \code{\link{start_rr}()} and
#' virtual X11 related versions \code{\link{checkx_rr}()},
#' \code{\link{killx_rr}()}, or \code{\link{startx_rr}()}..
#' RPC pbdCS commands used by \code{\link{check_cs}()},
#' \code{\link{kill_cs}()}, or \code{\link{start_cs}()}.
#'
Expand Down Expand Up @@ -58,7 +60,7 @@ RPC.CT <- function(
RPC.LI <- function(
exec.type = "ssh",
args = "",
pport = "22",
pport = 22,
user = "snoweye",
hostname = "192.168.56.101",
priv.key = "~/.ssh/id_rsa",
Expand Down Expand Up @@ -103,16 +105,22 @@ RPC.LI <- function(
#' @export
#' @rdname zz_rpc_control
RPC.RR <- function(
check = "ps ax|grep '[r]emoter::server'",
kill = "kill -9 $(ps ax|grep '[r]emoter::server'|awk '{print $1}')",
check = "ps axww|grep '[r]emoter::server'",
kill = "kill -9 $(ps axww|grep '[r]emoter::server'|awk '{print $1}')",
start = "nohup Rscript -e 'remoter::server()' > .rrlog 2>&1 < /dev/null &",
preload = "source ~/work-my/00_set_devel_R; "
preload = "source ~/work-my/00_set_devel_R; ",
checkx = "ps axww|grep '[r]emoter::server\\|[x]vfb-run'",
killx = "kill -9 $(ps axww|grep '[r]emoter::server\\|[x]vfb-run'|awk '{print $1}')",
startx = "nohup xvfb-run Rscript -e 'remoter::server()' > .rrlog 2>&1 < /dev/null &"
){
list(
check = check,
kill = kill,
start = start,
preload = preload
preload = preload,
checkx = checkx,
killx = killx,
startx = startx
)
}

Expand All @@ -133,4 +141,3 @@ RPC.CS <- function(
preload = preload
)
}

116 changes: 116 additions & 0 deletions R/machine.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#' machine
#'
#' Remote machine configuration settings.
#'
#' @param exec.type
#' either "ssh" or "plink" in character. Windows will force to use "plink".
#' @param args
#' further arguments to "ssh" or "plink" for connecting to the server
#' in addition to port, user id, and host name.
#' @param pport
#' ssh port opened on the server.
#' @param user
#' user id for logging to the server. If none is supplied, then the system user
#' name will be used instead.
#' @param hostname
#' the server ip or host name.
#' @param priv.key,priv.key.ppk
#' location of the private key for user authentication, the file will be
#' checked first then \code{-i priv.key} will be added to \code{args}
#' when the file exists.
#' \code{priv.key.ppk} is only used when \code{plink} is called.
#'
#' @return
#' An object of class \code{machine}.
#'
#' @examples
#' \dontrun{
#' # note: not my actual aws url
#' myaws <- machine("ec2-1-2-3-4.compute-1.amazonaws.com", user="my_aws_username")
#'
#' # if you don't specify 'user', we use your host machine's user name
#' myvm <- machine("192.168.1.10")
#' }
#'
#' @name machine
#' @export
machine <- function(hostname, user, exec.type = .pbd_env$RPC.LI$exec.type,
args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport,
priv.key = .pbd_env$RPC.LI$priv.key,
priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk)
{
if (missing(user))
{
if (.Platform$OS.type == "windows")
user <- shell("echo %username%", intern=TRUE)
else
user <- system("whoami", intern=TRUE)
warning("No user name supplied; using system user name...")
}

if (missing(hostname))
stop("You must supply a host name or ip in machine() call; i.e. what do you want to connect to?")

check.is.string(hostname)
check.is.string(user)
check.is.string(exec.type)
check.is.string(args)
check.is.posint(pport)
check.is.string(priv.key)
check.is.string(priv.key.ppk)

if (.Platform$OS.type == "windows")
exec.type <- "plink"
if (exec.type != "ssh" && exec.type != "plink")
stop(paste0("exec.type (", exec.type, ") is not found."))

m <- list(hostname=hostname, user=user, exec.type=exec.type, args=args,
pport=pport, priv.key=priv.key, priv.key.ppk=priv.key.ppk)
class(m) <- "machine"

return(m)
}

check.is.machine <- function(machine)
{
# the error message isn't super informative, but the individual argument
# checks can only fail if they go meddling with an object after creation
# via machine(), and such people get what they deserve
errmsg <- "argument 'machine' seemingly not generated via call to machine()"

if (!inherits(machine, "machine"))
stop(errmsg)

check.is.string(machine$hostname, msg=errmsg)
check.is.string(machine$user, msg=errmsg)
check.is.string(machine$exec.type, msg=errmsg)
check.is.string(machine$args, msg=errmsg)
check.is.posint(machine$pport, msg=errmsg)
check.is.string(machine$priv.key, msg=errmsg)
check.is.string(machine$priv.key.ppk, msg=errmsg)

if (machine$exec.type != "ssh" && machine$exec.type != "plink")
stop(errmsg)

invisible(TRUE)
}



#' @title print-machine
#' @description Printing for machine class objects.
#' @param x machine class object
#' @param ... ignored
#' @rdname print-machine
#' @name print-machine
#' @method print machine
#' @export
print.machine <- function(x, ...)
{
cat(paste0("Machine config for ", x$user, "@", x$hostname, "\n"))
cat(paste0(" pport = ", x$pport, "\n"))
cat(paste0(" type = ", x$exec.type, "\n"))
cat(paste0(" args = \"", x$args, "\"\n"))
cat(paste0(" priv.key = ", x$priv.key, "\n"))
cat(paste0(" priv.key.ppk = ", x$priv.key.ppk, "\n"))
}
4 changes: 3 additions & 1 deletion R/pbdRPC-package.r
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#' A very light yet secure implementation of remote procedure call.
#'
#' @references Project URL: \url{https://github.com/RBigData/pbdRPC}
#' @author Wei-Chen Chen
#' @author Wei-Chen Chen and Drew Schmidt
#'
#' @name pbdRPC-package
#'
#' @importFrom tools pskill
#'
#' @docType package
#' @keywords package
Expand Down
Loading

0 comments on commit 6f232d7

Please sign in to comment.