def makeNodeInfo(): # Generate the NodeInfo files (the files containing some node related info) NodeInfo_subdir = "NodeInfo" print "BBS> Updating BBS_WORK_TOPDIR/%s" % NodeInfo_subdir NodeInfo_path = os.path.join(BBSvars.work_topdir, NodeInfo_subdir) bbs.fileutils.remake_dir(NodeInfo_path) os.chdir(NodeInfo_path) writeRversion() writeRconfig() Rscript = "sessionInfo()" bbs.jobs.runJob(BBSbase.Rscript2syscmd(Rscript), \ 'R-sessionInfo.txt', 60.0, True) # ignore retcode Rscript = "data.frame(installed.packages()[,c('Version','Built')])" bbs.jobs.runJob(BBSbase.Rscript2syscmd(Rscript), \ 'R-instpkgs.txt', 60.0, True) # ignore retcode writeSysCommandVersion('CC') writeSysCommandVersion('CXX') writeSysCommandVersion('CXX98') writeSysCommandVersion('CXX11') writeSysCommandVersion('CXX14') writeSysCommandVersion('F77') writeSysCommandVersion('FC') print "BBS> cd BBS_WORK_TOPDIR" os.chdir(BBSvars.work_topdir) BBSvars.Node_rdir.Put(NodeInfo_subdir, True, True) return
def make_STAGE2_pkg_deps_list(target_pkgs): # Make 'target_pkgs.txt' file. target_pkgs_file = "target_pkgs.txt" out = open(target_pkgs_file, 'w') for pkg in target_pkgs: out.write("%s\n" % pkg) out.close() print "BBS> [make_STAGE2_pkg_deps_list]", print "%s pkgs written to %s" % (len(target_pkgs), target_pkgs_file) # Make 'STAGE2_pkg_deps_list.txt' file. Rfunction = "make_STAGE2_pkg_deps_list" script_path = os.path.join(BBScorevars.BBS_home, "utils", "make_STAGE2_pkg_deps_list.R") STAGE2_pkg_deps_list_path = "STAGE2_pkg_deps_list.txt" print "BBS> [make_STAGE2_pkg_deps_list]", print "Calling %s() defined in %s to make %s file ..." % \ (Rfunction, script_path, STAGE2_pkg_deps_list_path), # Backslashes in the paths injected in 'Rscript' will be seen as escape # characters by R so we need to replace them. Nothing will be replaced # on a Unix-like platform, only on Windows where the paths can actually # contain backslashes. script_path2 = script_path.replace('\\', '/') target_pkgs_file2 = target_pkgs_file.replace('\\', '/') STAGE2_pkg_deps_list_path2 = STAGE2_pkg_deps_list_path.replace('\\', '/') # Use short.list=TRUE to skip installation of target packages not needed # by another target package for build or check. #Rscript = "source('%s');%s('%s',outfile='%s',short.list=TRUE)" % \ Rscript = "source('%s');%s('%s',outfile='%s')" % \ (script_path2, Rfunction, target_pkgs_file2, STAGE2_pkg_deps_list_path2) out_file = Rfunction + ".Rout" bbs.jobs.runJob(BBSbase.Rscript2syscmd(Rscript), out_file) # ignore retcode print "OK" # Load 'STAGE2_pkg_deps_list.txt' file. print "BBS> [make_STAGE2_pkg_deps_list] Loading %s file ..." % \ STAGE2_pkg_deps_list_path, f = open(STAGE2_pkg_deps_list_path, 'r') pkg_deps_list = {} EMPTY_STRING = '' for line in f: (pkg, deps) = line.split(":") deps = deps.strip().split(" ") if EMPTY_STRING in deps: deps.remove(EMPTY_STRING) pkg_deps_list[pkg] = deps f.close() print "OK (%s pkgs and their deps loaded)" % len(pkg_deps_list) print "BBS> [make_STAGE2_pkg_deps_list] DONE." return pkg_deps_list
def get_installed_pkgs(): installed_pkgs_path = "installed_pkgs.txt" Rscript = "writeLines(rownames(installed.packages()),'%s')" % \ installed_pkgs_path out_file = "get_installed_pkgs.Rout" bbs.jobs.runJob(BBSbase.Rscript2syscmd(Rscript), out_file) # ignore retcode installed_pkgs = [] f = open(installed_pkgs_path, 'r') for line in f: installed_pkgs.append(line.strip()) f.close() print "BBS> [get_installed_pkgs] %s installed pkgs" % len(installed_pkgs) return installed_pkgs
def CallRfunctionFromSTAGE2Script(Rfunction, out_file=None): print "BBS> [%s] BEGIN ..." % Rfunction script_path = BBSvars.STAGE2_r_script # Backslahes in the paths injected in 'Rscript' will be seen as escape # characters by R so we need to replace them. Nothing will be replaced # on a Unix-like platform, only on Windows where the paths can actually # contain backslahes. script_path = script_path.replace('\\', '/') Rscript = "source('%s');%s()" % (script_path, Rfunction) if out_file == None: out_file = '%s.Rout' % Rfunction bbs.jobs.runJob(BBSbase.Rscript2syscmd(Rscript), out_file, 3600.0) # ignore retcode print "BBS> [%s] END." % Rfunction return