Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,36 @@
# Changelog

## [1.0.1a4](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.0.1a4) (2023-12-15)
## [1.1.1a4](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.1.1a4) (2024-04-01)

[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.0.1a3...1.0.1a4)
[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.1.1a3...1.1.1a4)

**Merged pull requests:**

- Update tests and automation to extend neon-minerva test case [\#47](https://github.com/NeonGeckoCom/skill-ip_address/pull/47) ([NeonDaniel](https://github.com/NeonDaniel))
- Update test dependency to stable spec [\#52](https://github.com/NeonGeckoCom/skill-ip_address/pull/52) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.0.1a3](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.0.1a3) (2023-10-26)
## [1.1.1a3](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.1.1a3) (2024-02-01)

[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.0.1a2...1.0.1a3)

**Fixed bugs:**

- \[BUG\] AttributeError: 'IPSkill' object has no attribute '\_settings\_path' [\#45](https://github.com/NeonGeckoCom/skill-ip_address/issues/45)
[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.1.1a2...1.1.1a3)

**Merged pull requests:**

- Update neon-utils dependency to validate fix [\#46](https://github.com/NeonGeckoCom/skill-ip_address/pull/46) ([NeonDaniel](https://github.com/NeonDaniel))
- Support ovos-utils 0.1 [\#51](https://github.com/NeonGeckoCom/skill-ip_address/pull/51) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.0.1a2](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.0.1a2) (2023-10-23)
## [1.1.1a2](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.1.1a2) (2024-01-26)

[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.0.1a1...1.0.1a2)
[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.1.1a1...1.1.1a2)

**Merged pull requests:**

- Ukrainian Translation and Intent tests [\#26](https://github.com/NeonGeckoCom/skill-ip_address/pull/26) ([NeonMariia](https://github.com/NeonMariia))
- Update logging and English vocabulary [\#50](https://github.com/NeonGeckoCom/skill-ip_address/pull/50) ([NeonDaniel](https://github.com/NeonDaniel))

## [1.0.1a1](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.0.1a1) (2023-10-23)
## [1.1.1a1](https://github.com/NeonGeckoCom/skill-ip_address/tree/1.1.1a1) (2024-01-26)

[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.0.0...1.0.1a1)
[Full Changelog](https://github.com/NeonGeckoCom/skill-ip_address/compare/1.1.0...1.1.1a1)

**Merged pull requests:**

- Update unit test init to account for upstream Skill class changes [\#44](https://github.com/NeonGeckoCom/skill-ip_address/pull/44) ([NeonDaniel](https://github.com/NeonDaniel))
- Support Node devices [\#49](https://github.com/NeonGeckoCom/skill-ip_address/pull/49) ([NeonDaniel](https://github.com/NeonDaniel))



Expand Down
38 changes: 25 additions & 13 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List
from ifaddr import get_adapters
from neon_utils.user_utils import get_user_prefs
from requests import get
from adapt.intent import IntentBuilder
from neon_utils.skills.neon_skill import NeonSkill
from ovos_utils import classproperty
from ovos_utils.log import LOG
from ovos_utils.process_utils import RuntimeRequirements

from mycroft.skills.core import intent_handler
from ovos_bus_client.message import Message
from ovos_workshop.decorators import intent_handler


# TODO: Add something equivalent to neon_utils.net_utils
def get_ifaces(ignore_list=None):
""" Build a dict with device names and their associated ip address.

Arguments:
ignore_list(list): list of devices to ignore. Defaults to "lo"

def get_ifaces(ignore_list: List[str] = None, message: Message = None) -> dict:
"""
Build a dict with device names and their associated ip address.
@param ignore_list: list of devices to ignore. Defaults to "lo"
@param message: Message associated with request
Returns:
(dict) with device names as keys and ip addresses as value.
"""
if message and message.context.get('node_data'):
remote_ip = message.context['node_data'].get('networking',
{}).get('local_ip')
if remote_ip:
LOG.info(f"Got node IP from context: {remote_ip}")
return {"node": remote_ip}

ignore_list = ignore_list or ['lo']
res = {}
for iface in get_adapters():
Expand Down Expand Up @@ -95,10 +103,10 @@ def handle_query_ip(self, message):
"""
if message.data.get("public"):
public = True
addr = {'public': self._get_public_ip_address()}
addr = {'public': self._get_public_ip_address(message)}
else:
public = False
addr = get_ifaces()
addr = get_ifaces(message=message)

dot = self.dialog_renderer.render("dot")

Expand Down Expand Up @@ -133,10 +141,14 @@ def handle_query_ip(self, message):
private=True, wait=True)

@staticmethod
def _get_public_ip_address() -> str:
def _get_public_ip_address(message: Message = None) -> str:
"""
Get the public IP address associated with the request
:returns: str public IP address
"""
# TODO: Server implementation should get this from request origin
return get('https://api.ipify.org').text
public_addr = None
if message and message.context.get('node_data'):
public_addr = message.context['node_data'].get('networking',
{}).get('public_ip')
LOG.info(f"Got public IP from context: {public_addr}")
return public_addr or get('https://api.ipify.org').text
2 changes: 2 additions & 0 deletions locale/en-us/IP.voc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
IP address
IP
i.p.
i p
i p address
network address
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
requests~=2.20
ifaddr~=0.1
neon-utils~=1.7
ovos_utils~=0.0.28
ovos-utils~=0.0, >=0.0.28
ovos-bus-client~=0.0.5
ovos-workshop~=0.0.12
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
neon-minerva[padatious]~=0.1
neon-minerva[padatious]~=0.2
4 changes: 3 additions & 1 deletion skill.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"python": [
"ifaddr~=0.1",
"neon-utils~=1.7",
"ovos_utils~=0.0.28",
"ovos-bus-client~=0.0.5",
"ovos-utils~=0.0, >=0.0.28",
"ovos-workshop~=0.0.12",
"requests~=2.20"
],
"system": {},
Expand Down
5 changes: 0 additions & 5 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,10 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import shutil
import unittest
import pytest

from os import environ
from os.path import dirname, join
from mock import Mock
from mycroft_bus_client import Message
from ovos_utils.messagebus import FakeBus

from neon_minerva.tests.skill_unit_test_base import SkillTestCase

Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

__version__ = "1.1.0"
__version__ = "1.2.0"