Skip to content

Commit 6271611

Browse files
committed
more small tweaks
1 parent c0e1cb4 commit 6271611

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

BBS-make-PROPAGATION_STATUS_DB.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
### This file is part of the BBS software (Bioconductor Build System).
55
###
66
### Author: Hervé Pagès <hpages.on.github@gmail.com>
7-
### Last modification: May 24, 2021
7+
### Last modification: Nov 22, 2023
88
###
99

1010
import sys
@@ -17,15 +17,20 @@
1717
import BBSbase
1818

1919
def make_PROPAGATION_STATUS_DB(final_repo):
20-
Rfunction = 'makePropagationStatusDb'
20+
## Prepare Rexpr (must be a single string with no spaces).
21+
Rscript_path = os.path.join(BBSvars.BBS_home,
22+
'utils',
23+
'makePropagationStatusDb.R')
24+
Rfun = 'makePropagationStatusDb'
2125
OUTGOING_dir = 'OUTGOING'
2226
db_filepath = 'PROPAGATION_STATUS_DB.txt'
23-
script_path = os.path.join(BBSvars.BBS_home,
24-
"utils",
25-
"makePropagationStatusDb.R")
26-
Rexpr = "source('%s');%s('%s','%s',db_filepath='%s')" % \
27-
(script_path, Rfunction, OUTGOING_dir, final_repo, db_filepath)
27+
Rfuncall = "%s('%s','%s',db_filepath='%s')" % \
28+
(Rfun, OUTGOING_dir, final_repo, db_filepath)
29+
Rexpr = "source('%s');%s" % (Rscript_path, Rfuncall)
30+
31+
## Turn Rexpr into a system command.
2832
cmd = BBSbase.Rexpr2syscmd(Rexpr)
33+
2934
try:
3035
## Nasty things (that I don't really understand) can happen with
3136
## subprocess.run() if this code is runned by the Task Scheduler

BBSbase.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### This file is part of the BBS software (Bioconductor Build System).
44
###
55
### Author: Hervé Pagès <hpages.on.github@gmail.com>
6-
### Last modification: Oct 6, 2020
6+
### Last modification: Nov 22, 2023
77
###
88

99
import sys
@@ -124,17 +124,21 @@ def extractLocalCRANstylePkgRepo(contrib_path, destdir):
124124
print('OK')
125125
return
126126

127-
# The R expression passed thru 'Rexpr' must NOT contain spaces or it will
128-
# break on Windows!
127+
# 'Rexpr' must be a single string containing an R expression. It should NOT
128+
# contain spaces or it will break on Windows!
129129
def Rexpr2syscmd(Rexpr):
130-
if BBSvars.rscript_cmd == None:
131-
if sys.platform == 'win32':
130+
if sys.platform == 'win32':
131+
# We can't put quotes around Rexpr on Windows. This means that we
132+
# can't have spaces in Rexpr.
133+
if Rexpr.find(' ') >= 0:
134+
sys.exit("ERROR in Rexpr2syscmd(): 'Rexpr' contains spaces!")
135+
if BBSvars.rscript_cmd == None:
132136
syscmd = 'echo %s | %s --no-echo' % (Rexpr, BBSvars.r_cmd)
133137
else:
134-
syscmd = 'echo "%s" | %s --no-echo' % (Rexpr, BBSvars.r_cmd)
135-
else:
136-
if sys.platform == 'win32':
137138
syscmd = '%s -e %s' % (BBSvars.rscript_cmd, Rexpr)
139+
else:
140+
if BBSvars.rscript_cmd == None:
141+
syscmd = 'echo "%s" | %s --no-echo' % (Rexpr, BBSvars.r_cmd)
138142
else:
139143
syscmd = '%s -e "%s"' % (BBSvars.rscript_cmd, Rexpr)
140144
return syscmd

propagation/BBS-deploy-books.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def _deploy_book(pkg, version, dest_dir):
1717
print("Deploying content from book tarball '%s' to '%s/' ..." % \
1818
(srcpkg_file, dest_subdir), end=' ')
1919
sys.stdout.flush()
20+
shutil.rmtree(pkg, ignore_errors=True) # if leftover from previous run
2021
if not os.path.exists(srcpkg_file):
2122
errmsg = "oops.. couldn't find book tarball '%s' " % srcpkg_file + \
2223
"in\ndirectory:\n\n %s\n\n" % os.getcwd() + \

0 commit comments

Comments
 (0)