dycw-utilities 0.175.6__py3-none-any.whl → 0.175.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dycw-utilities
3
- Version: 0.175.6
3
+ Version: 0.175.7
4
4
  Summary: Miscellaneous Python utilities
5
5
  Author: Derek Wan
6
6
  Author-email: Derek Wan <d.wan@icloud.com>
@@ -1,4 +1,4 @@
1
- utilities/__init__.py,sha256=7y6XPRHYRyZjE6Vfy185IzZfDUJT8hoQcrfKUT3_4RU,60
1
+ utilities/__init__.py,sha256=B5bIogCgY2363uBTrXOQ-P5Y0xUozj2Nfbz2ZiV4uhs,60
2
2
  utilities/altair.py,sha256=TLfRFbG9HwG7SLXoJ-v0r-t49ZaGgTQZD82cpjVi4vs,9085
3
3
  utilities/asyncio.py,sha256=aJySVxBY0gqsIYnoNmH7-1r8djKuf4vSsU69VCD08t8,16772
4
4
  utilities/atomicwrites.py,sha256=tPo6r-Rypd9u99u66B9z86YBPpnLrlHtwox_8Z7T34Y,5790
@@ -80,7 +80,7 @@ utilities/sqlalchemy.py,sha256=HQYpd7LFxdTF5WYVWYtCJeEBI71EJm7ytvCGyAH9B-U,37163
80
80
  utilities/sqlalchemy_polars.py,sha256=JCGhB37raSR7fqeWV5dTsciRTMVzIdVT9YSqKT0piT0,13370
81
81
  utilities/statsmodels.py,sha256=koyiBHvpMcSiBfh99wFUfSggLNx7cuAw3rwyfAhoKpQ,3410
82
82
  utilities/string.py,sha256=shmBK87zZwzGyixuNuXCiUbqzfeZ9xlrFwz6JTaRvDk,582
83
- utilities/subprocess.py,sha256=C9H8GiV4gsNRRJY5mo8_2DcNqfeonxcfT5o6icQeSkg,40599
83
+ utilities/subprocess.py,sha256=pTmRcfsIraSfsM182R0gzqvDrBS7-_dRmwOABU1ZB14,41018
84
84
  utilities/tempfile.py,sha256=Lx6qa16lL1XVH6WdmD_G9vlN6gLI8nrIurxmsFkPKvg,3022
85
85
  utilities/testbook.py,sha256=j1KmaVbrX9VrbeMgtPh5gk55myAsn3dyRUn7jGbPbRk,1294
86
86
  utilities/text.py,sha256=7SvwcSR2l_5cOrm1samGnR4C-ZI6qyFLHLzSpO1zeHQ,13958
@@ -97,7 +97,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
97
97
  utilities/whenever.py,sha256=F4ek0-OBWxHYrZdmoZt76N2RnNyKY5KrEHt7rqO4AQE,60183
98
98
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
99
99
  utilities/zoneinfo.py,sha256=tdIScrTB2-B-LH0ukb1HUXKooLknOfJNwHk10MuMYvA,3619
100
- dycw_utilities-0.175.6.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
- dycw_utilities-0.175.6.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
- dycw_utilities-0.175.6.dist-info/METADATA,sha256=761YNYgBWP5Xs0xN_xnVhdet11rc3wj-eIQfF_XoqNk,1442
103
- dycw_utilities-0.175.6.dist-info/RECORD,,
100
+ dycw_utilities-0.175.7.dist-info/WHEEL,sha256=RRVLqVugUmFOqBedBFAmA4bsgFcROUBiSUKlERi0Hcg,79
101
+ dycw_utilities-0.175.7.dist-info/entry_points.txt,sha256=cOGtKeJI0KXLSV7MJ8Dhc2G8jPgDcBDm53MVNJU4ycI,136
102
+ dycw_utilities-0.175.7.dist-info/METADATA,sha256=inDD1FvpQAWndmJ70WVWYhpWPrGG1MIhPIOR8Yfz98o,1442
103
+ dycw_utilities-0.175.7.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.175.6"
3
+ __version__ = "0.175.7"
utilities/subprocess.py CHANGED
@@ -217,6 +217,13 @@ def echo_cmd(text: str, /) -> list[str]:
217
217
  ##
218
218
 
219
219
 
220
+ def env_cmds(env: StrStrMapping, /) -> list[str]:
221
+ return [f"{key}={value}" for key, value in env.items()]
222
+
223
+
224
+ ##
225
+
226
+
220
227
  def expand_path(
221
228
  path: PathLike, /, *, subs: StrMapping | None = None, sudo: bool = False
222
229
  ) -> Path:
@@ -893,11 +900,12 @@ def ssh(
893
900
  user: str,
894
901
  hostname: str,
895
902
  /,
896
- *cmd_and_cmds_or_args: str,
903
+ *cmd_and_args: str,
897
904
  batch_mode: bool = True,
898
905
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
899
906
  strict_host_key_checking: bool = True,
900
907
  port: int | None = None,
908
+ env: StrStrMapping | None = None,
901
909
  input: str | None = None,
902
910
  print: bool = False,
903
911
  print_stdout: bool = False,
@@ -913,11 +921,12 @@ def ssh(
913
921
  user: str,
914
922
  hostname: str,
915
923
  /,
916
- *cmd_and_cmds_or_args: str,
924
+ *cmd_and_args: str,
917
925
  batch_mode: bool = True,
918
926
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
919
927
  strict_host_key_checking: bool = True,
920
928
  port: int | None = None,
929
+ env: StrStrMapping | None = None,
921
930
  input: str | None = None,
922
931
  print: bool = False,
923
932
  print_stdout: bool = False,
@@ -933,11 +942,12 @@ def ssh(
933
942
  user: str,
934
943
  hostname: str,
935
944
  /,
936
- *cmd_and_cmds_or_args: str,
945
+ *cmd_and_args: str,
937
946
  batch_mode: bool = True,
938
947
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
939
948
  strict_host_key_checking: bool = True,
940
949
  port: int | None = None,
950
+ env: StrStrMapping | None = None,
941
951
  input: str | None = None,
942
952
  print: bool = False,
943
953
  print_stdout: bool = False,
@@ -953,11 +963,12 @@ def ssh(
953
963
  user: str,
954
964
  hostname: str,
955
965
  /,
956
- *cmd_and_cmds_or_args: str,
966
+ *cmd_and_args: str,
957
967
  batch_mode: bool = True,
958
968
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
959
969
  strict_host_key_checking: bool = True,
960
970
  port: int | None = None,
971
+ env: StrStrMapping | None = None,
961
972
  input: str | None = None,
962
973
  print: bool = False,
963
974
  print_stdout: bool = False,
@@ -973,11 +984,12 @@ def ssh(
973
984
  user: str,
974
985
  hostname: str,
975
986
  /,
976
- *cmd_and_cmds_or_args: str,
987
+ *cmd_and_args: str,
977
988
  batch_mode: bool = True,
978
989
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
979
990
  strict_host_key_checking: bool = True,
980
991
  port: int | None = None,
992
+ env: StrStrMapping | None = None,
981
993
  input: str | None = None,
982
994
  print: bool = False,
983
995
  print_stdout: bool = False,
@@ -992,11 +1004,12 @@ def ssh(
992
1004
  user: str,
993
1005
  hostname: str,
994
1006
  /,
995
- *cmd_and_cmds_or_args: str,
1007
+ *cmd_and_args: str,
996
1008
  batch_mode: bool = True,
997
1009
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
998
1010
  strict_host_key_checking: bool = True,
999
1011
  port: int | None = None,
1012
+ env: StrStrMapping | None = None,
1000
1013
  input: str | None = None, # noqa: A002
1001
1014
  print: bool = False, # noqa: A002
1002
1015
  print_stdout: bool = False,
@@ -1008,18 +1021,19 @@ def ssh(
1008
1021
  logger: LoggerLike | None = None,
1009
1022
  ) -> str | None:
1010
1023
  """Execute a command on a remote machine."""
1011
- cmd_and_args = ssh_cmd( # skipif-ci
1024
+ run_cmd_and_args = ssh_cmd( # skipif-ci
1012
1025
  user,
1013
1026
  hostname,
1014
- *cmd_and_cmds_or_args,
1027
+ *cmd_and_args,
1015
1028
  batch_mode=batch_mode,
1016
1029
  host_key_algorithms=host_key_algorithms,
1017
1030
  strict_host_key_checking=strict_host_key_checking,
1018
1031
  port=port,
1032
+ env=env,
1019
1033
  )
1020
1034
  try: # skipif-ci
1021
1035
  return run(
1022
- *cmd_and_args,
1036
+ *run_cmd_and_args,
1023
1037
  input=input,
1024
1038
  print=print,
1025
1039
  print_stdout=print_stdout,
@@ -1038,7 +1052,7 @@ def ssh(
1038
1052
  return ssh(
1039
1053
  user,
1040
1054
  hostname,
1041
- *cmd_and_cmds_or_args,
1055
+ *cmd_and_args,
1042
1056
  batch_mode=batch_mode,
1043
1057
  host_key_algorithms=host_key_algorithms,
1044
1058
  strict_host_key_checking=strict_host_key_checking,
@@ -1072,11 +1086,12 @@ def ssh_cmd(
1072
1086
  user: str,
1073
1087
  hostname: str,
1074
1088
  /,
1075
- *cmd_and_cmds_or_args: str,
1089
+ *cmd_and_args: str,
1076
1090
  batch_mode: bool = True,
1077
1091
  host_key_algorithms: list[str] = _HOST_KEY_ALGORITHMS,
1078
1092
  strict_host_key_checking: bool = True,
1079
1093
  port: int | None = None,
1094
+ env: StrStrMapping | None = None,
1080
1095
  ) -> list[str]:
1081
1096
  """Command to use 'ssh' to execute a command on a remote machine."""
1082
1097
  args: list[str] = ssh_opts_cmd(
@@ -1085,7 +1100,10 @@ def ssh_cmd(
1085
1100
  strict_host_key_checking=strict_host_key_checking,
1086
1101
  port=port,
1087
1102
  )
1088
- return [*args, f"{user}@{hostname}", *cmd_and_cmds_or_args]
1103
+ args.append(f"{user}@{hostname}")
1104
+ if env is not None:
1105
+ args.extend(env_cmds(env))
1106
+ return [*args, *cmd_and_args]
1089
1107
 
1090
1108
 
1091
1109
  def ssh_opts_cmd(
@@ -1407,6 +1425,7 @@ __all__ = [
1407
1425
  "cp",
1408
1426
  "cp_cmd",
1409
1427
  "echo_cmd",
1428
+ "env_cmds",
1410
1429
  "expand_path",
1411
1430
  "git_branch_current",
1412
1431
  "git_checkout",