Skip to content

Commit

Permalink
Fix install path on Travis
Browse files Browse the repository at this point in the history
Add status to get_key

Fix #23
  • Loading branch information
rolandoislas committed Jun 4, 2017
1 parent c176165 commit f28293d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
14 changes: 10 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
# June 1, 2017 - 1.1.1
# Fix Make, cmake, and setup.py not returning on errors
# Fix current directory not being restored on a git update failure
# June 2, 2017 - 1.1.2
# Detect and install to virtualenv

VERSION="1.1"
VERSION="1.1.2"
REPO_DRC_SIM="https://github.com/rolandoislas/drc-sim.git"
REPO_WPA_SUPPLICANT_DRC="https://github.com/rolandoislas/drc-hostap.git"
REPO_DRC_SIM_C="https://github.com/rolandoislas/drc-sim-c.git"
Expand Down Expand Up @@ -200,7 +202,13 @@ install_drc_sim() {
# Install
echo "Installing drc-sim"
echo "Downloading Python packages. This may take a while."
if ! python3 "${drc_dir}setup.py" install --record "${drc_dir}/install.txt" &> "/tmp/drc-sim-py-install.log"; then
prefix=""
if [ ! -z "${VIRTUAL_ENV}" ]; then
echo "Installing into virtualenv: ${VIRTUAL_ENV}"
prefix="--prefix ${VIRTUAL_ENV}"
fi
if ! python3 "${drc_dir}setup.py" install ${prefix} --record "${drc_dir}/install.txt" &> \
"/tmp/drc-sim-py-install.log"; then
cat "/tmp/drc-sim-py-install.log"
return 1
fi
Expand Down Expand Up @@ -233,15 +241,13 @@ uninstall() {
exit 2
fi
else
cat ${drc_install_log}
echo "Could not clean Python installed files. Missing ${drc_install_log}"
fi
# Launcher (.desktop)
to_remove=("/usr/share/applications/drc-sim-backend.desktop" "/usr/share/applications/drcsimbackend.desktop"
"/usr/share/icons/hicolor/512x512/apps/drcsimbackend.png")
for item in "${to_remove[@]}"; do
if [[ -f "${item}" ]]; then
echo "Removing application launcher"
rm -f ${item} &> /dev/null
fi
done
Expand Down
9 changes: 9 additions & 0 deletions src/server/ui/gui/frame/frame_about.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ def __init__(self, master=None, **kw):
super().__init__(master, **kw)
self.text_name = Label(self, text=constants.NAME)
self.text_version = Label(self, text="v" + constants.VERSION)
self.text_license = Label(self,
text="%s is free software: you can\n" % constants.NAME +
"redistribute it and/or modify it under the\n"
"terms of the GNU General Public License as\n"
"published by the Free Software Foundation,\n"
"either version 2 of the License, or\n"
"(at your option) any later version."
)

self.text_name.grid(row=0, column=0)
self.text_version.grid(row=1, column=0)
self.text_license.grid(row=2, column=0)
self.grid_columnconfigure(0, weight=1)

def activate(self):
Expand Down
18 changes: 10 additions & 8 deletions src/server/ui/gui/frame/frame_get_key.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tkinter import PhotoImage, Button, END, messagebox
from tkinter.ttk import Entry, Progressbar, Combobox
from tkinter.ttk import Entry, Combobox, Label

from src.server.data import constants
from src.server.data.resource import Resource
Expand Down Expand Up @@ -41,8 +41,8 @@ def __init__(self, master=None, **kw):
self.button_delete = Button(self, text="Delete")
# Code
self.entry_pair_code = Entry(self, state="readonly")
# Progress bar
self.progress_bar = Progressbar(self, mode="indeterminate")
# Status Message
self.status_message = Label(self, state="readonly")
# interface dropdown
self.dropdown_wii_u = Combobox(self, state="readonly")
# Events
Expand All @@ -58,7 +58,7 @@ def __init__(self, master=None, **kw):
self.button_clover.grid(column=3, row=0)
self.button_delete.grid(column=4, row=0)
self.entry_pair_code.grid(column=0, row=1, columnspan=5)
self.progress_bar.grid(column=0, row=3, columnspan=5)
self.status_message.grid(column=0, row=3, columnspan=5)
self.dropdown_wii_u.grid(column=0, row=2, columnspan=5)

# noinspection PyUnusedLocal
Expand Down Expand Up @@ -99,7 +99,6 @@ def button_clicked(self, event):
if len(code) == 4:
self.getting_psk = True
self.set_code_text("")
self.progress_bar.grid()
self.get_psk(code, wii_u_interface)

def get_psk(self, code, interface):
Expand Down Expand Up @@ -127,19 +126,22 @@ def wpa_status_changed(self, status):
self.deactivate()
self.activate()
messagebox.showerror("Auth Saved", "Successfully paired with Wii U.")
elif status == WpaSupplicant.SCANNING:
self.status_message["text"] = "Scanning"
elif status == WpaSupplicant.CONNECTING:
self.status_message["text"] = "Connecting"

def activate(self):
LoggerGui.debug("FrameTab activate called")
self.getting_psk = False
self.set_code_text("")
self.progress_bar.start()
if not self.wpa_supplicant or not self.wpa_supplicant.get_status():
self.progress_bar.grid_remove()
self.status_message["text"] = ""
self.dropdown_wii_u["values"] = InterfaceUtil.get_wiiu_compatible_interfaces()

def deactivate(self):
LoggerGui.debug("FrameTab deactivate called")
self.progress_bar.stop()
self.status_message["text"] = ""
self.getting_psk = False
if self.wpa_supplicant:
self.wpa_supplicant.stop()
Expand Down
29 changes: 27 additions & 2 deletions src/server/util/wpa_supplicant.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def get_psk(self, conf_path, interface, code):
NOT_FOUND: wpa_supplicant_drc did not find any Wii U APs
TERMINATED: wpa_supplicant_drc could not authenticate with any SSIDs
DISCONNECTED: auth details were saved
SCANNING: scan has started
CONNECTING: attempting to authenticate with a Wii U
:return: None
"""
self.connect(conf_path, interface, status_check=False)
Expand All @@ -219,10 +221,19 @@ def get_psk_thread(self, code):
# Scan for Wii U SSIDs
scan_tries = 5
wii_u_bssids = []
self.set_status(self.SCANNING)
while self.running and scan_tries > 0:
self.psk_thread_cli.sendline("scan")
LoggerWpa.debug("CLI expect waiting for scan results available event")
self.psk_thread_cli.expect("<3>CTRL-EVENT-SCAN-RESULTS", timeout=60)
scan_wait_tries = 60
while self.running:
try:
self.psk_thread_cli.expect("<3>CTRL-EVENT-SCAN-RESULTS", timeout=1)
break
except pexpect.TIMEOUT:
scan_wait_tries -= 1
if scan_wait_tries <= 0:
raise pexpect.TIMEOUT("Scan timeout")
self.psk_thread_cli.sendline("scan_results")
LoggerWpa.debug("CLI expect waiting for scan results")
self.psk_thread_cli.expect("bssid / frequency / signal level / flags / ssid")
Expand All @@ -246,13 +257,22 @@ def get_psk_thread(self, code):
self.set_status(self.NOT_FOUND)
return
# attempt to pair with any wii u bssid
self.set_status(self.CONNECTING)
for bssid in wii_u_bssids:
self.psk_thread_cli.sendline("wps_pin %s %s" % (bssid, code + "5678"))
LoggerWpa.debug("CLI expect waiting for wps_pin input confirmation")
self.psk_thread_cli.expect(code + "5678")
LoggerWpa.debug("CLI expect waiting for authentication")
try:
self.psk_thread_cli.expect("<3>WPS-CRED-RECEIVED", timeout=60)
connect_wait_tries = 60
while self.running:
try:
self.psk_thread_cli.expect("<3>WPS-CRED-RECEIVED", timeout=1)
break
except pexpect.TIMEOUT:
connect_wait_tries -= 1
if connect_wait_tries <= 0:
raise pexpect.TIMEOUT("Connect Timeout")
# save conf
LoggerWpa.debug("PSK obtained")
# Save to temp config before reading from it
Expand All @@ -270,6 +290,11 @@ def get_psk_thread(self, code):
LoggerWpa.debug("PSK get attempt ended with an error.")
LoggerWpa.exception(e)
self.set_status(self.FAILED_START)
# Unexpected EOF
except pexpect.EOF as e:
if self.running: # Thread was not killed
LoggerWpa.exception(e)
return
# Failed to authenticate
LoggerWpa.debug("Could not authenticate with any SSIDs")
self.set_status(self.TERMINATED)
Expand Down

0 comments on commit f28293d

Please sign in to comment.