|
3 | 3 | import importlib |
4 | 4 | import io |
5 | 5 | import os |
| 6 | +import shutil |
| 7 | +from datetime import datetime, timezone |
6 | 8 | from typing import Any, List, Tuple |
7 | 9 |
|
8 | 10 | from configobj import ConfigObj |
@@ -42,18 +44,36 @@ def main(): |
42 | 44 | _validate_config(config) |
43 | 45 | # Add templateDir to config |
44 | 46 | config["default"]["templateDir"] = template_dir |
| 47 | + # Get timestamp for provenance |
| 48 | + # Provenance cfg will be placed in both `output` and `www` |
| 49 | + ts_utc = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S_%f") |
45 | 50 | # Output script directory |
46 | 51 | output = config["default"]["output"] |
47 | 52 | username = os.environ.get("USER") |
48 | 53 | output = output.replace("$USER", username) |
49 | 54 | script_dir = os.path.join(output, "post/scripts") |
50 | 55 | job_ids_file = os.path.join(script_dir, "jobids.txt") |
| 56 | + provenance = os.path.join(script_dir, f"provenance.{ts_utc}.cfg") |
51 | 57 | try: |
52 | 58 | os.makedirs(script_dir) |
| 59 | + shutil.copy(args.config, provenance) |
53 | 60 | except OSError as exc: |
54 | 61 | if exc.errno != errno.EEXIST: |
55 | 62 | raise OSError("Cannot create script directory") |
56 | 63 | pass |
| 64 | + # Web output directory |
| 65 | + www = config["default"]["www"] |
| 66 | + username = os.environ.get("USER") |
| 67 | + www = www.replace("$USER", username) |
| 68 | + www_case_dir = os.path.join(www, config["default"]["case"]) |
| 69 | + provenance = os.path.join(www_case_dir, f"provenance.{ts_utc}.cfg") |
| 70 | + try: |
| 71 | + os.makedirs(www_case_dir) |
| 72 | + shutil.copy(args.config, provenance) |
| 73 | + except OSError as exc: |
| 74 | + if exc.errno != errno.EEXIST: |
| 75 | + raise OSError("Cannot create www case directory") |
| 76 | + pass |
57 | 77 | machine_info = _get_machine_info(config) |
58 | 78 | config = _determine_parameters(machine_info, config) |
59 | 79 | if args.last_year: |
|
0 commit comments