|
29 | 29 | """Provide data access object to the suite runtime database for Cylc Review.""" |
30 | 30 |
|
31 | 31 |
|
| 32 | +def get_prefix(user_name): |
| 33 | + """Return user "home" dir under $CYLC_REVIEW_HOME, or else ~user_name.""" |
| 34 | + if os.environ.get('CYLC_REVIEW_HOME', False) and user_name: |
| 35 | + prefix = os.path.join( |
| 36 | + os.environ['CYLC_REVIEW_HOME'], |
| 37 | + str(user_name) |
| 38 | + ) |
| 39 | + else: |
| 40 | + prefix = "~" |
| 41 | + if user_name: |
| 42 | + prefix += user_name |
| 43 | + return prefix |
| 44 | + |
| 45 | + |
32 | 46 | class CylcReviewDAO(object): |
33 | 47 | """Cylc Review data access object to the suite runtime database.""" |
34 | 48 |
|
@@ -108,12 +122,11 @@ def _db_init(self, user_name, suite_name): |
108 | 122 | """Initialise a named CylcSuiteDAO database connection.""" |
109 | 123 | key = (user_name, suite_name) |
110 | 124 | if key not in self.daos: |
111 | | - prefix = "~" |
112 | | - if user_name: |
113 | | - prefix += user_name |
114 | 125 | for name in [os.path.join("log", "db"), "cylc-suite.db"]: |
115 | 126 | db_f_name = os.path.expanduser(os.path.join( |
116 | | - prefix, os.path.join("cylc-run", suite_name, name))) |
| 127 | + get_prefix(user_name), |
| 128 | + os.path.join("cylc-run", |
| 129 | + suite_name, name))) |
117 | 130 | self.daos[key] = CylcSuiteDAO(db_f_name, is_public=True) |
118 | 131 | if os.path.exists(db_f_name): |
119 | 132 | break |
@@ -382,11 +395,8 @@ def _get_job_logs(self, user_name, suite_name, entries, entry_of): |
382 | 395 | relevant entries of that cycle. |
383 | 396 | Modify each entry in entries. |
384 | 397 | """ |
385 | | - prefix = "~" |
386 | | - if user_name: |
387 | | - prefix += user_name |
388 | 398 | user_suite_dir = os.path.expanduser(os.path.join( |
389 | | - prefix, os.path.join("cylc-run", suite_name))) |
| 399 | + get_prefix(user_name), os.path.join("cylc-run", suite_name))) |
390 | 400 | try: |
391 | 401 | fs_log_cycles = os.listdir( |
392 | 402 | os.path.join(user_suite_dir, "log", "job")) |
@@ -519,11 +529,8 @@ def get_suite_cycles_summary( |
519 | 529 | integer_mode = row[0].isdigit() |
520 | 530 | break |
521 | 531 |
|
522 | | - prefix = "~" |
523 | | - if user_name: |
524 | | - prefix += user_name |
525 | 532 | user_suite_dir = os.path.expanduser(os.path.join( |
526 | | - prefix, os.path.join("cylc-run", suite_name))) |
| 533 | + get_prefix(user_name), os.path.join("cylc-run", suite_name))) |
527 | 534 | targzip_log_cycles = [] |
528 | 535 | try: |
529 | 536 | for item in os.listdir(os.path.join(user_suite_dir, "log")): |
|
0 commit comments