-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:brickbots/PiFinder
- Loading branch information
Showing
5 changed files
with
205 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import glob | ||
import sh | ||
import socket | ||
from PiFinder import utils | ||
|
||
BACKUP_PATH = "/home/pifinder/PiFinder_data/PiFinder_backup.zip" | ||
|
||
|
||
class Network: | ||
""" | ||
Provides wifi network info | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def populate_wifi_networks(self): | ||
""" | ||
Parses wpa_supplicant.conf to get current config | ||
""" | ||
pass | ||
|
||
def get_wifi_networks(self): | ||
return "" | ||
|
||
def delete_wifi_network(self, network_id): | ||
""" | ||
Immediately deletes a wifi network | ||
""" | ||
pass | ||
|
||
def add_wifi_network(self, ssid, key_mgmt, psk=None): | ||
""" | ||
Add a wifi network | ||
""" | ||
pass | ||
|
||
def get_ap_name(self): | ||
return "UNKN" | ||
|
||
def set_ap_name(self, ap_name): | ||
pass | ||
|
||
def get_host_name(self): | ||
return socket.gethostname() | ||
|
||
def get_connected_ssid(self): | ||
""" | ||
Returns the SSID of the connected wifi network or | ||
None if not connected or in AP mode | ||
""" | ||
return "UNKN" | ||
|
||
def set_host_name(self, hostname): | ||
if hostname == self.get_host_name(): | ||
return | ||
result = "UNKN" | ||
|
||
def wifi_mode(self): | ||
return "UNKN" | ||
|
||
def set_wifi_mode(self, mode): | ||
pass | ||
|
||
def local_ip(self): | ||
return "NONE" | ||
|
||
|
||
def remove_backup(): | ||
""" | ||
Removes backup file | ||
""" | ||
pass | ||
|
||
|
||
def backup_userdata(): | ||
""" | ||
Back up userdata to a single zip file for later | ||
restore. Returns the path to the zip file. | ||
Backs up: | ||
config.json | ||
observations.db | ||
obslist/* | ||
""" | ||
return BACKUP_PATH | ||
|
||
|
||
def restore_userdata(zip_path): | ||
""" | ||
Compliment to backup_userdata | ||
restores userdata | ||
OVERWRITES existing data! | ||
""" | ||
pass | ||
|
||
|
||
def shutdown(): | ||
""" | ||
shuts down the Pi | ||
""" | ||
print("SYS: Initiating Shutdown") | ||
return True | ||
|
||
|
||
def update_software(): | ||
""" | ||
Uses systemctl to git pull and then restart | ||
service | ||
""" | ||
print("SYS: Running update") | ||
return True | ||
|
||
|
||
def restart_pifinder(): | ||
""" | ||
Uses systemctl to restart the PiFinder | ||
service | ||
""" | ||
print("SYS: Restarting PiFinder") | ||
return True | ||
|
||
|
||
def restart_system(): | ||
""" | ||
Restarts the system | ||
""" | ||
print("SYS: Initiating System Restart") | ||
|
||
|
||
def go_wifi_ap(): | ||
print("SYS: Switching to AP") | ||
return True | ||
|
||
|
||
def go_wifi_cli(): | ||
print("SYS: Switching to Client") | ||
return True | ||
|
||
|
||
def verify_password(username, password): | ||
""" | ||
Checks the provided password against the provided user | ||
password | ||
""" | ||
return True | ||
|
||
|
||
def change_password(username, current_password, new_password): | ||
""" | ||
Changes the PiFinder User password | ||
""" | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
% include("header.tpl", title="Advanced") | ||
|
||
<div id="error" class="error-message"></div> | ||
<center> | ||
<div style="display: grid; grid-template-columns: repeat(4, 1fr); margin: 0.5rem; justify-content: center; gap: 0.5rem;"> | ||
<button class="btn remote-button" onclick="buttonClicked(this, 'LOC')">GPS location lock</button> | ||
<button class="btn remote-button" onclick="buttonClicked(this, 'TIME')">GPS time lock</button> | ||
</div> | ||
<div style="display: flex; flex-direction: row; margin: 0px 5px 0px 5px; gap: 1rem; justify-content: center;"> | ||
</div> | ||
</center> | ||
<script> | ||
function buttonClicked(btn, code) { | ||
if(code == 'LOC') { | ||
fetch("/gps-lock") | ||
.then(response => { | ||
if (!response.ok) { throw Error(response.statusText); } | ||
}) | ||
} else if(code == 'TIME') { | ||
fetch("/time-lock") | ||
.then(response => { | ||
if (!response.ok) { throw Error(response.statusText); } | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
% include("footer.tpl", title="PiFinder UI") | ||
|