Merge ~jocave/plainbox-provider-checkbox:wwan-master-deguac into plainbox-provider-checkbox:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Jonathan Cave
Approved revision: 4ec088307e35a38770c0441d565fc627fe463e44
Merged at revision: fd4eebce9bf979a3c76ca75db2665538210093bc
Proposed branch: ~jocave/plainbox-provider-checkbox:wwan-master-deguac
Merge into: plainbox-provider-checkbox:master
Diff against target: 68 lines (+9/-8)
1 file modified
bin/wifi_master_mode.py (+9/-8)
Reviewer Review Type Date Requested Status
Sheila Miguez (community) Approve
Review via email: mp+378756@code.launchpad.net

Description of the change

Continued effort to de-🥑 the provider, wifi_master_mode this time.

To post a comment you must log in.
Revision history for this message
Sheila Miguez (codersquid) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/wifi_master_mode b/bin/wifi_master_mode.py
0similarity index 90%0similarity index 90%
1rename from bin/wifi_master_mode1rename from bin/wifi_master_mode
2rename to bin/wifi_master_mode.py2rename to bin/wifi_master_mode.py
index 5953ea3..3888caa 100755
--- a/bin/wifi_master_mode
+++ b/bin/wifi_master_mode.py
@@ -1,32 +1,32 @@
1#!/usr/bin/env python31#!/usr/bin/env python3
2# Copyright 2015 Canonical Ltd.2# Copyright 2015-2020 Canonical Ltd.
3# All rights reserved.3# All rights reserved.
4#4#
5# Written by:5# Written by:
6# Jonathan Cave <jonathan.cave@canonical.com>6# Jonathan Cave <jonathan.cave@canonical.com>
7# Po-Hsu Lin <po-hsu.lin@canonical.com>7# Po-Hsu Lin <po-hsu.lin@canonical.com>
88
9import argparse
9import logging10import logging
10import os11import os
11import sys12import sys
12import subprocess13import subprocess
13import tempfile14import tempfile
1415
15from guacamole import Command
1616
1717class WifiMasterMode():
18class WifiMasterMode(Command):
1918
20 """Make system to act as an 802.11 Wi-Fi Access Point."""19 """Make system to act as an 802.11 Wi-Fi Access Point."""
2120
22 def register_arguments(self, parser):21 def main(self):
22 parser = argparse.ArgumentParser()
23 parser.add_argument('--protocol', default='g',23 parser.add_argument('--protocol', default='g',
24 choices=['a', 'b', 'g', 'ad'],24 choices=['a', 'b', 'g', 'ad'],
25 help="802.11 protocol, possible value: a/b/g/ad")25 help="802.11 protocol, possible value: a/b/g/ad")
26 parser.add_argument('--auto', action='store_true',26 parser.add_argument('--auto', action='store_true',
27 help="Run in the automated mode")27 help="Run in the automated mode")
28 args = parser.parse_args()
2829
29 def invoked(self, ctx):
30 data_dir = ""30 data_dir = ""
31 try:31 try:
32 data_dir = os.environ['PLAINBOX_PROVIDER_DATA']32 data_dir = os.environ['PLAINBOX_PROVIDER_DATA']
@@ -50,12 +50,12 @@ class WifiMasterMode(Command):
50 with tempfile.NamedTemporaryFile(mode='w+t') as conf_file_out:50 with tempfile.NamedTemporaryFile(mode='w+t') as conf_file_out:
51 with open(conf_in, "r") as conf_file_in:51 with open(conf_in, "r") as conf_file_in:
52 data_in = conf_file_in.read()52 data_in = conf_file_in.read()
53 data_out = data_in.replace("$PROTOCOL", ctx.args.protocol)53 data_out = data_in.replace("$PROTOCOL", args.protocol)
54 data_out = data_out.replace("$WIFI-DEV-NAME", wifi_dev)54 data_out = data_out.replace("$WIFI-DEV-NAME", wifi_dev)
55 conf_file_out.write(data_out)55 conf_file_out.write(data_out)
56 conf_file_out.flush()56 conf_file_out.flush()
5757
58 if ctx.args.auto:58 if args.auto:
59 child = subprocess.Popen(['hostapd', '-d', conf_file_out.name],59 child = subprocess.Popen(['hostapd', '-d', conf_file_out.name],
60 stdout=subprocess.PIPE,60 stdout=subprocess.PIPE,
61 universal_newlines=True)61 universal_newlines=True)
@@ -87,5 +87,6 @@ class WifiMasterMode(Command):
87 finally:87 finally:
88 child.terminate()88 child.terminate()
8989
90
90if __name__ == "__main__":91if __name__ == "__main__":
91 WifiMasterMode().main()92 WifiMasterMode().main()

Subscribers

People subscribed via source and target branches