rda-python-common 2.0.18__tar.gz → 2.0.20__tar.gz

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.
Files changed (33) hide show
  1. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/PKG-INFO +1 -1
  2. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/pyproject.toml +1 -1
  3. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_cmd.py +1 -1
  4. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_file.py +16 -16
  5. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_log.py +14 -3
  6. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common.egg-info/PKG-INFO +1 -1
  7. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/LICENSE +0 -0
  8. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/README.md +0 -0
  9. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/setup.cfg +0 -0
  10. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgCMD.py +0 -0
  11. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgDBI.py +0 -0
  12. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgFile.py +0 -0
  13. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgLOG.py +0 -0
  14. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgLock.py +0 -0
  15. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgOPT.py +0 -0
  16. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgSIG.py +0 -0
  17. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgSplit.py +0 -0
  18. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/PgUtil.py +0 -0
  19. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/__init__.py +0 -0
  20. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_dbi.py +0 -0
  21. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_lock.py +0 -0
  22. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_opt.py +0 -0
  23. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_password.py +0 -0
  24. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_sig.py +0 -0
  25. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_split.py +0 -0
  26. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pg_util.py +0 -0
  27. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common/pgpassword.py +0 -0
  28. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common.egg-info/SOURCES.txt +0 -0
  29. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common.egg-info/dependency_links.txt +0 -0
  30. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common.egg-info/entry_points.txt +0 -0
  31. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common.egg-info/requires.txt +0 -0
  32. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/src/rda_python_common.egg-info/top_level.txt +0 -0
  33. {rda_python_common-2.0.18 → rda_python_common-2.0.20}/test/test_common.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_common
3
- Version: 2.0.18
3
+ Version: 2.0.20
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rda_python_common"
7
- version = "2.0.18"
7
+ version = "2.0.20"
8
8
  authors = [
9
9
  { name="Zaihua Ji", email="zji@ucar.edu" },
10
10
  ]
@@ -265,7 +265,7 @@ class PgCMD(PgLock):
265
265
  if otype: cmd += ' ' + otype
266
266
  ret = options = ''
267
267
  for loop in range(3):
268
- ret = self.pgsystem(cmd, self.LOGWRN, 279) # 1+2+4+16+256
268
+ ret = self.pgsystem(cmd, self.LOGWRN, 1299) # 1+2+16+256+1024
269
269
  if loop < 2 and self.PGLOG['SYSERR'] and 'Connection timed out' in self.PGLOG['SYSERR']:
270
270
  time.sleep(self.PGSIG['ETIME'])
271
271
  else:
@@ -261,7 +261,7 @@ class PgFile(PgUtil, PgSIG):
261
261
  tinfo = self.check_object_file(tofile, bucket, 0, logact)
262
262
  if tinfo and tinfo['data_size'] > 0:
263
263
  return self.pglog("{}-{}-{}: file exists already".format(self.OHOST, bucket, tofile), logact)
264
- ocmd = self.valid_command(self.OBJCTCMD, logact)
264
+ ocmd = self.OBJCTCMD
265
265
  cmd = "{} ul -lf {} -b {} -k {} -md '{}'".format(ocmd, fromfile, bucket, tofile, uinfo)
266
266
  for loop in range(2):
267
267
  buf = self.pgsystem(cmd, logact, self.CMDBTH)
@@ -295,7 +295,7 @@ class PgFile(PgUtil, PgSIG):
295
295
  destination_endpoint = topoint
296
296
  label = f"{self.ENDPOINTS[frompoint]} to {self.ENDPOINTS[topoint]} {action}"
297
297
  verify_checksum = True
298
- bcmd = self.valid_command(self.BACKCMD, logact)
298
+ bcmd = self.BACKCMD
299
299
  cmd = f'{bcmd} {action} -se {source_endpoint} -de {destination_endpoint} --label "{label}"'
300
300
  if verify_checksum:
301
301
  cmd += ' -vc'
@@ -325,7 +325,7 @@ class PgFile(PgUtil, PgSIG):
325
325
  if tinfo and tinfo['data_size'] > 0:
326
326
  return self.pglog("{}-{}: file exists already".format(topoint, tofile), logact)
327
327
  action = 'transfer'
328
- bcmd = self.valid_command(self.BACKCMD, logact)
328
+ bcmd = self.BACKCMD
329
329
  cmd = f'{bcmd} {action} -se {frompoint} -de {topoint} -sf {fromfile} -df {tofile} -vc'
330
330
  task = self.submit_globus_task(cmd, topoint, logact)
331
331
  if task['stat'] == 'S':
@@ -373,7 +373,7 @@ class PgFile(PgUtil, PgSIG):
373
373
  if not taskid: return ret
374
374
  if not endpoint: endpoint = self.PGLOG['BACKUPEP']
375
375
  mp = r'Status:\s+({})'.format('|'.join(self.QSTATS.values()))
376
- bcmd = self.valid_command(self.BACKCMD, logact)
376
+ bcmd = self.BACKCMD
377
377
  cmd = f"{bcmd} get-task {taskid}"
378
378
  astats = ['OK', 'Queued']
379
379
  for loop in range(2):
@@ -502,7 +502,7 @@ class PgFile(PgUtil, PgSIG):
502
502
  if not finfo:
503
503
  if finfo != None: return ret
504
504
  return self.lmsg(fromfile, "{}-{} to copy to {}".format(self.OHOST, self.PGLOG['MISSFILE'], tofile), logact)
505
- ocmd = self.valid_command(self.OBJCTCMD, logact)
505
+ ocmd = self.OBJCTCMD
506
506
  cmd = "{} go -k {} -b {}".format(ocmd, fromfile, bucket)
507
507
  fromname = op.basename(fromfile)
508
508
  toname = op.basename(tofile)
@@ -608,7 +608,7 @@ class PgFile(PgUtil, PgSIG):
608
608
  # Delete a file on object store
609
609
  def delete_object_file(self, file, bucket = None, logact = 0):
610
610
  if not bucket: bucket = self.PGLOG['OBJCTBKT']
611
- ocmd = self.valid_command(self.OBJCTCMD, logact)
611
+ ocmd = self.OBJCTCMD
612
612
  for loop in range(2):
613
613
  list = self.object_glob(file, bucket, 0, logact)
614
614
  if not list: return self.FAILURE
@@ -628,7 +628,7 @@ class PgFile(PgUtil, PgSIG):
628
628
  if not endpoint: endpoint = self.PGLOG['BACKUPEP']
629
629
  info = self.check_backup_file(file, endpoint, 0, logact)
630
630
  if not info: return self.FAILURE
631
- bcmd = self.valid_command(self.BACKCMD, logact)
631
+ bcmd = self.BACKCMD
632
632
  cmd = f"{bcmd} delete -ep {endpoint} -tf {file}"
633
633
  task = self.submit_globus_task(cmd, endpoint, logact)
634
634
  if task['stat'] == 'S':
@@ -782,7 +782,7 @@ class PgFile(PgUtil, PgSIG):
782
782
  return self.errlog("{}-{}: Object File exists, cannot move {}-{} to it".format(tobucket, tofile, frombucket, fromfile), 'R', 1, logact)
783
783
  elif tinfo != None:
784
784
  return self.FAILURE
785
- ocmd = self.valid_command(self.OBJCTCMD, logact)
785
+ ocmd = self.OBJCTCMD
786
786
  cmd = "{} mv -b {} -db {} -k {} -dk {}".format(ocmd, frombucket, tobucket, fromfile, tofile)
787
787
  ucmd = "{} gm -k {} -b {}".format(ocmd, fromfile, frombucket)
788
788
  ubuf = self.pgsystem(ucmd, self.LOGWRN, self.CMDRET)
@@ -816,7 +816,7 @@ class PgFile(PgUtil, PgSIG):
816
816
  return self.SUCCESS
817
817
  else:
818
818
  return self.errlog("{}-{}: {} to move".format(frombucket, frompath, self.PGLOG['MISSFILE']), 'R', 1, logact)
819
- ocmd = self.valid_command(self.OBJCTCMD, logact)
819
+ ocmd = self.OBJCTCMD
820
820
  cmd = "{} mv -b {} -db {} -k {} -dk {}".format(ocmd, frombucket, tobucket, frompath, topath)
821
821
  for loop in range(2):
822
822
  buf = self.pgsystem(cmd, logact, self.CMDBTH)
@@ -846,7 +846,7 @@ class PgFile(PgUtil, PgSIG):
846
846
  return self.errlog("{}: File exists, cannot move {} to it".format(tofile, fromfile), 'B', 1, logact)
847
847
  elif tinfo != None:
848
848
  return ret
849
- bcmd = self.valid_command(self.BACKCMD, logact)
849
+ bcmd = self.BACKCMD
850
850
  cmd = f"{bcmd} rename -ep {endpoint} --old-path {fromfile} --new-path {tofile}"
851
851
  loop = 0
852
852
  while loop < 2:
@@ -945,7 +945,7 @@ class PgFile(PgUtil, PgSIG):
945
945
  return self.FAILURE
946
946
  if not odir: odir = dir
947
947
  if not self.make_one_backup_directory(op.dirname(dir), odir, endpoint, logact): return self.FAILURE
948
- bcmd = self.valid_command(self.BACKCMD, logact)
948
+ bcmd = self.BACKCMD
949
949
  cmd = f"{bcmd} mkdir -ep {endpoint} -p {dir}"
950
950
  for loop in range(2):
951
951
  buf = self.pgsystem(cmd, logact, self.CMDRET)
@@ -1421,7 +1421,7 @@ class PgFile(PgUtil, PgSIG):
1421
1421
  if not file: return ret
1422
1422
  ms = re.match(r'^(.+)/$', file)
1423
1423
  if ms: file = ms.group(1) # remove ending '/' in case
1424
- ocmd = self.valid_command(self.OBJCTCMD, logact)
1424
+ ocmd = self.OBJCTCMD
1425
1425
  cmd = "{} lo {} -b {}".format(ocmd, file, bucket)
1426
1426
  ucmd = "{} gm -k {} -b {}".format(ocmd, file, bucket) if opt&14 else None
1427
1427
  loop = 0
@@ -1466,7 +1466,7 @@ class PgFile(PgUtil, PgSIG):
1466
1466
  if not bucket: bucket = self.PGLOG['OBJCTBKT']
1467
1467
  ret = None
1468
1468
  if not path: return ret
1469
- ocmd = self.valid_command(self.OBJCTCMD, logact)
1469
+ ocmd = self.OBJCTCMD
1470
1470
  cmd = "{} lo {} -ls -b {}".format(ocmd, path, bucket)
1471
1471
  loop = 0
1472
1472
  while loop < 2:
@@ -1520,7 +1520,7 @@ class PgFile(PgUtil, PgSIG):
1520
1520
  if not endpoint: endpoint = self.PGLOG['BACKUPEP']
1521
1521
  bdir = op.dirname(file)
1522
1522
  bfile = op.basename(file)
1523
- bcmd = self.valid_command(self.BACKCMD, logact)
1523
+ bcmd = self.BACKCMD
1524
1524
  cmd = f"{bcmd} ls -ep {endpoint} -p {bdir} --filter {bfile}"
1525
1525
  ccnt = loop = 0
1526
1526
  while loop < 2:
@@ -1781,7 +1781,7 @@ class PgFile(PgUtil, PgSIG):
1781
1781
  if not bucket: bucket = self.PGLOG['OBJCTBKT']
1782
1782
  ms = re.match(r'^(.+)/$', dir)
1783
1783
  if ms: dir = ms.group(1)
1784
- ocmd = self.valid_command(self.OBJCTCMD, logact)
1784
+ ocmd = self.OBJCTCMD
1785
1785
  cmd = "{} lo {} -b {}".format(ocmd, dir, bucket)
1786
1786
  ary = err = None
1787
1787
  buf = self.pgsystem(cmd, self.LOGWRN, self.CMDRET)
@@ -1820,7 +1820,7 @@ class PgFile(PgUtil, PgSIG):
1820
1820
  def backup_glob(self, dir, endpoint = None, opt = 0, logact = 0):
1821
1821
  if not dir: return None
1822
1822
  if not endpoint: endpoint = self.PGLOG['BACKUPEP']
1823
- bcmd = self.valid_command(self.BACKCMD, logact)
1823
+ bcmd = self.BACKCMD
1824
1824
  cmd = f"{bcmd} ls -ep {endpoint} -p {dir}"
1825
1825
  flist = {}
1826
1826
  for loop in range(2):
@@ -670,10 +670,11 @@ class PgLOG:
670
670
  end = time.time()
671
671
  last = end - last
672
672
  if error:
673
+ cmdpstr = self.command_path(cmdstr)
673
674
  if ret == self.FAILURE:
674
- error = "Error Execute: {}\n{}".format(cmdstr, error)
675
+ error = "Error Execute: {}\n{}".format(cmdpstr, error)
675
676
  else:
676
- error = "Error From: {}\n{}".format(cmdstr, error)
677
+ error = "Error From: {}\n{}".format(cmdpstr, error)
677
678
  if loop > 1: error = "Retry "
678
679
  if cmdopt&256: self.PGLOG['SYSERR'] += error
679
680
  if cmdopt&4:
@@ -691,7 +692,7 @@ class PgLOG:
691
692
  retbuf = ''
692
693
  return (retbuf if cmdopt&16 else ret)
693
694
 
694
- # strip carrage return '\r', but keep ending newline '\n'
695
+ # strip carriage return '\r', but keep ending newline '\n'
695
696
  @staticmethod
696
697
  def strip_output_line(line):
697
698
  ms = re.search(r'\r([^\r]+)\r*$', line)
@@ -865,6 +866,16 @@ class PgLOG:
865
866
  self.COMMANDS[cmd] = buf
866
867
  return self.COMMANDS[cmd]
867
868
 
869
+ # get full command path if possible
870
+ def command_path(self, cmdstr):
871
+ if not cmdstr: return ''
872
+ ary = cmdstr.split(' ', 1)
873
+ cmd = ary[0]
874
+ if re.search(r'[\\/]', cmd): return cmdstr
875
+ optstr = (' ' + ary[1]) if len(ary) > 1 else ''
876
+ pcmd = shutil.which(cmd)
877
+ return (pcmd+optstr) if pcmd else cmdstr
878
+
868
879
  # add carbon copies to self.PGLOG['CCDADDR']
869
880
  def add_carbon_copy(self, cc = None, isstr = None, exclude = 0, specialist = None):
870
881
  if not cc:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_common
3
- Version: 2.0.18
3
+ Version: 2.0.20
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