rda-python-common 1.0.46__py3-none-any.whl → 1.0.47__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rda-python-common might be problematic. Click here for more details.
- rda_python_common/PgFile.py +56 -36
- rda_python_common/PgLOG.py +32 -27
- rda_python_common/PgOPT.py +2 -2
- rda_python_common/PgSIG.py +2 -2
- {rda_python_common-1.0.46.dist-info → rda_python_common-1.0.47.dist-info}/METADATA +1 -1
- rda_python_common-1.0.47.dist-info/RECORD +15 -0
- rda_python_common-1.0.46.dist-info/RECORD +0 -15
- {rda_python_common-1.0.46.dist-info → rda_python_common-1.0.47.dist-info}/WHEEL +0 -0
- {rda_python_common-1.0.46.dist-info → rda_python_common-1.0.47.dist-info}/licenses/LICENSE +0 -0
- {rda_python_common-1.0.46.dist-info → rda_python_common-1.0.47.dist-info}/top_level.txt +0 -0
rda_python_common/PgFile.py
CHANGED
|
@@ -113,9 +113,9 @@ QHOSTS = {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
ENDPOINTS = {
|
|
116
|
-
'gdex-glade' : "NCAR
|
|
117
|
-
'gdex-quasar' : "NCAR
|
|
118
|
-
'gdex-quasar-drdata' : "NCAR
|
|
116
|
+
'gdex-glade' : "NCAR GDEX GLADE",
|
|
117
|
+
'gdex-quasar' : "NCAR GDEX Quasar",
|
|
118
|
+
'gdex-quasar-drdata' : "NCAR GDEX Quasar DRDATA"
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
BFILES = {} # cache backup file names and dates for each bid
|
|
@@ -163,7 +163,7 @@ def errlog(msg, etype, retry = 0, logact = 0):
|
|
|
163
163
|
#
|
|
164
164
|
# Return 1 if successful 0 if failed with error message generated in PgLOG.pgsystem() cached in PgLOG.PGLOG['SYSERR']
|
|
165
165
|
#
|
|
166
|
-
def
|
|
166
|
+
def copy_gdex_file(tofile, fromfile, tohost = LHOST, fromhost = LHOST, logact = 0):
|
|
167
167
|
|
|
168
168
|
thost = strip_host_name(tohost)
|
|
169
169
|
fhost = strip_host_name(fromhost)
|
|
@@ -192,6 +192,8 @@ def copy_rda_file(tofile, fromfile, tohost = LHOST, fromhost = LHOST, logact = 0
|
|
|
192
192
|
|
|
193
193
|
return errlog("{}-{}->{}-{}: Cannot copy file".format(fhost, fromfile, thost, tofile), 'O', 1, PgLOG.LGEREX)
|
|
194
194
|
|
|
195
|
+
copy_rda_file = copy_gdex_file
|
|
196
|
+
|
|
195
197
|
#
|
|
196
198
|
# Copy a file locally
|
|
197
199
|
#
|
|
@@ -300,7 +302,7 @@ def local_copy_object(tofile, fromfile, bucket = None, meta = None, logact = 0):
|
|
|
300
302
|
if not bucket: bucket = PgLOG.PGLOG['OBJCTBKT']
|
|
301
303
|
if meta is None: meta = {}
|
|
302
304
|
if 'user' not in meta: meta['user'] = PgLOG.PGLOG['CURUID']
|
|
303
|
-
if 'group' not in meta: meta['group'] = PgLOG.PGLOG['
|
|
305
|
+
if 'group' not in meta: meta['group'] = PgLOG.PGLOG['GDEXGRP']
|
|
304
306
|
uinfo = json.dumps(meta)
|
|
305
307
|
|
|
306
308
|
finfo = check_local_file(fromfile, 0, logact)
|
|
@@ -332,7 +334,7 @@ def local_copy_object(tofile, fromfile, bucket = None, meta = None, logact = 0):
|
|
|
332
334
|
# tofiles - target file name list, echo name leading with /dsnnn.n/ on Quasar and
|
|
333
335
|
# leading with /data/ or /decsdata/ on local glade disk
|
|
334
336
|
# fromfiles - source file name list, the same format as the tofiles
|
|
335
|
-
# topoint - target endpoint name, 'gdex-glade', 'gdex-quasar' or 'gdex-quasar-
|
|
337
|
+
# topoint - target endpoint name, 'gdex-glade', 'gdex-quasar' or 'gdex-quasar-dgdexta'
|
|
336
338
|
# frompoint - source endpoint name, the same choices as the topoint
|
|
337
339
|
#
|
|
338
340
|
def quasar_multiple_trasnfer(tofiles, fromfiles, topoint, frompoint, logact = 0):
|
|
@@ -374,7 +376,7 @@ def quasar_multiple_trasnfer(tofiles, fromfiles, topoint, frompoint, logact = 0)
|
|
|
374
376
|
# tofile - target file name, leading with /dsnnn.n/ on Quasar and
|
|
375
377
|
# leading with /data/ or /decsdata/ on local glade disk
|
|
376
378
|
# fromfile - source file, the same format as the tofile
|
|
377
|
-
# topoint - target endpoint name, 'gdex-glade', 'gdex-quasar' or 'gdex-quasar-
|
|
379
|
+
# topoint - target endpoint name, 'gdex-glade', 'gdex-quasar' or 'gdex-quasar-dgdexta'
|
|
378
380
|
# frompoint - source endpoint name, the same choices as the topoint
|
|
379
381
|
#
|
|
380
382
|
def endpoint_copy_endpoint(tofile, fromfile, topoint, frompoint, logact = 0):
|
|
@@ -689,7 +691,7 @@ def object_copy_remote(tofile, fromfile, host, bucket = None, logact = 0):
|
|
|
689
691
|
#
|
|
690
692
|
# Return 1 if successful 0 if failed with error message generated in PgLOG.pgsystem() cached in PgLOG.PGLOG['SYSERR']
|
|
691
693
|
#
|
|
692
|
-
def
|
|
694
|
+
def delete_gdex_file(file, host, logact = 0):
|
|
693
695
|
|
|
694
696
|
shost = strip_host_name(host)
|
|
695
697
|
if PgUtil.pgcmp(shost, LHOST, 1) == 0:
|
|
@@ -699,6 +701,8 @@ def delete_rda_file(file, host, logact = 0):
|
|
|
699
701
|
else:
|
|
700
702
|
return delete_remote_file(file, host, logact)
|
|
701
703
|
|
|
704
|
+
delete_rda_file = delete_gdex_file
|
|
705
|
+
|
|
702
706
|
#
|
|
703
707
|
# Delete a local file/irectory
|
|
704
708
|
#
|
|
@@ -784,7 +788,7 @@ def delete_backup_file(file, endpoint = None, logact = 0):
|
|
|
784
788
|
return PgLOG.FAILURE
|
|
785
789
|
|
|
786
790
|
#
|
|
787
|
-
# reset local file/directory information to make them writable for PgLOG.PGLOG['
|
|
791
|
+
# reset local file/directory information to make them writable for PgLOG.PGLOG['GDEXUSER']
|
|
788
792
|
# file - file name (mandatory)
|
|
789
793
|
# info - gathered file info with option 14, None means file not exists
|
|
790
794
|
#
|
|
@@ -817,8 +821,8 @@ def reset_local_directory(dir, info = None, logact = 0):
|
|
|
817
821
|
if info:
|
|
818
822
|
if info['mode'] and info['mode'] != 0o775:
|
|
819
823
|
ret += set_local_mode(dir, 0, 0o775, info['mode'], info['logname'], logact)
|
|
820
|
-
if info['group'] and PgLOG.PGLOG['
|
|
821
|
-
ret += change_local_group(dir, PgLOG.PGLOG['
|
|
824
|
+
if info['group'] and PgLOG.PGLOG['GDEXGRP'] != info['group']:
|
|
825
|
+
ret += change_local_group(dir, PgLOG.PGLOG['GDEXGRP'], info['group'], info['logname'], logact)
|
|
822
826
|
|
|
823
827
|
return 1 if ret else 0
|
|
824
828
|
|
|
@@ -833,8 +837,8 @@ def reset_local_file(file, info = None, logact = 0):
|
|
|
833
837
|
if info:
|
|
834
838
|
if info['mode'] != 0o664:
|
|
835
839
|
ret += set_local_mode(file, 1, 0o664, info['mode'], info['logname'], logact)
|
|
836
|
-
if PgLOG.PGLOG['
|
|
837
|
-
ret += change_local_group(file, PgLOG.PGLOG['
|
|
840
|
+
if PgLOG.PGLOG['GDEXGRP'] != info['group']:
|
|
841
|
+
ret += change_local_group(file, PgLOG.PGLOG['GDEXGRP'], info['group'], info['logname'], logact)
|
|
838
842
|
|
|
839
843
|
return ret
|
|
840
844
|
|
|
@@ -847,7 +851,7 @@ def reset_local_file(file, info = None, logact = 0):
|
|
|
847
851
|
#
|
|
848
852
|
# Return PgLOG.SUCCESS if successful PgLOG.FAILURE otherwise
|
|
849
853
|
#
|
|
850
|
-
def
|
|
854
|
+
def move_gdex_file(tofile, fromfile, host, logact = 0):
|
|
851
855
|
|
|
852
856
|
shost = strip_host_name(host)
|
|
853
857
|
if PgUtil.pgcmp(shost, LHOST, 1) == 0:
|
|
@@ -857,6 +861,8 @@ def move_rda_file(tofile, fromfile, host, logact = 0):
|
|
|
857
861
|
else:
|
|
858
862
|
return move_remote_file(tofile, fromfile, host, logact)
|
|
859
863
|
|
|
864
|
+
move_rda_file = move_gdex_file
|
|
865
|
+
|
|
860
866
|
#
|
|
861
867
|
# Move a file locally
|
|
862
868
|
#
|
|
@@ -1071,7 +1077,7 @@ def move_backup_file(tofile, fromfile, endpoint = None, logact = 0):
|
|
|
1071
1077
|
#
|
|
1072
1078
|
# Return PgLOG.SUCCESS(1) if successful or PgLOG.FAILURE(0) if failed
|
|
1073
1079
|
#
|
|
1074
|
-
def
|
|
1080
|
+
def make_gdex_directory(dir, host, logact = 0):
|
|
1075
1081
|
|
|
1076
1082
|
if not dir: return PgLOG.SUCCESS
|
|
1077
1083
|
shost = strip_host_name(host)
|
|
@@ -1080,6 +1086,8 @@ def make_rda_directory(dir, host, logact = 0):
|
|
|
1080
1086
|
else:
|
|
1081
1087
|
return make_remote_directory(dir, host, logact)
|
|
1082
1088
|
|
|
1089
|
+
make_rda_directory = make_gdex_directory
|
|
1090
|
+
|
|
1083
1091
|
#
|
|
1084
1092
|
# Make a local directory
|
|
1085
1093
|
#
|
|
@@ -1239,7 +1247,7 @@ def is_root_directory(dir, etype, host = None, action = None, logact = 0):
|
|
|
1239
1247
|
#
|
|
1240
1248
|
# set mode for a given direcory/file on a given host (include local host)
|
|
1241
1249
|
#
|
|
1242
|
-
def
|
|
1250
|
+
def set_gdex_mode(file, isfile, host, nmode = None, omode = None, logname = None, logact = 0):
|
|
1243
1251
|
|
|
1244
1252
|
shost = strip_host_name(host)
|
|
1245
1253
|
if PgUtil.pgcmp(shost, LHOST, 1) == 0:
|
|
@@ -1247,6 +1255,8 @@ def set_rda_mode(file, isfile, host, nmode = None, omode = None, logname = None,
|
|
|
1247
1255
|
else:
|
|
1248
1256
|
return set_remote_mode(file, isfile, host, nmode, omode, logact)
|
|
1249
1257
|
|
|
1258
|
+
set_rda_mode = set_gdex_mode
|
|
1259
|
+
|
|
1250
1260
|
#
|
|
1251
1261
|
# set mode for given local directory or file
|
|
1252
1262
|
#
|
|
@@ -1292,7 +1302,7 @@ def set_remote_mode(file, isfile, host, nmode = 0, omode = 0, logact = 0):
|
|
|
1292
1302
|
def change_local_group(file, ngrp = None, ogrp = None, logname = None, logact = 0):
|
|
1293
1303
|
|
|
1294
1304
|
if not ngrp:
|
|
1295
|
-
ngid = PgLOG.PGLOG['
|
|
1305
|
+
ngid = PgLOG.PGLOG['GDEXGID']
|
|
1296
1306
|
else:
|
|
1297
1307
|
ngid = grp.getgrnam[ngrp].gr_gid
|
|
1298
1308
|
if logact and logact&PgLOG.EXITLG: logact &=~PgLOG.EXITLG
|
|
@@ -1455,7 +1465,7 @@ def check_service_accessibilty(sname, fhost = None, logact = 0):
|
|
|
1455
1465
|
if not fhost: fhost = PgLOG.PGLOG['HOSTNAME']
|
|
1456
1466
|
pgrec = PgDBI.pgget("dsservice", "*", "service = '{}' AND hostname = '{}'".format(sname, fhost), logact)
|
|
1457
1467
|
if not pgrec:
|
|
1458
|
-
PgLOG.pglog("dsservice: Access {} from {} is not defined in
|
|
1468
|
+
PgLOG.pglog("dsservice: Access {} from {} is not defined in GDEX Configuration".format(sname, fhost), logact)
|
|
1459
1469
|
return -1
|
|
1460
1470
|
|
|
1461
1471
|
path = sname if (pgrec['flag'] == "H" or pgrec['flag'] == "G") else None
|
|
@@ -1484,7 +1494,7 @@ def local_host_action(host, action, info, logact = 0):
|
|
|
1484
1494
|
if host == "partition":
|
|
1485
1495
|
msg = "for individual partition"
|
|
1486
1496
|
elif host == "rda_config":
|
|
1487
|
-
msg = "via https://gdex.ucar.edu/
|
|
1497
|
+
msg = "via https://gdex.ucar.edu/rda_pg_config"
|
|
1488
1498
|
elif host in PgLOG.BCHCMDS:
|
|
1489
1499
|
msg = "on a {} Node".format(host)
|
|
1490
1500
|
else:
|
|
@@ -1555,7 +1565,7 @@ def strip_host_name(host):
|
|
|
1555
1565
|
#
|
|
1556
1566
|
# Return a dict of file info, or None if file not exists
|
|
1557
1567
|
#
|
|
1558
|
-
def
|
|
1568
|
+
def check_gdex_file(file, host = LHOST, opt = 0, logact = 0):
|
|
1559
1569
|
|
|
1560
1570
|
shost = strip_host_name(host)
|
|
1561
1571
|
|
|
@@ -1570,6 +1580,8 @@ def check_rda_file(file, host = LHOST, opt = 0, logact = 0):
|
|
|
1570
1580
|
else:
|
|
1571
1581
|
return check_remote_file(file, host, opt, logact)
|
|
1572
1582
|
|
|
1583
|
+
check_rda_file = check_gdex_file
|
|
1584
|
+
|
|
1573
1585
|
#
|
|
1574
1586
|
# wrapper to check_local_file() and check_globus_file() to check info for a file
|
|
1575
1587
|
# on local or remote Globus endpoints
|
|
@@ -1686,7 +1698,7 @@ def local_path_size(pname):
|
|
|
1686
1698
|
# file: remote File name
|
|
1687
1699
|
# opt: 0 - get data size only (fname, data_size, isfile), fname is the file basename
|
|
1688
1700
|
# 1 - get date/time modified (date_modified, time_modfied)
|
|
1689
|
-
# 2 - file owner's login name (logname), assumed '
|
|
1701
|
+
# 2 - file owner's login name (logname), assumed 'gdexdata'
|
|
1690
1702
|
# 4 - get permission mode in 3 octal digits (mode)
|
|
1691
1703
|
# 8 - get group name (group), assumed 'dss'
|
|
1692
1704
|
# 16 - get week day 0-Sunday, 1-Monday (week_day)
|
|
@@ -1743,8 +1755,8 @@ def remote_file_stat(line, opt):
|
|
|
1743
1755
|
info['time_modified'] = mtime
|
|
1744
1756
|
if opt&16: info['week_day'] = PgUtil.get_weekday(mdate)
|
|
1745
1757
|
|
|
1746
|
-
if opt&2: info['logname'] = "
|
|
1747
|
-
if opt&8: info['group'] = PgLOG.PGLOG['
|
|
1758
|
+
if opt&2: info['logname'] = "gdexdata"
|
|
1759
|
+
if opt&8: info['group'] = PgLOG.PGLOG['GDEXGRP']
|
|
1748
1760
|
|
|
1749
1761
|
return info
|
|
1750
1762
|
|
|
@@ -2100,7 +2112,7 @@ def ftp_file_stat(line, opt):
|
|
|
2100
2112
|
#
|
|
2101
2113
|
# Return: a dict with filenames as keys None if empty directory
|
|
2102
2114
|
#
|
|
2103
|
-
def
|
|
2115
|
+
def gdex_glob(dir, host, opt = 0, logact = 0):
|
|
2104
2116
|
|
|
2105
2117
|
shost = strip_host_name(host)
|
|
2106
2118
|
if PgUtil.pgcmp(shost, LHOST, 1) == 0:
|
|
@@ -2112,6 +2124,8 @@ def rda_glob(dir, host, opt = 0, logact = 0):
|
|
|
2112
2124
|
else:
|
|
2113
2125
|
return remote_glob(dir, host, opt, logact)
|
|
2114
2126
|
|
|
2127
|
+
rda_glob = gdex_glob
|
|
2128
|
+
|
|
2115
2129
|
#
|
|
2116
2130
|
# get an array of directories/files under given dir on local host
|
|
2117
2131
|
#
|
|
@@ -2151,7 +2165,7 @@ def local_glob(dir, opt = 0, logact = 0):
|
|
|
2151
2165
|
# host: host name the directory on, default to LHOST
|
|
2152
2166
|
# opt: 0 - get data size only (fname, data_size, isfile), fname is the file basename
|
|
2153
2167
|
# 1 - get date/time modified (date_modified, time_modfied)
|
|
2154
|
-
# 2 - file owner's login name (logname), assumed '
|
|
2168
|
+
# 2 - file owner's login name (logname), assumed 'gdexdata'
|
|
2155
2169
|
# 4 - get permission mode in 3 octal digits (mode)
|
|
2156
2170
|
# 8 - get group name (group), assumed 'dss'
|
|
2157
2171
|
# 16 - get week day 0-Sunday, 1-Monday (week_day)
|
|
@@ -2409,9 +2423,9 @@ def clean_delete_directory(logact = 0):
|
|
|
2409
2423
|
for dir in DELDIRS:
|
|
2410
2424
|
host = DELDIRS[dir]
|
|
2411
2425
|
dinfo = (dir if host == LHOST else "{}-{}".format(host, dir))
|
|
2412
|
-
dstat =
|
|
2426
|
+
dstat = gdex_empty_directory(dir, DELDIRS[dir])
|
|
2413
2427
|
if dstat == 0:
|
|
2414
|
-
if
|
|
2428
|
+
if delete_gdex_file(dir, host, logact):
|
|
2415
2429
|
PgLOG.pglog(dinfo + ": Empty directory removed", lact)
|
|
2416
2430
|
elif dstat > 0:
|
|
2417
2431
|
if dstat == 1 and lvl > 0: PgLOG.pglog(dinfo + ": Directory not empty yet", lact)
|
|
@@ -2433,7 +2447,7 @@ def clean_empty_directory(dir, host, logact = 0):
|
|
|
2433
2447
|
|
|
2434
2448
|
if not dir: return 0
|
|
2435
2449
|
|
|
2436
|
-
dirs =
|
|
2450
|
+
dirs = gdex_glob(dir, host)
|
|
2437
2451
|
cnt = 0
|
|
2438
2452
|
if logact:
|
|
2439
2453
|
lact = logact&~PgLOG.EXITLG
|
|
@@ -2448,7 +2462,7 @@ def clean_empty_directory(dir, host, logact = 0):
|
|
|
2448
2462
|
|
|
2449
2463
|
dinfo = (dir if same_hosts(host, LHOST) else "{}-{}".format(host, dir))
|
|
2450
2464
|
if cnt == 0:
|
|
2451
|
-
if
|
|
2465
|
+
if delete_gdex_file(dir, host, logact):
|
|
2452
2466
|
PgLOG.pglog(dinfo + ": Empty directory removed", lact)
|
|
2453
2467
|
return 1
|
|
2454
2468
|
else:
|
|
@@ -2462,7 +2476,7 @@ def clean_empty_directory(dir, host, logact = 0):
|
|
|
2462
2476
|
#
|
|
2463
2477
|
# Return: 0 if empty directory, 1 if not empty and -1 if invalid directory
|
|
2464
2478
|
#
|
|
2465
|
-
def
|
|
2479
|
+
def gdex_empty_directory(dir, host):
|
|
2466
2480
|
|
|
2467
2481
|
shost = strip_host_name(host)
|
|
2468
2482
|
|
|
@@ -2471,6 +2485,8 @@ def rda_empty_directory(dir, host):
|
|
|
2471
2485
|
else:
|
|
2472
2486
|
return remote_empty_directory(dir, host)
|
|
2473
2487
|
|
|
2488
|
+
rda_empty_directory = gdex_empty_directory
|
|
2489
|
+
|
|
2474
2490
|
#
|
|
2475
2491
|
# return 0 if empty local directory, 1 if not; -1 if cannot remove
|
|
2476
2492
|
#
|
|
@@ -2505,13 +2521,15 @@ def remote_empty_directory(dir, host):
|
|
|
2505
2521
|
#
|
|
2506
2522
|
# return: array of file sizes size is -1 if file does not exist
|
|
2507
2523
|
#
|
|
2508
|
-
def
|
|
2524
|
+
def gdex_file_sizes(files, host, logact = 0):
|
|
2509
2525
|
|
|
2510
2526
|
sizes = []
|
|
2511
|
-
for file in files: sizes.append(
|
|
2527
|
+
for file in files: sizes.append(gdex_file_size(file, host, 2, logact))
|
|
2512
2528
|
|
|
2513
2529
|
return sizes
|
|
2514
2530
|
|
|
2531
|
+
rda_file_sizes = gdex_file_sizes
|
|
2532
|
+
|
|
2515
2533
|
#
|
|
2516
2534
|
# get sizes of local files
|
|
2517
2535
|
#
|
|
@@ -2540,15 +2558,15 @@ def local_file_sizes(files, logact = 0):
|
|
|
2540
2558
|
# -1 - file not exists
|
|
2541
2559
|
# -2 - error check file
|
|
2542
2560
|
#
|
|
2543
|
-
def
|
|
2561
|
+
def gdex_file_size(file, host, opt = 0, logact = 0):
|
|
2544
2562
|
|
|
2545
|
-
info =
|
|
2563
|
+
info = check_gdex_file(file, host, 0, logact)
|
|
2546
2564
|
if info:
|
|
2547
2565
|
if info['isfile'] and info['data_size'] < PgLOG.PGLOG['MINSIZE']:
|
|
2548
2566
|
if opt:
|
|
2549
2567
|
if opt&2: errlog("{}-{}: {} file".format(host, file, ("Too small({}B)".format(info['data_size']) if info['data_size'] > 0 else "Empty")),
|
|
2550
2568
|
'O', 1, logact)
|
|
2551
|
-
if opt&1:
|
|
2569
|
+
if opt&1: delete_gdex_file(file, host, logact)
|
|
2552
2570
|
return 0
|
|
2553
2571
|
else:
|
|
2554
2572
|
return info['data_size'] # if not regular file or not empty
|
|
@@ -2559,6 +2577,8 @@ def rda_file_size(file, host, opt = 0, logact = 0):
|
|
|
2559
2577
|
if opt&4: errlog("{}-{}: {}".format(host, file, PgLOG.PGLOG['MISSFILE']), 'O', 1, logact)
|
|
2560
2578
|
return -1 # file not exist
|
|
2561
2579
|
|
|
2580
|
+
rda_file_size = gdex_file_size
|
|
2581
|
+
|
|
2562
2582
|
#
|
|
2563
2583
|
# check if a local file is empty or too small to be considered valid
|
|
2564
2584
|
#
|
|
@@ -3049,7 +3069,7 @@ def check_storage_dflags(dflags, dscheck = None, logact = 0):
|
|
|
3049
3069
|
return msgary
|
|
3050
3070
|
|
|
3051
3071
|
#
|
|
3052
|
-
# check a
|
|
3072
|
+
# check a GDEX file is backed up or not for given file record;
|
|
3053
3073
|
# clear the cached bfile records if frec is None.
|
|
3054
3074
|
# return 0 if not yet, 1 if backed up, or -1 if backed up but modified
|
|
3055
3075
|
#
|
rda_python_common/PgLOG.py
CHANGED
|
@@ -59,7 +59,7 @@ MISLOG = (0x00811) # cannot access logfile
|
|
|
59
59
|
EMLSUM = (0x08000) # record as email summary
|
|
60
60
|
EMEROL = (0x10000) # record error as email only
|
|
61
61
|
EMLALL = (0x1D208) # all email acts
|
|
62
|
-
DOSUDO = (0x20000) # add 'sudo -u PGLOG['
|
|
62
|
+
DOSUDO = (0x20000) # add 'sudo -u PGLOG['GDEXUSER']'
|
|
63
63
|
NOTLOG = (0x40000) # do not log any thing
|
|
64
64
|
OVRIDE = (0x80000) # do override existing file or record
|
|
65
65
|
NOWAIT = (0x100000) # do not wait on globus task to finish
|
|
@@ -99,9 +99,9 @@ PGLOG = { # more defined in untaint_suid() with environment variables
|
|
|
99
99
|
'BACKROOT': "/DRDATA/DECS", # backup path for desaster recovering tape on hpss
|
|
100
100
|
'OLDAROOT': "/FS/DSS", # old root path on hpss
|
|
101
101
|
'OLDBROOT': "/DRDATA/DSS", # old backup tape on hpss
|
|
102
|
-
'
|
|
103
|
-
'
|
|
104
|
-
'
|
|
102
|
+
'GDEXUSER' : "gdexdata", # common gdex user name
|
|
103
|
+
'GDEXEMAIL' : "zji", # specialist to receipt email intead of common gdex user name
|
|
104
|
+
'SUDOGDEX' : 0, # 1 to allow sudo to PGLOG['GDEXUSER']
|
|
105
105
|
'HOSTNAME' : '', # current host name the process in running on
|
|
106
106
|
'OBJCTSTR' : "object",
|
|
107
107
|
'BACKUPNM' : "quasar",
|
|
@@ -121,7 +121,7 @@ PGLOG = { # more defined in untaint_suid() with environment variables
|
|
|
121
121
|
'SLMTIME' : 604800, # max runtime for SLURM bath job, (7x24x60x60 seconds)
|
|
122
122
|
'PBSTIME' : 86400, # max runtime for PBS bath job, (24x60x60 seconds)
|
|
123
123
|
'MSSGRP' : None, # set if set to different HPSS group
|
|
124
|
-
'
|
|
124
|
+
'GDEXGRP' : "decs",
|
|
125
125
|
'EMLSEND' : None, # path to sendmail, None if not exists
|
|
126
126
|
'DSCHECK' : None, # carry some cached dscheck information
|
|
127
127
|
'PGDBBUF' : None, # reference to a connected database object
|
|
@@ -139,6 +139,11 @@ PGLOG = { # more defined in untaint_suid() with environment variables
|
|
|
139
139
|
'EMLPORT' : 25
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
PGLOG['RDAUSER'] = PGLOG['GDEXUSER']
|
|
143
|
+
PGLOG['RDAGRP'] = PGLOG['GDEXGRP']
|
|
144
|
+
PGLOG['RDAEMAIL'] = PGLOG['GDEXEMAIL']
|
|
145
|
+
PGLOG['SUDORDA'] = PGLOG['SUDOGDEX']
|
|
146
|
+
|
|
142
147
|
HOSTTYPES = {
|
|
143
148
|
'rda' : 'dsg_mach',
|
|
144
149
|
'casper' : 'dav',
|
|
@@ -311,15 +316,15 @@ def send_python_email(subject = None, receiver = None, msg = None, sender = None
|
|
|
311
316
|
docc = False if cc else True
|
|
312
317
|
if not sender:
|
|
313
318
|
sender = PGLOG['CURUID']
|
|
314
|
-
if sender != PGLOG['
|
|
315
|
-
if sender == PGLOG['
|
|
319
|
+
if sender != PGLOG['GDEXUSER']: docc = False
|
|
320
|
+
if sender == PGLOG['GDEXUSER']: sender = PGLOG['GDEXEMAIL']
|
|
316
321
|
if sender.find('@') == -1: sender += "@ucar.edu"
|
|
317
322
|
if not receiver:
|
|
318
323
|
receiver = PGLOG['EMLADDR'] if PGLOG['EMLADDR'] else PGLOG['CURUID']
|
|
319
|
-
if receiver == PGLOG['
|
|
324
|
+
if receiver == PGLOG['GDEXUSER']: receiver = PGLOG['GDEXEMAIL']
|
|
320
325
|
if receiver.find('@') == -1: receiver += "@ucar.edu"
|
|
321
326
|
|
|
322
|
-
if docc and not re.match(PGLOG['
|
|
327
|
+
if docc and not re.match(PGLOG['GDEXUSER'], sender): add_carbon_copy(sender, 1)
|
|
323
328
|
emlmsg = EmailMessage()
|
|
324
329
|
emlmsg.set_content(msg)
|
|
325
330
|
emlmsg['From'] = sender
|
|
@@ -792,7 +797,7 @@ def pgsystem(pgcmd, logact = LOGWRN, cmdopt = 5, instr = None, seconds = 0):
|
|
|
792
797
|
if ret == FAILURE and loop >= loops: errlog |= logact
|
|
793
798
|
pglog(error, errlog)
|
|
794
799
|
|
|
795
|
-
if last > PGLOG['CMDTIME'] and not re.search(r'(^|/|\s)(dsarch|dsupdt|dsrqst
|
|
800
|
+
if last > PGLOG['CMDTIME'] and not re.search(r'(^|/|\s)(dsarch|dsupdt|dsrqst)\s', cmdstr):
|
|
796
801
|
cmdstr = "> {} Ends By {}".format(break_long_string(cmdstr, 100, "...", 1), current_datetime())
|
|
797
802
|
cmd_execute_time(cmdstr, last, cmdact)
|
|
798
803
|
|
|
@@ -1176,11 +1181,11 @@ def get_local_command(cmd, asuser = None):
|
|
|
1176
1181
|
cuser = PGLOG['SETUID'] if PGLOG['SETUID'] else PGLOG['CURUID']
|
|
1177
1182
|
if not asuser or cuser == asuser: return cmd
|
|
1178
1183
|
|
|
1179
|
-
if cuser == PGLOG['
|
|
1184
|
+
if cuser == PGLOG['GDEXUSER']:
|
|
1180
1185
|
wrapper = "pgstart_" + asuser
|
|
1181
1186
|
if valid_command(wrapper): return "{} {}".format(wrapper, cmd)
|
|
1182
|
-
elif PGLOG['
|
|
1183
|
-
return "sudo -u {} {}".format(PGLOG['
|
|
1187
|
+
elif PGLOG['SUDOGDEX'] and asuser == PGLOG['GDEXUSER']:
|
|
1188
|
+
return "sudo -u {} {}".format(PGLOG['GDEXUSER'], cmd) # sudo as user gdexdata
|
|
1184
1189
|
|
|
1185
1190
|
return cmd
|
|
1186
1191
|
|
|
@@ -1203,12 +1208,12 @@ def get_hpss_command(cmd, asuser = None, hcmd = None):
|
|
|
1203
1208
|
if not hcmd: hcmd = 'hsi'
|
|
1204
1209
|
|
|
1205
1210
|
if asuser and cuser != asuser:
|
|
1206
|
-
if cuser == PGLOG['
|
|
1211
|
+
if cuser == PGLOG['GDEXUSER']:
|
|
1207
1212
|
return "{} sudo -u {} {}".format(hcmd, asuser, cmd) # setuid wrapper as user asuser
|
|
1208
|
-
elif PGLOG['
|
|
1209
|
-
return "sudo -u {} {} {}".format(PGLOG['
|
|
1213
|
+
elif PGLOG['SUDOGDEX'] and asuser == PGLOG['GDEXUSER']:
|
|
1214
|
+
return "sudo -u {} {} {}".format(PGLOG['GDEXUSER'], hcmd, cmd) # sudo as user gdexdata
|
|
1210
1215
|
|
|
1211
|
-
if cuser != PGLOG['
|
|
1216
|
+
if cuser != PGLOG['GDEXUSER']:
|
|
1212
1217
|
if re.match(r'^ls ', cmd) and hcmd == 'hsi':
|
|
1213
1218
|
return "hpss" + cmd # use 'hpssls' instead of 'hsi ls'
|
|
1214
1219
|
elif re.match(r'^htar -tvf', hcmd):
|
|
@@ -1225,8 +1230,8 @@ def get_sync_command(host, asuser = None):
|
|
|
1225
1230
|
|
|
1226
1231
|
host = get_short_host(host)
|
|
1227
1232
|
|
|
1228
|
-
if (not (PGLOG['SETUID'] and PGLOG['SETUID'] == PGLOG['
|
|
1229
|
-
(not asuser or asuser == PGLOG['
|
|
1233
|
+
if (not (PGLOG['SETUID'] and PGLOG['SETUID'] == PGLOG['GDEXUSER']) and
|
|
1234
|
+
(not asuser or asuser == PGLOG['GDEXUSER'])):
|
|
1230
1235
|
return "sync" + host
|
|
1231
1236
|
|
|
1232
1237
|
return host + "-sync"
|
|
@@ -1240,7 +1245,7 @@ def set_suid(cuid = 0):
|
|
|
1240
1245
|
if cuid != PGLOG['EUID'] or cuid != PGLOG['RUID']:
|
|
1241
1246
|
os.setreuid(cuid, cuid)
|
|
1242
1247
|
PGLOG['SETUID'] = pwd.getpwuid(cuid).pw_name
|
|
1243
|
-
if not (PGLOG['SETUID'] == PGLOG['
|
|
1248
|
+
if not (PGLOG['SETUID'] == PGLOG['GDEXUSER'] or cuid == PGLOG['RUID']):
|
|
1244
1249
|
set_specialist_environments(PGLOG['SETUID'])
|
|
1245
1250
|
PGLOG['CURUID'] == PGLOG['SETUID'] # set CURUID to a specific specialist
|
|
1246
1251
|
|
|
@@ -1256,12 +1261,12 @@ def set_common_pglog():
|
|
|
1256
1261
|
PGLOG['EUID'] = os.geteuid()
|
|
1257
1262
|
PGLOG['CURUID'] = pwd.getpwuid(PGLOG['RUID']).pw_name
|
|
1258
1263
|
try:
|
|
1259
|
-
PGLOG['RDAUID'] = pwd.getpwnam(PGLOG['
|
|
1260
|
-
PGLOG['RDAGID'] = grp.getgrnam(PGLOG['
|
|
1264
|
+
PGLOG['RDAUID'] = PGLOG['GDEXUID'] = pwd.getpwnam(PGLOG['GDEXUSER']).pw_uid
|
|
1265
|
+
PGLOG['RDAGID'] = PGLOG['GDEXGID'] = grp.getgrnam(PGLOG['GDEXGRP']).gr_gid
|
|
1261
1266
|
except:
|
|
1262
|
-
PGLOG['RDAUID'] = 0
|
|
1263
|
-
PGLOG['RDAGID'] = 0
|
|
1264
|
-
if PGLOG['CURUID'] == PGLOG['
|
|
1267
|
+
PGLOG['RDAUID'] = PGLOG['GDEXUID'] = 0
|
|
1268
|
+
PGLOG['RDAGID'] = PGLOG['GDEXGID'] = 0
|
|
1269
|
+
if PGLOG['CURUID'] == PGLOG['GDEXUSER']: PGLOG['SETUID'] = PGLOG['GDEXUSER']
|
|
1265
1270
|
|
|
1266
1271
|
PGLOG['HOSTNAME'] = get_host()
|
|
1267
1272
|
for htype in HOSTTYPES:
|
|
@@ -1274,7 +1279,7 @@ def set_common_pglog():
|
|
|
1274
1279
|
PGLOG['NOTBROOT'] = '|'.join([PGLOG['OLDAROOT'], PGLOG['OLDBROOT'], PGLOG['ARCHROOT']])
|
|
1275
1280
|
PGLOG['ALLROOTS'] = '|'.join([PGLOG['OLDAROOT'], PGLOG['OLDBROOT'], PGLOG['ARCHROOT'], PGLOG['BACKROOT']])
|
|
1276
1281
|
SETPGLOG("USRHOME", "/glade/u/home")
|
|
1277
|
-
SETPGLOG("DSSHOME", "/glade/u/home/
|
|
1282
|
+
SETPGLOG("DSSHOME", "/glade/u/home/gdexdata")
|
|
1278
1283
|
SETPGLOG("GDEXHOME", "/data/local")
|
|
1279
1284
|
SETPGLOG("ADDPATH", "")
|
|
1280
1285
|
SETPGLOG("ADDLIB", "")
|
|
@@ -1334,7 +1339,7 @@ def set_common_pglog():
|
|
|
1334
1339
|
SETPGLOG("CNFPATH", PGLOG['DSSHOME']+"/config") # path to configuration files
|
|
1335
1340
|
SETPGLOG("DSSURL", "https://gdex.ucar.edu") # current dss web URL
|
|
1336
1341
|
SETPGLOG("RQSTURL", "/datasets/request") # request URL path
|
|
1337
|
-
SETPGLOG("WEBSERVERS", "
|
|
1342
|
+
SETPGLOG("WEBSERVERS", "") # webserver names for Web server
|
|
1338
1343
|
PGLOG['WEBHOSTS'] = PGLOG['WEBSERVERS'].split(':') if PGLOG['WEBSERVERS'] else []
|
|
1339
1344
|
SETPGLOG("DBMODULE", '')
|
|
1340
1345
|
SETPGLOG("LOCDATA", "/data")
|
rda_python_common/PgOPT.py
CHANGED
|
@@ -624,7 +624,7 @@ def set_email_logact():
|
|
|
624
624
|
def validate_dsowner(aname, dsid = None, logname = None, pgds = 0, logact = 0):
|
|
625
625
|
|
|
626
626
|
if not logname: logname = (params['LN'] if 'LN' in params else PgLOG.PGLOG['CURUID'])
|
|
627
|
-
if logname == PgLOG.PGLOG['
|
|
627
|
+
if logname == PgLOG.PGLOG['GDEXUSER']: return 1
|
|
628
628
|
|
|
629
629
|
dsids = {}
|
|
630
630
|
if dsid:
|
|
@@ -1638,7 +1638,7 @@ def send_request_email_notice(pgrqst, errmsg, fcount, rstat, readyfile = None, p
|
|
|
1638
1638
|
exclude = (einfo['SENDER'] if errmsg else einfo['RECEIVER'])
|
|
1639
1639
|
if not errmsg and pgcntl and pgcntl['ccemail']:
|
|
1640
1640
|
PgLOG.add_carbon_copy(pgcntl['ccemail'], 1, exclude, pgrqst['specialist'])
|
|
1641
|
-
if PgLOG.PGLOG['CURUID'] != pgrqst['specialist'] and PgLOG.PGLOG['CURUID'] != PgLOG.PGLOG['
|
|
1641
|
+
if PgLOG.PGLOG['CURUID'] != pgrqst['specialist'] and PgLOG.PGLOG['CURUID'] != PgLOG.PGLOG['GDEXUSER']:
|
|
1642
1642
|
PgLOG.add_carbon_copy(PgLOG.PGLOG['CURUID'], 1, exclude)
|
|
1643
1643
|
if 'CC' in params: PgLOG.add_carbon_copy(params['CC'], 0, exclude)
|
|
1644
1644
|
einfo['CCD'] = PgLOG.PGLOG['CCDADDR']
|
rda_python_common/PgSIG.py
CHANGED
|
@@ -1089,7 +1089,7 @@ def record_background(bcmd, logact = PgLOG.LOGWRN):
|
|
|
1089
1089
|
aname = bcmd
|
|
1090
1090
|
|
|
1091
1091
|
mp = r"^\s*(\S+)\s+(\d+)\s+1\s+.*{}(.*)$".format(aname)
|
|
1092
|
-
pc = "ps -u {},{} -f | grep ' 1 ' | grep {}".format(PgLOG.PGLOG['CURUID'], PgLOG.PGLOG['
|
|
1092
|
+
pc = "ps -u {},{} -f | grep ' 1 ' | grep {}".format(PgLOG.PGLOG['CURUID'], PgLOG.PGLOG['GDEXUSER'], aname)
|
|
1093
1093
|
for i in range(2):
|
|
1094
1094
|
buf = PgLOG.pgsystem(pc, logact, 20+1024)
|
|
1095
1095
|
if buf:
|
|
@@ -1100,7 +1100,7 @@ def record_background(bcmd, logact = PgLOG.LOGWRN):
|
|
|
1100
1100
|
(uid, sbid, acmd) = ms.groups()
|
|
1101
1101
|
bid = int(sbid)
|
|
1102
1102
|
if bid in CBIDS: return -1
|
|
1103
|
-
if uid == PgLOG.PGLOG['
|
|
1103
|
+
if uid == PgLOG.PGLOG['GDEXUSER']:
|
|
1104
1104
|
acmd = re.sub(r'^\.(pl|py)\s+', '', acmd, 1)
|
|
1105
1105
|
if re.match(r'^{}{}'.format(aname, acmd), bcmd): continue
|
|
1106
1106
|
CBIDS[bid] = bcmd
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rda_python_common
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.47
|
|
4
4
|
Summary: RDA Python common library codes shared by other RDA python packages
|
|
5
5
|
Author-email: Zaihua Ji <zji@ucar.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/NCAR/rda-python-common
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
rda_python_common/PgCMD.py,sha256=EYjG2Z4zEnvsXE1z-jt5UaNoEKxnOYYiMMzvW6HrKA4,20597
|
|
2
|
+
rda_python_common/PgDBI.py,sha256=nAov-B-B9XZ7p7rX1ZU4TcjAItSXVq18yD0Xe80TkwY,74962
|
|
3
|
+
rda_python_common/PgFile.py,sha256=obl9Pj3yFnjrOJUTFiEHK7ZbG2Ic_m3dT0NqO7rGvOs,99370
|
|
4
|
+
rda_python_common/PgLOG.py,sha256=99prfZRwj9wTUCldv1JMtpgltK_HdNuVfNHv6TIcxVg,55723
|
|
5
|
+
rda_python_common/PgLock.py,sha256=12i84nsGBuifSyPnm8IR63LvHvRuVU573D5QKFlHdOI,22623
|
|
6
|
+
rda_python_common/PgOPT.py,sha256=7eqERFMz2gkKIgHucjwxgBFE9mQ_mUsy_OlUqHyAHrw,56014
|
|
7
|
+
rda_python_common/PgSIG.py,sha256=t0yF2vnLgb6TKEBwIp7pEemvp-N29tjkLMoPETKgiZo,35797
|
|
8
|
+
rda_python_common/PgSplit.py,sha256=QKPbF55m8KCTGmwVwL3uG_nuylCC4FSVfLuXeLjJHbE,8816
|
|
9
|
+
rda_python_common/PgUtil.py,sha256=OqESKCd72b9g8m8jwjPJhXDtPYlW6G8oSOhwChvz2Cg,48600
|
|
10
|
+
rda_python_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
rda_python_common-1.0.47.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
|
|
12
|
+
rda_python_common-1.0.47.dist-info/METADATA,sha256=nktxdbeH-g992tcm2GDxithSx-cWrh3oIvlZDfxbFtI,716
|
|
13
|
+
rda_python_common-1.0.47.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
rda_python_common-1.0.47.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
|
|
15
|
+
rda_python_common-1.0.47.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
rda_python_common/PgCMD.py,sha256=EYjG2Z4zEnvsXE1z-jt5UaNoEKxnOYYiMMzvW6HrKA4,20597
|
|
2
|
-
rda_python_common/PgDBI.py,sha256=nAov-B-B9XZ7p7rX1ZU4TcjAItSXVq18yD0Xe80TkwY,74962
|
|
3
|
-
rda_python_common/PgFile.py,sha256=CJqMlUzR47JkTRBsAWwfY-Fl_3IED-u5HuR19EtdDuo,99006
|
|
4
|
-
rda_python_common/PgLOG.py,sha256=KK90AHYssRCeqa2swphhuTdnPeSOMUc8ylwFJe1Bi8c,55525
|
|
5
|
-
rda_python_common/PgLock.py,sha256=12i84nsGBuifSyPnm8IR63LvHvRuVU573D5QKFlHdOI,22623
|
|
6
|
-
rda_python_common/PgOPT.py,sha256=Q0e5dhfhOw8ha7y28s3SS8xBk_kdHSWjC8JfC--2rvU,56012
|
|
7
|
-
rda_python_common/PgSIG.py,sha256=ZVM9Qz6yIFurwIQJtV5-CFbKOTdFsZ-Rs95SEpDFgNk,35795
|
|
8
|
-
rda_python_common/PgSplit.py,sha256=QKPbF55m8KCTGmwVwL3uG_nuylCC4FSVfLuXeLjJHbE,8816
|
|
9
|
-
rda_python_common/PgUtil.py,sha256=OqESKCd72b9g8m8jwjPJhXDtPYlW6G8oSOhwChvz2Cg,48600
|
|
10
|
-
rda_python_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
-
rda_python_common-1.0.46.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
|
|
12
|
-
rda_python_common-1.0.46.dist-info/METADATA,sha256=YCP0-JU_eA01fHYBpWsatyCeOT-T_Sw6wGnoXe9iosY,716
|
|
13
|
-
rda_python_common-1.0.46.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
-
rda_python_common-1.0.46.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
|
|
15
|
-
rda_python_common-1.0.46.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|