Skip to content

Commit c24862b

Browse files
authored
Ability to override --data-dir for scenarios when proxy.py is running as a user with no home directory (#1389)
* Ability to override `--data-dir` for scenarios when `proxy.py` is running as a user with no home directory * Single quotes * Update expected tar.gz name and Default to `ms-python.black-formatter` in vscode settings * Fix tests for Python 3.6 and 3.7 * Updated README
1 parent 7026c13 commit c24862b

File tree

9 files changed

+37
-14
lines changed

9 files changed

+37
-14
lines changed

.github/workflows/test-library.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
- name: Set the expected dist artifact names
189189
id: artifact-name
190190
run: |
191-
print('::set-output name=sdist::proxy.py-${{
191+
print('::set-output name=sdist::proxy_py-${{
192192
steps.request-check.outputs.release-requested == 'true'
193193
&& github.event.inputs.release-version
194194
|| steps.scm-version.outputs.dist-version

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ build
3636

3737
pyreverse.png
3838
profile.svg
39+
40+
*-pre-push
41+
jaxl-api-credentials*.json

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"typescript.preferences.quoteStyle": "single",
2020
"[python]": {
2121
"editor.wordBasedSuggestions": "matchingDocuments",
22-
"editor.defaultFormatter": null
22+
"editor.defaultFormatter": "ms-python.black-formatter"
2323
},
2424
"python.testing.unittestEnabled": false,
2525
"python.testing.autoTestDiscoverOnSaveEnabled": true,

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,8 +2357,9 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
23572357
[--plugins PLUGINS [PLUGINS ...]] [--enable-dashboard]
23582358
[--basic-auth BASIC_AUTH] [--enable-ssh-tunnel]
23592359
[--work-klass WORK_KLASS] [--pid-file PID_FILE] [--openssl OPENSSL]
2360-
[--enable-proxy-protocol] [--enable-conn-pool] [--key-file KEY_FILE]
2361-
[--cert-file CERT_FILE] [--client-recvbuf-size CLIENT_RECVBUF_SIZE]
2360+
[--data-dir DATA_DIR] [--enable-proxy-protocol] [--enable-conn-pool]
2361+
[--key-file KEY_FILE] [--cert-file CERT_FILE]
2362+
[--client-recvbuf-size CLIENT_RECVBUF_SIZE]
23622363
[--server-recvbuf-size SERVER_RECVBUF_SIZE]
23632364
[--max-sendbuf-size MAX_SENDBUF_SIZE] [--timeout TIMEOUT]
23642365
[--disable-http-proxy] [--disable-headers DISABLE_HEADERS]
@@ -2378,7 +2379,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
23782379
[--filtered-client-ips FILTERED_CLIENT_IPS]
23792380
[--filtered-url-regex-config FILTERED_URL_REGEX_CONFIG]
23802381

2381-
proxy.py v2.4.4rc6.dev11+gac1f05d7.d20240413
2382+
proxy.py v2.4.4rc6.dev85+g9335918b
23822383

23832384
options:
23842385
-h, --help show this help message and exit
@@ -2459,6 +2460,7 @@ options:
24592460
--pid-file PID_FILE Default: None. Save "parent" process ID to a file.
24602461
--openssl OPENSSL Default: openssl. Path to openssl binary. By default,
24612462
assumption is that openssl is in your PATH.
2463+
--data-dir DATA_DIR Default: ~/.proxypy. Path to proxypy data directory.
24622464
--enable-proxy-protocol
24632465
Default: False. If used, will enable proxy protocol.
24642466
Only version 1 is currently supported.
@@ -2501,9 +2503,9 @@ options:
25012503
Default: None. Signing certificate to use for signing
25022504
dynamically generated HTTPS certificates. If used,
25032505
must also pass --ca-key-file and --ca-signing-key-file
2504-
--ca-file CA_FILE Default: /Users/abhinavsingh/Dev/proxy.py/.venv3118/li
2505-
b/python3.11/site-packages/certifi/cacert.pem. Provide
2506-
path to custom CA bundle for peer certificate
2506+
--ca-file CA_FILE Default: /Users/abhinavsingh/Dev/proxy.py/.venv31010/l
2507+
ib/python3.10/site-packages/certifi/cacert.pem.
2508+
Provide path to custom CA bundle for peer certificate
25072509
verification
25082510
--ca-signing-key-file CA_SIGNING_KEY_FILE
25092511
Default: None. CA signing key to use for dynamic

proxy/common/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def _env_threadless_compliant() -> bool:
4747
DOT = b'.'
4848
SLASH = b'/'
4949
AT = b'@'
50+
AND = b'&'
51+
EQUAL = b'='
5052
HTTP_PROTO = b'http'
5153
HTTPS_PROTO = HTTP_PROTO + b's'
5254
HTTP_1_0 = HTTP_PROTO.upper() + SLASH + b'1.0'

proxy/common/flag.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,13 @@ def initialize(
381381
),
382382
)
383383

384-
args.proxy_py_data_dir = DEFAULT_DATA_DIRECTORY_PATH
384+
args.proxy_py_data_dir = cast(
385+
str,
386+
opts.get(
387+
'data_dir',
388+
args.data_dir or DEFAULT_DATA_DIRECTORY_PATH,
389+
),
390+
)
385391
os.makedirs(args.proxy_py_data_dir, exist_ok=True)
386392

387393
ca_cert_dir = opts.get('ca_cert_dir', args.ca_cert_dir)

proxy/proxy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@
145145
'By default, assumption is that openssl is in your PATH.',
146146
)
147147

148+
flags.add_argument(
149+
'--data-dir',
150+
type=str,
151+
default=None,
152+
help='Default: ~/.proxypy. Path to proxypy data directory.',
153+
)
154+
148155

149156
class Proxy:
150157
"""Proxy is a context manager to control proxy.py library core.

requirements-tunnel.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
paramiko==2.11.0
2-
types-paramiko==2.11.3
1+
paramiko==2.11.0; python_version < '3.11'
2+
paramiko==3.4.0; python_version >= '3.11'
3+
types-paramiko==2.11.3; python_version < '3.11'
4+
types-paramiko==3.4.0.20240311; python_version >= '3.11'
35
cryptography==36.0.2; python_version <= '3.6'

tests/test_main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
DEFAULT_ENABLE_SSH_TUNNEL, DEFAULT_ENABLE_WEB_SERVER,
3434
DEFAULT_DISABLE_HTTP_PROXY, PLUGIN_WEBSOCKET_TRANSPORT,
3535
DEFAULT_CA_SIGNING_KEY_FILE, DEFAULT_CLIENT_RECVBUF_SIZE,
36-
DEFAULT_SERVER_RECVBUF_SIZE, DEFAULT_CACHE_DIRECTORY_PATH,
37-
DEFAULT_ENABLE_REVERSE_PROXY, DEFAULT_ENABLE_STATIC_SERVER,
38-
_env_threadless_compliant,
36+
DEFAULT_DATA_DIRECTORY_PATH, DEFAULT_SERVER_RECVBUF_SIZE,
37+
DEFAULT_CACHE_DIRECTORY_PATH, DEFAULT_ENABLE_REVERSE_PROXY,
38+
DEFAULT_ENABLE_STATIC_SERVER, _env_threadless_compliant,
3939
)
4040

4141

@@ -83,6 +83,7 @@ def mock_default_args(mock_args: mock.Mock) -> None:
8383
mock_args.enable_ssh_tunnel = DEFAULT_ENABLE_SSH_TUNNEL
8484
mock_args.enable_reverse_proxy = DEFAULT_ENABLE_REVERSE_PROXY
8585
mock_args.unix_socket_path = None
86+
mock_args.data_dir = DEFAULT_DATA_DIRECTORY_PATH
8687
mock_args.cache_dir = DEFAULT_CACHE_DIRECTORY_PATH
8788

8889
@mock.patch('os.remove')

0 commit comments

Comments
 (0)