rda-python-common 2.1.9__py3-none-any.whl → 2.1.10__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.
@@ -22,7 +22,7 @@ object that existing callers expect.
22
22
 
23
23
  from . import PgLOG, PgUtil, PgDBI, PgFile, PgLock, PgCMD, PgSIG, PgOPT, PgSplit
24
24
 
25
- __version__ = "2.1.9"
25
+ __version__ = "2.1.10"
26
26
 
27
27
  __all__ = [
28
28
  "PgLOG",
@@ -389,7 +389,7 @@ class PgCMD(PgLock):
389
389
  if pgrqst: pgctl = self.get_dsrqst_control(pgrqst, logact)
390
390
  return pgctl
391
391
 
392
- def get_dynamic_options(self, cmd, oindex, otype):
392
+ def get_dynamic_options(self, cmd, oindex, otype, hostname=None):
393
393
  """Runs cmd to retrieve dynamic option strings, retrying on timeout.
394
394
 
395
395
  Executes the command up to three times, retrying when a connection
@@ -401,6 +401,11 @@ class PgCMD(PgLock):
401
401
  oindex (int or None): Object index appended to cmd when truthy.
402
402
  otype (str or None): Object type appended to cmd when truthy;
403
403
  'R' selects the first option from a slash-separated pair.
404
+ hostname (str or None): If provided, the command is executed
405
+ remotely via ``ssh <hostname> ...`` instead of locally; the
406
+ leading command name is resolved to its absolute path via
407
+ ``command_path`` so the remote shell does not depend on its
408
+ own PATH.
404
409
 
405
410
  Returns:
406
411
  str: The parsed option string, or '' if the command produced no
@@ -408,6 +413,7 @@ class PgCMD(PgLock):
408
413
  """
409
414
  if oindex: cmd += " {}".format(oindex)
410
415
  if otype: cmd += ' ' + otype
416
+ if hostname: cmd = "ssh {} {}".format(hostname, self.command_path(cmd))
411
417
  ret = options = ''
412
418
  for loop in range(3):
413
419
  ret = self.pgsystem(cmd, self.LOGWRN, 1299) # 1+2+16+256+1024
@@ -180,6 +180,7 @@ class PgLOG:
180
180
  self.BCHCMDS = {'PBS': 'qsub'}
181
181
  # global dists to cashe information
182
182
  self.COMMANDS = {}
183
+ self.CMDPATHS = {} # cache of bare command name -> full path (or '' if not found)
183
184
  self.PBSHOSTS = []
184
185
  self.PBSSTATS = {}
185
186
  # set additional common PGLOG values
@@ -1197,15 +1198,19 @@ class PgLOG:
1197
1198
  Returns:
1198
1199
  String with the leading command resolved to its full path, or the
1199
1200
  original *cmdstr* if the command already contains a path separator
1200
- or cannot be found via ``shutil.which``.
1201
+ or cannot be found via ``shutil.which``. Results of the
1202
+ ``shutil.which`` lookup are cached in ``self.CMDPATHS``.
1201
1203
  """
1202
1204
  if not cmdstr: return ''
1203
- ary = cmdstr.split(' ', 1)
1204
- cmd = ary[0]
1205
- if re.search(r'[\\/]', cmd): return cmdstr
1206
- optstr = (' ' + ary[1]) if len(ary) > 1 else ''
1207
- pcmd = shutil.which(cmd)
1208
- return (pcmd+optstr) if pcmd else cmdstr
1205
+ sp = cmdstr.find(' ')
1206
+ cmd = cmdstr if sp < 0 else cmdstr[:sp]
1207
+ if '/' in cmd or '\\' in cmd: return cmdstr
1208
+ pcmd = self.CMDPATHS.get(cmd)
1209
+ if pcmd is None:
1210
+ pcmd = shutil.which(cmd) or ''
1211
+ self.CMDPATHS[cmd] = pcmd
1212
+ if not pcmd: return cmdstr
1213
+ return pcmd if sp < 0 else pcmd + cmdstr[sp:]
1209
1214
 
1210
1215
  def add_carbon_copy(self, cc=None, isstr=None, exclude=0, specialist=None):
1211
1216
  """Update the Cc address list in ``PGLOG['CCDADDR']``.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rda_python_common
3
- Version: 2.1.9
3
+ Version: 2.1.10
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
@@ -92,7 +92,7 @@ PgLOG.pglog("hello", PgLOG.LOGWRN)
92
92
  python -c "import rda_python_common; print(rda_python_common.__version__)"
93
93
  ```
94
94
 
95
- You should see the installed version (currently `2.1.9`). If the import
95
+ You should see the installed version (currently `2.1.10`). If the import
96
96
  fails, double-check that the active Python environment is the one where you
97
97
  ran `pip install`.
98
98
 
@@ -7,12 +7,12 @@ rda_python_common/PgOPT.py,sha256=Kn4JYezZhZwAn2usiIYHoHiymGHRgsN299dxyXbKwkI,56
7
7
  rda_python_common/PgSIG.py,sha256=eTJJ3XxutsQ3JSg6uYRpH26ZmrVUup3ShqDFLWXLruA,35803
8
8
  rda_python_common/PgSplit.py,sha256=SSg5_Qu5PqP44EkqebO-V_cErNcdE2QtORgFHQ7RqlQ,8822
9
9
  rda_python_common/PgUtil.py,sha256=OqESKCd72b9g8m8jwjPJhXDtPYlW6G8oSOhwChvz2Cg,48600
10
- rda_python_common/__init__.py,sha256=_zWhlp02qZlgMlsox5HGR_mmXRjyQSHIo__v_hTW2rY,994
11
- rda_python_common/pg_cmd.py,sha256=hQZaW80eFqEUoF0vZHtGuvBEWXbXdY0Nvj6rFIQGboo,32856
10
+ rda_python_common/__init__.py,sha256=FNcDisQ9NznJzOx1igxplnMqrQulXb-D3Kqi6o8hxDY,995
11
+ rda_python_common/pg_cmd.py,sha256=PiQaAeb7l92LceqMwSzLpz9nD5pDRHJcEZxTDn-HeCs,33255
12
12
  rda_python_common/pg_dbi.py,sha256=q6LT4a4lwo-sM2LEqgrEVkAlh886xeKiz4feqRKw-7c,116238
13
13
  rda_python_common/pg_file.py,sha256=RzQTxnht4bFOVty4qoYPREawMCUsnFIbWm2pfEez1fE,161993
14
14
  rda_python_common/pg_lock.py,sha256=31EaVDjCkcx3-n8-KnzG18R8Pz7Z6KyFsEqcml6Iq5c,32702
15
- rda_python_common/pg_log.py,sha256=5kasi1aucWWhlGRlvOG9MT4eHmNsPqEb09rFn_kHPjg,80669
15
+ rda_python_common/pg_log.py,sha256=Vr0z7mujcotvHEEXNPbJRUx5gNbBWfVGZJ30ms9h7iE,80953
16
16
  rda_python_common/pg_opt.py,sha256=sXrlzFWpR2XMak6NlA0MPvErBuQnY6gHM5OsHtoeIPQ,82496
17
17
  rda_python_common/pg_password.py,sha256=X-eIDwdqBhtrhrbDTNWle-0JtWsyIVZdDOZaBu7cFHM,2343
18
18
  rda_python_common/pg_sig.py,sha256=wLKBmFNWAmxWJFC2L3SLsD4n464kzzHbIFFNBlCW6kI,52759
@@ -20,9 +20,9 @@ rda_python_common/pg_split.py,sha256=aAWKUZPmZ-LQ_fJ3DSKzPKxJw0fMDJ2fgP8ZT629M30
20
20
  rda_python_common/pg_util.py,sha256=bjp2civRIhqaBSR8oOtyRzYIZBdwB90SzmJLjRIA7fc,87280
21
21
  rda_python_common/pgpassword.py,sha256=aTQaO59QokWrv2EKom4TvKhNW2Mr6aFMMBVG4DCbcKI,5023
22
22
  rda_python_common/pgpassword.usg,sha256=Wrle6A8sdlMGx3ZEAmE6TNDPOlG84Whe0T3rCNFzPfY,2013
23
- rda_python_common-2.1.9.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
24
- rda_python_common-2.1.9.dist-info/METADATA,sha256=RCXhbSP_OnuQyIUUa5h67nFYjzElGU2uDBMXoH5wFcY,11090
25
- rda_python_common-2.1.9.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
26
- rda_python_common-2.1.9.dist-info/entry_points.txt,sha256=pZgVNWspcK-F1TbPav7C3C9NdeHDZMm_25fW9weix00,65
27
- rda_python_common-2.1.9.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
28
- rda_python_common-2.1.9.dist-info/RECORD,,
23
+ rda_python_common-2.1.10.dist-info/licenses/LICENSE,sha256=1dck4EAQwv8QweDWCXDx-4Or0S8YwiCstaso_H57Pno,1097
24
+ rda_python_common-2.1.10.dist-info/METADATA,sha256=uA5vJ1a2J-arJe3_pMzR4PMj6fGlaWKz1ZVqJLCAhGE,11092
25
+ rda_python_common-2.1.10.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
26
+ rda_python_common-2.1.10.dist-info/entry_points.txt,sha256=pZgVNWspcK-F1TbPav7C3C9NdeHDZMm_25fW9weix00,65
27
+ rda_python_common-2.1.10.dist-info/top_level.txt,sha256=KVQmx7D3DD-jsiheqL8HdTrRE14hpRnZY5_ioMArA5k,18
28
+ rda_python_common-2.1.10.dist-info/RECORD,,