diff options
| author | PMR <pmr@pmr-lander> | 2020-02-07 17:05:54 +0000 |
|---|---|---|
| committer | PMR <pmr@pmr-lander> | 2020-02-07 17:05:54 +0000 |
| commit | fd4eebce9bf979a3c76ca75db2665538210093bc (patch) | |
| tree | 1d14fc7b1eff8be652f371dbbe7a778f6d7d02a4 /bin | |
| parent | 4c53a3fe68a4f9fd0345b4823f7c79d4ed9c036f (diff) | |
| parent | 4ec088307e35a38770c0441d565fc627fe463e44 (diff) | |
Merge #378756 from ~jocave/plainbox-provider-checkbox:wwan-master-deguac
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/wifi_master_mode.py (renamed from bin/wifi_master_mode) | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/bin/wifi_master_mode b/bin/wifi_master_mode.py index 5953ea34..3888caa6 100755 --- a/bin/wifi_master_mode +++ b/bin/wifi_master_mode.py @@ -1,32 +1,32 @@ #!/usr/bin/env python3 -# Copyright 2015 Canonical Ltd. +# Copyright 2015-2020 Canonical Ltd. # All rights reserved. # # Written by: # Jonathan Cave <jonathan.cave@canonical.com> # Po-Hsu Lin <po-hsu.lin@canonical.com> +import argparse import logging import os import sys import subprocess import tempfile -from guacamole import Command - -class WifiMasterMode(Command): +class WifiMasterMode(): """Make system to act as an 802.11 Wi-Fi Access Point.""" - def register_arguments(self, parser): + def main(self): + parser = argparse.ArgumentParser() parser.add_argument('--protocol', default='g', choices=['a', 'b', 'g', 'ad'], help="802.11 protocol, possible value: a/b/g/ad") parser.add_argument('--auto', action='store_true', help="Run in the automated mode") + args = parser.parse_args() - def invoked(self, ctx): data_dir = "" try: data_dir = os.environ['PLAINBOX_PROVIDER_DATA'] @@ -50,12 +50,12 @@ class WifiMasterMode(Command): with tempfile.NamedTemporaryFile(mode='w+t') as conf_file_out: with open(conf_in, "r") as conf_file_in: data_in = conf_file_in.read() - data_out = data_in.replace("$PROTOCOL", ctx.args.protocol) + data_out = data_in.replace("$PROTOCOL", args.protocol) data_out = data_out.replace("$WIFI-DEV-NAME", wifi_dev) conf_file_out.write(data_out) conf_file_out.flush() - if ctx.args.auto: + if args.auto: child = subprocess.Popen(['hostapd', '-d', conf_file_out.name], stdout=subprocess.PIPE, universal_newlines=True) @@ -87,5 +87,6 @@ class WifiMasterMode(Command): finally: child.terminate() + if __name__ == "__main__": WifiMasterMode().main() |
