Skip to content

Commit a1cbcbb

Browse files
committed
move waitForTargetRepoToBeReady() from BBS-run.py to BBSbase.py
1 parent 17b4643 commit a1cbcbb

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

BBS-run.py

+2-28
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
### This file is part of the BBS software (Bioconductor Build System).
55
###
66
### Author: Hervé Pagès <[email protected]>
7-
### Last modification: May 31, 2023
7+
### Last modification: Dec 11, 2023
88
###
99

1010
import sys
1111
import os
1212
import time
13-
import urllib.request
1413
from functools import lru_cache
1514

1615
import bbs.fileutils
@@ -209,31 +208,6 @@ def getSrcPkgFilesFromSuccessfulSTAGE3(stage_label):
209208
sys.stdout.flush()
210209
return srcpkg_files
211210

212-
def waitForTargetRepoToBeReady():
213-
PACKAGES_url = BBSvars.central_base_url + '/src/contrib/PACKAGES'
214-
nb_attempts = 0
215-
while True:
216-
nb_attempts += 1
217-
try:
218-
f = urllib.request.urlopen(PACKAGES_url)
219-
except urllib.error.HTTPError:
220-
print('BBS> [waitForTargetRepoToBeReady]', end=' ')
221-
print('Unable to access %s. ' % PACKAGES_url + \
222-
'Looks like the target repo is not ready yet!')
223-
else:
224-
break
225-
if nb_attempts == 30:
226-
print('BBS> [waitForTargetRepoToBeReady]', end=' ')
227-
print('FATAL ERROR: was unable to access %s after %d attempts. ' % \
228-
(PACKAGES_url, nb_attempts) + 'Giving up.')
229-
sys.exit('=> EXIT.')
230-
print('BBS> [waitForTargetRepoToBeReady]', end=' ')
231-
print('-> will wait 3 minutes before trying again ...')
232-
sys.stdout.flush()
233-
bbs.jobs.sleep(180.0)
234-
f.close()
235-
return
236-
237211

238212
##############################################################################
239213
## STAGE2: Update ALL packages and re-install target packages + dependencies.
@@ -420,7 +394,7 @@ def STAGE2():
420394
# (if it's not ready yet it probably means that the prerun.sh script did
421395
# not finish on the main node, in which case we want to wait before we
422396
# sync the local meat dir with the central MEAT0 dir).
423-
waitForTargetRepoToBeReady()
397+
BBSbase.waitForTargetRepoToBeReady()
424398
if not BBSvars.no_transmission:
425399
BBSvars.install_rdir.RemakeMe(True)
426400
if BBSvars.synchronous_transmission:

BBSbase.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
## This file is part of the BBS software (Bioconductor Build System).
44
##
55
## Author: Hervé Pagès <[email protected]>
6-
## Last modification: Nov 22, 2023
6+
## Last modification: Dec 11, 2023
77
##
88

99
import sys
1010
import os
1111
import tarfile
12+
import urllib.request
1213

1314
import bbs.fileutils
1415
import bbs.parse
@@ -65,6 +66,31 @@ def injectFieldsIntoMeat(meat_path, target_pkgs):
6566
print('OK')
6667
return
6768

69+
def waitForTargetRepoToBeReady():
70+
PACKAGES_url = BBSvars.central_base_url + '/src/contrib/PACKAGES'
71+
nb_attempts = 0
72+
while True:
73+
nb_attempts += 1
74+
try:
75+
f = urllib.request.urlopen(PACKAGES_url)
76+
except urllib.error.HTTPError:
77+
print('BBS> [waitForTargetRepoToBeReady]', end=' ')
78+
print('Unable to access %s. ' % PACKAGES_url + \
79+
'Looks like the target repo is not ready yet!')
80+
else:
81+
break
82+
if nb_attempts == 30:
83+
print('BBS> [waitForTargetRepoToBeReady]', end=' ')
84+
print('FATAL ERROR: was unable to access %s after %d attempts. ' % \
85+
(PACKAGES_url, nb_attempts) + 'Giving up.')
86+
sys.exit('=> EXIT.')
87+
print('BBS> [waitForTargetRepoToBeReady]', end=' ')
88+
print('-> will wait 3 minutes before trying again ...')
89+
sys.stdout.flush()
90+
bbs.jobs.sleep(180.0)
91+
f.close()
92+
return
93+
6894
def cloneCRANstylePkgRepo(contrib_url, destdir, update_only=False):
6995
print('BBS> Start cloning CRAN-style package repo %s/ to %s/ ...' % \
7096
(contrib_url, destdir))

0 commit comments

Comments
 (0)