Skip to content

Commit 11d1672

Browse files
author
Andy Werner
committed
v0.1.3: Added status log with ip addresses etc
1 parent 95301c7 commit 11d1672

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

octoprint_netconnectd/__init__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,30 @@
77

88

99
import logging
10+
import threading
1011
import netifaces
1112
from flask import jsonify, make_response
1213

1314
import octoprint.plugin
14-
1515
from octoprint.server import admin_permission
1616

17+
18+
19+
1720
class NetconnectdSettingsPlugin(octoprint.plugin.SettingsPlugin,
1821
octoprint.plugin.TemplatePlugin,
1922
octoprint.plugin.SimpleApiPlugin,
2023
octoprint.plugin.AssetPlugin):
2124

25+
LOG_STATE_DELAY = 15.0
26+
2227
def __init__(self):
2328
self.address = None
2429

2530
def initialize(self):
2631
self.address = self._settings.get(["socket"])
2732
self.forwardUrl = self._settings.get(["forwardUrl"])
33+
self._log_state_timed(self.LOG_STATE_DELAY)
2834

2935
@property
3036
def hostname(self):
@@ -253,6 +259,19 @@ def _get_ip_address(self, interface):
253259
except:
254260
pass
255261

262+
def _log_state_timed(self, delay=0):
263+
if delay > 0:
264+
myThread = threading.Timer(delay, self._log_state_timed)
265+
myThread.daemon = True
266+
myThread.name = "Netconnectd_log_state_timer"
267+
myThread.start()
268+
else:
269+
msg = "Netconnectd status: ip_eth0: {}, ip_wlan0: {}, status: {}".format(
270+
self._get_ip_address('eth0'),
271+
self._get_ip_address('wlan0'),
272+
self._get_status())
273+
logging.getLogger("octoprint.plugins." + __name__).info(msg)
274+
256275
__plugin_name__ = "Netconnectd Client"
257276

258277

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
setuptools.setup(**octoprint_setuptools.create_plugin_setup_parameters(
66
identifier="netconnectd",
77
name="OctoPrint-Netconnectd",
8-
version="0.1.2", # Gina's version ins master is "0.1" - April 2018
8+
version="0.1.3", # Gina's version ins master is "0.1" - April 2018
99
description="Client for netconnectd that allows configuration of netconnectd through OctoPrint's settings dialog. It's only available for Linux right now.",
1010
author="Gina Häußge",
1111

0 commit comments

Comments
 (0)