-
Notifications
You must be signed in to change notification settings - Fork 11
/
pypeit_syncraw
executable file
·98 lines (74 loc) · 2.8 KB
/
pypeit_syncraw
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3
#
# See top-level LICENSE.rst file for Copyright information
#
# -*- coding: utf-8 -*-
"""
This script runs the PypeIt development suite of tests
"""
import shutil
import os
import subprocess
from pkg_resources import resource_filename
from IPython import embed
def parser(options=None):
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
description='Sync/copy the RAW_DATA')
parser.add_argument('developer', type=str, default=None, help='Developer (jxp)')
parser.add_argument('-c', '--copy', default=False, action='store_true',
help='Use copy instead of sync')
parser.add_argument('-d', '--dryrun', default=False, action='store_true',
help='Only list the steps')
parser.add_argument('-p', '--print', default=False, action='store_true',
help='Print the command')
return parser.parse_args() if options is None else parser.parse_args(options)
def main():
pargs = parser()
if pargs.copy:
command = 'copy'
else:
command = 'sync'
#
if pargs.developer == 'jxp':
raw_path = 'GoogleDrive:Astronomy/UCO/PypeIt/PypeIt-development-suite/RAW_DATA'
calib_path = 'GoogleDrive:Astronomy/UCO/PypeIt/Calibrations'
elif pargs.developer == 'rjc':
raw_path = 'PypeIt:RAW_DATA'
calib_path = None
elif pargs.developer == 'jfh':
raw_path = '/mnt/quasar/joe/google_drive/PypeIt-development-suite/RAW_DATA'
calib_path = None
# Do it
praw = ['rclone', command, raw_path, 'RAW_DATA', '-v']
pnires1, pnires2, ptell, ptell2 = None, None, None, None
if calib_path is not None:
# Tellurics
ptell = ['rclone', command, calib_path+'/Telluric', 'Telluric', '-v']
tell_path = os.path.join(resource_filename('pypeit', 'data'), 'telluric')
ptell2 = ['mv', 'Telluric/*.*', tell_path]
if pargs.dryrun:
for p in [praw, pnires1, ptell]:
if p is None:
continue
p += ['--dry-run']
for p in [praw, pnires1, pnires2, ptell, ptell2]:
if p is None:
continue
# Only execute these if the clone was performed
if p in [pnires2, ptell2] and pargs.dryrun:
continue
if pargs.print:
print(' '.join(p))
return
subprocess.run(p, check=True)
# Clean up?
if ptell is not None:
shutil.rmtree('Telluric/')
if __name__ == '__main__':
# Check for rclone
if not any([os.access(os.path.join(path, 'rclone'), os.X_OK)
for path in os.environ["PATH"].split(os.pathsep)]):
raise RuntimeError("You need to install rclone in your PATH")
# Giddy up
main()