mirror of
https://git.disroot.org/pranav/pybatmesh.git
synced 2024-12-28 02:50:20 +05:30
added support for arguments
Try naxalnet --help to see help
This commit is contained in:
parent
946d20a72c
commit
16dff8bb49
@ -22,6 +22,7 @@ The author, not unlike the Government of India, does not wish
|
||||
to take responsibility in your well-being if you get arrested under
|
||||
a draconian national security law, which was once used to arrest
|
||||
a person involved in the freedom struggle against British Raj.
|
||||
|
||||
-->
|
||||
|
||||
The name naxal comes from Naxalbari, a village in Darjeeling,
|
||||
|
@ -16,4 +16,4 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
__version__ = "0.2.0a"
|
||||
__version__ = "0.2.0a1"
|
||||
|
@ -24,11 +24,13 @@ import sys
|
||||
from pathlib import Path
|
||||
from shutil import copy
|
||||
from dasbus.error import DBusError
|
||||
from argparse import ArgumentParser
|
||||
from naxalnet.iwd import IWD, Device, Adapter
|
||||
|
||||
NETWORKD_CONFIGS = "/usr/share/naxalnet/networkd"
|
||||
NETWORKD_VOLATILE_DIR = "/run/systemd/network"
|
||||
ADHOC_SSID = "HelloWorld"
|
||||
# default values
|
||||
ADHOC_NAME = "HelloWorld"
|
||||
AP_SSID = "NaxalNet"
|
||||
AP_PASSWD = "naxalnet256"
|
||||
|
||||
@ -58,6 +60,7 @@ def here_be_dragons():
|
||||
This function is run every time you
|
||||
execute naxalnet from commandline
|
||||
"""
|
||||
args = parse_args()
|
||||
try:
|
||||
copy_files()
|
||||
except PermissionError as error:
|
||||
@ -94,7 +97,7 @@ def here_be_dragons():
|
||||
if not adhoc_adapter.is_powered_on():
|
||||
adhoc_adapter.power_on()
|
||||
adhoc_device.reload()
|
||||
adhoc_device.start_adhoc_open(ADHOC_SSID)
|
||||
adhoc_device.start_adhoc_open(args.adhoc_name)
|
||||
# Start Access point if ap_device is not empty,
|
||||
# ie, we have more devices
|
||||
if len(ap_devices) != 0:
|
||||
@ -106,10 +109,32 @@ def here_be_dragons():
|
||||
if not ap_adapter.is_powered_on():
|
||||
ap_adapter.power_on()
|
||||
ap_adapter.reload()
|
||||
ap_device.start_ap(AP_SSID, AP_PASSWD)
|
||||
ap_device.start_ap(args.ap_ssid, args.ap_passwd)
|
||||
except DBusError as error:
|
||||
print(error)
|
||||
sys.exit("An error occured while communicating with iwd")
|
||||
|
||||
# naxalnet will print Bye if no errors occured
|
||||
print("Bye")
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = ArgumentParser(description="setup batman networks")
|
||||
parser.add_argument(
|
||||
"--ap-ssid",
|
||||
type=str,
|
||||
help="SSID of the WiFi AP",
|
||||
default=AP_SSID,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ap-passwd",
|
||||
"--ap-password",
|
||||
type=str,
|
||||
help="password of the WiFi AP",
|
||||
default=AP_PASSWD,
|
||||
)
|
||||
parser.add_argument(
|
||||
"--adhoc-name", type=str, default=ADHOC_NAME, help="name of adhoc network"
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
Loading…
Reference in New Issue
Block a user