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) write_R_version() write_R_config() write_sys_command_version('CC') write_sys_command_version('CXX') #write_sys_command_version('CXX98') write_sys_command_version('CXX11') write_sys_command_version('CXX14') write_sys_command_version('CXX17') #write_sys_command_version('F77') #write_sys_command_version('FC') Rexpr = 'sessionInfo()' bbs.jobs.runJob(BBSbase.Rexpr2syscmd(Rexpr), \ 'R-sessionInfo.txt', 60.0, True) # ignore retcode Rexpr = "options(width=500);print(installed.packages()[,c('LibPath','Version','Built')],quote=FALSE)" bbs.jobs.runJob(BBSbase.Rexpr2syscmd(Rexpr), \ 'R-instpkgs.txt', 120.0, True) # ignore retcode print('BBS> cd BBS_WORK_TOPDIR') os.chdir(BBSvars.work_topdir) BBSvars.Node_rdir.Put(NodeInfo_subdir, True, True) return
def get_installed_pkgs(): installed_pkgs_path = 'installed_pkgs.txt' Rexpr = "writeLines(rownames(installed.packages()),'%s')" % \ installed_pkgs_path out_file = 'get_installed_pkgs.Rout' bbs.jobs.runJob(BBSbase.Rexpr2syscmd(Rexpr), 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 write_PACKAGES(rdir): doing_what = 'creating PACKAGES index file for target repo' print('BBS> START %s at %s...' % (doing_what, time.asctime())) sys.stdout.flush() Rexpr = r'library(tools);write_PACKAGES(\".\")' bbs.jobs.doOrDie(BBSbase.Rexpr2syscmd(Rexpr)) ## write_PACKAGES() won't create an empty PACKAGES file if no packages ## are found so we create one. if not os.path.exists('PACKAGES'): f = open('PACKAGES', 'w') f.close() rdir.Put('PACKAGES', True, True) print('BBS> DONE %s at %s.' % (doing_what, time.asctime())) sys.stdout.flush() return
def make_PROPAGATION_STATUS_DB(final_repo): Rfunction = 'makePropagationStatusDb' OUTGOING_dir = 'OUTGOING' db_filepath = 'PROPAGATION_STATUS_DB.txt' script_path = os.path.join(BBSvars.BBS_home, "utils", "makePropagationStatusDb.R") Rexpr = "source('%s');%s('%s','%s','%s')" % \ (script_path, Rfunction, OUTGOING_dir, final_repo, db_filepath) cmd = BBSbase.Rexpr2syscmd(Rexpr) ## Nasty things (that I don't really understand) can happen with ## subprocess.run() if this code is runned by the Task Scheduler ## on Windows (the child process tends to almost always return an ## error). Apparently using 'stderr=subprocess.STDOUT' fixes this pb. subprocess.run(cmd, stdout=None, stderr=subprocess.STDOUT, shell=True, check=True) return
def build_pkg_dep_graph(target_pkgs): # Generate file 'target_pkgs.txt'. 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> [build_pkg_dep_graph]', end=' ') print('%s pkgs written to %s' % (len(target_pkgs), target_pkgs_file)) # Generate file 'pkg_dep_graph.txt'. Rfunction = 'build_pkg_dep_graph' script_path = os.path.join(BBSvars.BBS_home, 'utils', 'build_pkg_dep_graph.R') print('BBS> [build_pkg_dep_graph]', end=' ') print('Calling %s() defined in %s to generate file %s ...' % \ (Rfunction, script_path, BBSutils.pkg_dep_graph_file), end=' ') # Backslashes in the paths injected in 'Rexpr' 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_dep_graph_path2 = BBSutils.pkg_dep_graph_file.replace('\\', '/') # Use short.list=TRUE for "smart STAGE2" i.e. to skip installation of # target packages not needed by another target package for build or check. #Rexpr = "source('%s');%s('%s',outfile='%s',short.list=TRUE)" % \ Rexpr = "source('%s');%s('%s',outfile='%s')" % \ (script_path2, Rfunction, target_pkgs_file2, STAGE2_pkg_dep_graph_path2) out_file = Rfunction + '.Rout' bbs.jobs.runJob(BBSbase.Rexpr2syscmd(Rexpr), out_file) # ignore retcode print('OK') # Send files 'target_pkgs.txt' and 'pkg_dep_graph.txt' to central # build node. BBSvars.Node_rdir.Put(BBSutils.pkg_dep_graph_file, True, True) # Load file 'pkg_dep_graph.txt'. print('BBS> [build_pkg_dep_graph] Loading %s file ...' % \ BBSutils.pkg_dep_graph_file, end=' ') pkg_dep_graph = bbs.parse.load_pkg_dep_graph(BBSutils.pkg_dep_graph_file) print('OK (%s pkgs and their deps loaded)' % len(pkg_dep_graph)) print('BBS> [build_pkg_dep_graph] DONE.') return pkg_dep_graph