Skip to content

Commit 2f286a0

Browse files
committed
wip: migrate hub
1 parent 44dd82f commit 2f286a0

7 files changed

Lines changed: 27 additions & 16 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
## Table of Contents
1616

1717
- [What is OpenPod?](#what-is-openpod)
18+
- [Directory Structure](#directory-structure)
1819

1920

2021
## What is OpenPod?
@@ -130,3 +131,13 @@ This file contains a JSON summary of the Pod for debugging purposes. The informa
130131
131132
]
132133
```
134+
135+
## Directory Structure
136+
137+
```default
138+
.
139+
├── .github # CI/CD using GitHub Actions and other functions.
140+
├── tests # Contains unit testing files.
141+
└── openpod # Contains OpenPod functionality.
142+
└── modules # Independent core functions.
143+
```

openpod/launcher.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Check Requirements #
2020
# ---------------------------------------------------------------------------- #
2121
try:
22-
import config
22+
import config # pylint: disable=W0611
2323
except ImportError :
2424
subprocess.call(['sudo', 'pip3', 'install', 'config'])
2525

@@ -33,7 +33,7 @@
3333

3434
if settings.Pi:
3535
try:
36-
from modules import rec_xbee
36+
from modules import rec_xbee # pylint: disable=C0412
3737
except ModuleNotFoundError as err:
3838
exception_log.error("%s", err)
3939

@@ -108,7 +108,7 @@
108108
# Main HUB Program #
109109
# ---------------------------------------------------------------------------- #
110110
try:
111-
import hub
111+
import pod # pylint: disable=W0611
112112

113113
except RuntimeError as err:
114114
exception_log.error("Could not start hub.py with error: %s", err)

openpod/modules/rec_lookup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def get_group_details(access_group_id):
134134
# ---------------------------------------------------------------------------- #
135135
# Perform Search #
136136
# ---------------------------------------------------------------------------- #
137-
def access_request(requested_id, request_node):
137+
def access_request(requested_id, request_node): # pylint: disable=R0911
138138
'''
139139
Processes access requests.
140140
request_id - User's ID that is making a request.

openpod/modules/rec_mqtt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from modules import rec_api, rec_xbee, rec_lookup
1313
from modules.rec_log import mqtt_log, exception_log, zip_send
1414
import settings
15-
import hub_updater
15+
import updater
1616

1717
# The callback for when the client receives a CONNACK response from the server.
1818
def on_connect(client, userdata, flags, return_code):
@@ -107,12 +107,12 @@ def mqtt_start_update():
107107
'''
108108
mqtt_log.info("UPDATE AVAILABLE - Triggered by the user.")
109109
try:
110-
hub_updater.update_hub()
110+
updater.update_hub()
111111
except RuntimeError as err:
112112
exception_log.error("Error while updating, atempting as subprocess. %s", err)
113113
with open('system.json', 'r+', encoding="UTF-8") as file:
114114
system_data = json.load(file)
115-
update_location = f'/opt/RecursionHub/{system_data.CurrentVersion}/hub_updater.py'
115+
update_location = f'/opt/RecursionHub/{system_data.CurrentVersion}/updater.py'
116116
with subprocess.Popen(['sudo', 'python3', f'{update_location}']) as script:
117117
print(script)
118118

openpod/pod.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def incoming_xbee_data():
7272
file.seek(0)
7373
json.dump(data, file)
7474
file.truncate()
75-
except Exception as err:
75+
except Exception as err: # pylint: disable=W0703
7676
print(err)
7777
# ------------------------------- TEMP SOLUTION ------------------------------ #
7878

@@ -104,10 +104,10 @@ def incoming_xbee_data():
104104
else:
105105
rec_log.publog("info", "Facility connection not found, no data to pull.")
106106
if settings.Pi:
107-
rec_gpio.state(settings.LED_IO, 1, 1) #Slow blink ready to pair to a facility.
107+
rec_gpio.state(settings.LED_IO, 1, 1) # Slow blink ready to pair to a facility.
108108

109109
zip_send() # Send latest log files on boot.
110-
except Exception as err:
110+
except Exception as err: # pylint: disable=W0703
111111
rec_log.publog("error", f"Error occured when pulling data: {err}")
112112

113113

openpod/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
'''Settings file contains "constants" that are unlikely to be changed.'''
44

55
DEBUG = True
6-
Pi = False
6+
PI = False
77

88

99
if DEBUG is True:
10-
RecursionURL = 'https://dev.recursion.space'
10+
RECURSION_SPACE_URL = 'https://dev.recursion.space'
1111
RECURSION_DOMAIN = 'dev.recursion.space'
1212
RECURSION_API_URL = 'https://dev.api.recursion.space'
1313

1414
else:
15-
RecursionURL = 'https://recursion.space'
15+
RECURSION_SPACE_URL = 'https://recursion.space'
1616
RECURSION_DOMAIN = 'recursion.space'
1717
RECURSION_API_URL = 'https://api.recursion.space'
1818

tests/test_updater.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from io import StringIO
1010
from unittest.mock import patch, mock_open, Mock
1111

12-
import hub_updater
12+
import updater # OpenPod Updater
1313

1414
import sys
1515
sys.path.insert(0, "0_1_0/")
@@ -28,9 +28,9 @@ def test_get_current_versions(self):
2828
"facility": "3b9fdc97-9649-4c80-8b48-10df647bd032"
2929
}""")
3030

31-
with patch('hub_updater.open') as mock_open:
31+
with patch('updater.open') as mock_open:
3232
mock_open.side_effect = [systemJSON, systemJSON]
33-
hub_updater.current_hub_version()
33+
updater.current_hub_version()
3434
# hub_updater.update_version_name()
3535
mock_open.assert_called()
3636

0 commit comments

Comments
 (0)