sferriol-python 0.6.0__tar.gz → 0.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {sferriol_python-0.6.0/sferriol_python.egg-info → sferriol_python-0.7.3}/PKG-INFO +1 -1
  2. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/__init__.py +9 -2
  3. sferriol_python-0.6.0/sferriol/python/_asyncio.py → sferriol_python-0.7.3/sferriol/python/asyncio.py +3 -3
  4. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/net.py +7 -5
  5. {sferriol_python-0.6.0 → sferriol_python-0.7.3/sferriol_python.egg-info}/PKG-INFO +1 -1
  6. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol_python.egg-info/SOURCES.txt +1 -1
  7. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/LICENSE +0 -0
  8. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/README.md +0 -0
  9. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/pyproject.toml +0 -0
  10. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/setup.cfg +0 -0
  11. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/setup.py +0 -0
  12. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/dictionary/__init__.py +0 -0
  13. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/env.py +0 -0
  14. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/json.py +0 -0
  15. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/object.py +0 -0
  16. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol/python/os.py +0 -0
  17. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol_python.egg-info/dependency_links.txt +0 -0
  18. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol_python.egg-info/requires.txt +0 -0
  19. {sferriol_python-0.6.0 → sferriol_python-0.7.3}/sferriol_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sferriol-python
3
- Version: 0.6.0
3
+ Version: 0.7.3
4
4
  Summary: python utilities
5
5
  Home-page: https://gitlab.in2p3.fr/sferriol-ip2i/sferriol-python
6
6
  Author: Sylvain Ferriol
@@ -4,8 +4,6 @@ import time
4
4
  import types
5
5
  from typing import Any, Callable
6
6
 
7
- import _asyncio as asyncio
8
-
9
7
 
10
8
  def load_module_from_file(fpath):
11
9
  """
@@ -58,3 +56,12 @@ def module_name_from_file(fpath):
58
56
  Return The module name of the associated python file.
59
57
  """
60
58
  return pathlib.Path(fpath).stem
59
+
60
+
61
+ def update_methods(obj, functions):
62
+ """
63
+ Update object methods by bounding new functions to instance obj
64
+ """
65
+ for func in functions:
66
+ name = func.__name__
67
+ setattr(obj, name, types.MethodType(func, obj))
@@ -1,4 +1,4 @@
1
- import asyncio
1
+ import asyncio as _asyncio
2
2
 
3
3
 
4
4
  async def run_shell_cmd(cmd: str) -> (int, str, str):
@@ -7,7 +7,7 @@ async def run_shell_cmd(cmd: str) -> (int, str, str):
7
7
  Returns:
8
8
  Tuple (returned code, stdout, stderr)
9
9
  """
10
- proc = await asyncio.create_subprocess_shell(
11
- cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
10
+ proc = await _asyncio.create_subprocess_shell(
11
+ cmd, stdout=_asyncio.subprocess.PIPE, stderr=_asyncio.subprocess.PIPE)
12
12
  stdout, stderr = await proc.communicate()
13
13
  return proc.returncode, stdout.decode().strip(), stderr.decode().strip()
@@ -34,11 +34,13 @@ def get_interface_ip_address(if_str: str) -> str:
34
34
  if_name = get_interface_name(if_str) if is_ipv4_address(if_str) else if_str
35
35
  if if_name in list_interfaces():
36
36
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
37
- return socket.inet_ntoa(
38
- fcntl.ioctl(s.fileno(), 0x8915,
39
- struct.pack('256s', bytes(if_name[:15],
40
- 'utf-8')))[20:24])
41
-
37
+ try:
38
+ return socket.inet_ntoa(
39
+ fcntl.ioctl(s.fileno(), 0x8915,
40
+ struct.pack('256s', bytes(if_name[:15],
41
+ 'utf-8')))[20:24])
42
+ except OSError:
43
+ pass
42
44
 
43
45
  def get_interface_name(ip_addr: str) -> str:
44
46
  """Returns the interface name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sferriol-python
3
- Version: 0.6.0
3
+ Version: 0.7.3
4
4
  Summary: python utilities
5
5
  Home-page: https://gitlab.in2p3.fr/sferriol-ip2i/sferriol-python
6
6
  Author: Sylvain Ferriol
@@ -4,7 +4,7 @@ pyproject.toml
4
4
  setup.cfg
5
5
  setup.py
6
6
  sferriol/python/__init__.py
7
- sferriol/python/_asyncio.py
7
+ sferriol/python/asyncio.py
8
8
  sferriol/python/env.py
9
9
  sferriol/python/json.py
10
10
  sferriol/python/net.py
File without changes