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
1diff --git a/bin/wifi_master_mode b/bin/wifi_master_mode.py
2similarity index 90%
3rename from bin/wifi_master_mode
4rename to bin/wifi_master_mode.py
5index 5953ea3..3888caa 100755
6--- a/bin/wifi_master_mode
7+++ b/bin/wifi_master_mode.py
8@@ -1,32 +1,32 @@
9 #!/usr/bin/env python3
10-# Copyright 2015 Canonical Ltd.
11+# Copyright 2015-2020 Canonical Ltd.
12 # All rights reserved.
13 #
14 # Written by:
15 # Jonathan Cave <jonathan.cave@canonical.com>
16 # Po-Hsu Lin <po-hsu.lin@canonical.com>
17
18+import argparse
19 import logging
20 import os
21 import sys
22 import subprocess
23 import tempfile
24
25-from guacamole import Command
26
27-
28-class WifiMasterMode(Command):
29+class WifiMasterMode():
30
31 """Make system to act as an 802.11 Wi-Fi Access Point."""
32
33- def register_arguments(self, parser):
34+ def main(self):
35+ parser = argparse.ArgumentParser()
36 parser.add_argument('--protocol', default='g',
37 choices=['a', 'b', 'g', 'ad'],
38 help="802.11 protocol, possible value: a/b/g/ad")
39 parser.add_argument('--auto', action='store_true',
40 help="Run in the automated mode")
41+ args = parser.parse_args()
42
43- def invoked(self, ctx):
44 data_dir = ""
45 try:
46 data_dir = os.environ['PLAINBOX_PROVIDER_DATA']
47@@ -50,12 +50,12 @@ class WifiMasterMode(Command):
48 with tempfile.NamedTemporaryFile(mode='w+t') as conf_file_out:
49 with open(conf_in, "r") as conf_file_in:
50 data_in = conf_file_in.read()
51- data_out = data_in.replace("$PROTOCOL", ctx.args.protocol)
52+ data_out = data_in.replace("$PROTOCOL", args.protocol)
53 data_out = data_out.replace("$WIFI-DEV-NAME", wifi_dev)
54 conf_file_out.write(data_out)
55 conf_file_out.flush()
56
57- if ctx.args.auto:
58+ if args.auto:
59 child = subprocess.Popen(['hostapd', '-d', conf_file_out.name],
60 stdout=subprocess.PIPE,
61 universal_newlines=True)
62@@ -87,5 +87,6 @@ class WifiMasterMode(Command):
63 finally:
64 child.terminate()
65
66+
67 if __name__ == "__main__":
68 WifiMasterMode().main()

Subscribers

People subscribed via source and target branches