-
Notifications
You must be signed in to change notification settings - Fork 0
/
slowRepoMaker.py
42 lines (34 loc) · 1.27 KB
/
slowRepoMaker.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
import glob
import os.path
from time import sleep
import shutil
import subprocess
class NewImages():
pauseLength = 10
def __init__(self, repoDir, dataGlob, clobber=False):
self.repoDir = repoDir
self.clobber = clobber
self.files = sorted([os.path.abspath(f) for f in glob.glob(dataGlob)])
def _preRun(self):
if os.path.exists(self.repoDir):
if self.clobber:
shutil.rmtree(repoDir)
os.makedirs(repoDir)
else:
raise RuntimeError(f"Path {repoDir} already exists - please use clobber=True to recreate")
else:
os.makedirs(repoDir)
with open(os.path.join(repoDir, "_mapper"), "w") as f:
f.write("lsst.obs.lsst.auxTel.AuxTelMapper")
def run(self):
self._preRun()
for filename in self.files[0:500]:
args = f" ingestImages.py {repoDir} {filename} --mode=link"
print(args)
ret = subprocess.check_output(args.split(), universal_newlines=True)
sleep(self.pauseLength)
if __name__ == "__main__":
dataGlob = '/project/shared/auxTel/_parent/raw/2020-01-28/*.fits'
repoDir = '/home/mfl/newImageRepo/'
repoMaker = NewImages(repoDir, dataGlob, clobber=True)
repoMaker.run()