-
Notifications
You must be signed in to change notification settings - Fork 11
/
BBS-make-PROPAGATION_STATUS_DB.py
executable file
·69 lines (60 loc) · 2.45 KB
/
BBS-make-PROPAGATION_STATUS_DB.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
##############################################################################
###
### This file is part of the BBS software (Bioconductor Build System).
###
### Author: Hervé Pagès <[email protected]>
### Last modification: Nov 22, 2023
###
import sys
import os
import time
import subprocess
import BBSutils
import BBSvars
import BBSbase
def make_PROPAGATION_STATUS_DB(final_repo):
## Prepare Rexpr (must be a single string with no spaces).
Rscript_path = os.path.join(BBSvars.BBS_home,
'utils',
'makePropagationStatusDb.R')
Rfun = 'makePropagationStatusDb'
OUTGOING_dir = 'OUTGOING'
db_filepath = 'PROPAGATION_STATUS_DB.txt'
Rfuncall = "%s('%s','%s',db_filepath='%s')" % \
(Rfun, OUTGOING_dir, final_repo, db_filepath)
Rexpr = "source('%s');%s" % (Rscript_path, Rfuncall)
## Turn Rexpr into a system command.
cmd = BBSbase.Rexpr2syscmd(Rexpr)
try:
## 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)
except subprocess.CalledProcessError as e:
BBSbase.kindly_notify_us('Postrun', e)
raise e
return
##############################################################################
### MAIN SECTION
##############################################################################
if __name__ == "__main__":
argc = len(sys.argv)
if argc > 1:
final_repo = sys.argv[1]
else:
final_repo = BBSutils.getenv('BBS_FINAL_REPO')
print()
if not os.path.isdir('OUTGOING'):
print('mmh.. I don\'t see the \'OUTGOING\' subdirectory ' + \
'in the current directory!')
print('Make sure to be in \'%s/\' ' % BBSvars.Central_rdir.path)
print('before running the BBS-make-PROPAGATION_STATUS_DB.py script.')
sys.exit('=> EXIT.')
print('BBS> ==============================================================')
print('BBS> [stage6c] STARTING stage6c on %s...' % time.asctime())
sys.stdout.flush()
make_PROPAGATION_STATUS_DB(final_repo)
print('BBS> [stage6c] DONE on %s.' % time.asctime())