aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-19 10:21:14 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-19 10:21:14 +0200
commitf4ea358ff01eea172125cda165612a4c15cbbfee (patch)
tree5b03e339d55a42b7fc2c1fde6f2bfb94e36bd053
parent5421d3e0ce9b3e49a833d40454b2a37ab8bbe74d (diff)
downloadhaketilo-hydrilla-f4ea358ff01eea172125cda165612a4c15cbbfee.tar.gz
haketilo-hydrilla-f4ea358ff01eea172125cda165612a4c15cbbfee.zip
[proxy] instead of writing addon.py under Haketilo state directory, include the script in package data files
-rw-r--r--src/hydrilla/mitmproxy_launcher/addon_script.py.mitmproxy9
-rw-r--r--src/hydrilla/mitmproxy_launcher/launch.py15
2 files changed, 13 insertions, 11 deletions
diff --git a/src/hydrilla/mitmproxy_launcher/addon_script.py.mitmproxy b/src/hydrilla/mitmproxy_launcher/addon_script.py.mitmproxy
new file mode 100644
index 0000000..fe853d1
--- /dev/null
+++ b/src/hydrilla/mitmproxy_launcher/addon_script.py.mitmproxy
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: CC0-1.0
+
+# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
+#
+# Available under the terms of Creative Commons Zero v1.0 Universal.
+
+from hydrilla.proxy.addon import HaketiloAddon
+
+addons = [HaketiloAddon()]
diff --git a/src/hydrilla/mitmproxy_launcher/launch.py b/src/hydrilla/mitmproxy_launcher/launch.py
index 2f706fd..3b7749d 100644
--- a/src/hydrilla/mitmproxy_launcher/launch.py
+++ b/src/hydrilla/mitmproxy_launcher/launch.py
@@ -45,16 +45,13 @@ from .. import _version
from ..translations import smart_gettext as _
+here = Path(__file__).resolve().parent
+
+
xdg_state_home = os.environ.get('XDG_STATE_HOME', '.local/state')
default_dir = str(Path.home() / xdg_state_home / 'haketilo')
old_default_dir_path = Path.home() / '.haketilo/'
-addon_script_text = '''
-from hydrilla.proxy.addon import HaketiloAddon
-
-addons = [HaketiloAddon()]
-'''
-
@click.command(help=_('cli_help.haketilo'))
@click.option('-l', '--listen-host', default='127.0.0.1', type=click.STRING,
help=_('cli_opt.haketilo.listen_host'))
@@ -83,10 +80,6 @@ def launch(listen_host: str, port: int, launch_browser: bool, directory: str) \
directory_path.mkdir(parents=True, exist_ok=True)
- script_path = directory_path / 'addon.py'
-
- script_path.write_text(addon_script_text)
-
launch_browser_str = 'true' if launch_browser else 'false'
sys.argv = [
@@ -100,7 +93,7 @@ def launch(listen_host: str, port: int, launch_browser: bool, directory: str) \
'--set', f'haketilo_listen_host={listen_host}',
'--set', f'haketilo_listen_port={port}',
'--set', f'haketilo_launch_browser={launch_browser_str}',
- '--scripts', str(script_path)
+ '--scripts', str(here / 'addon_script.py.mitmproxy')
]
for entry_point in distribution('mitmproxy').entry_points: