Skip to content

Commit

Permalink
v0.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Code Lao committed Nov 29, 2023
1 parent 9932385 commit e582272
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.5.2
*2023-11-29*

### Optimization and bug fixes.


# 0.5.0
*2023-11-17*

Expand Down
13 changes: 0 additions & 13 deletions py_local/check_connection.py

This file was deleted.

22 changes: 9 additions & 13 deletions py_local/config.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import os, subprocess
from . import check_connection as con


if con.check_internet_connection() == True:
try:
get_net_ifaces = subprocess.run(['ifconfig'], stdout=subprocess.PIPE, text=True)
net_ifaces = get_net_ifaces.stdout
ifaces_list = net_ifaces.split()
except:
if os.name == 'nt':
raise OSError('py-local works on Unix systems only!')
else:
raise OSError('Can\'t get information about your network interfaces! Seems like your OS doesn\'t support \'ifconfig\' command.')
else:
raise ConnectionError('Check your internet connection!')
try:
get_net_ifaces = subprocess.run(['ifconfig'], stdout=subprocess.PIPE, text=True)
net_ifaces = get_net_ifaces.stdout
ifaces_list = net_ifaces.split()
except:
if os.name == 'nt':
raise OSError('py-local works on Unix systems only!')
else:
raise OSError('Can\'t get information about your network interfaces! Seems like your OS doesn\'t support \'ifconfig\' command.')
19 changes: 8 additions & 11 deletions py_local/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ def iface():
for iface in possible_wifi_ifaces:
for i in range(10):
if iface+str(i)+':' in cfg.ifaces_list or iface+str(i) in cfg.ifaces_list:
get_iface_status = subprocess.run(['ifconfig', iface+str(i)], stdout=subprocess.PIPE, text=True)
if 'status' in get_iface_status.stdout:
if not 'inactive' in get_iface_status.stdout:
return iface+str(i)
return iface+str(i)
else:
if i+1 == 10:
raise OSError('No active Wi-Fi or Ethernet interfaces found!')
else:
if i+1 == 10:
raise OSError('No active Wi-Fi or Ethernet interfaces found!')
else:
continue
elif i+1 == 10:
raise OSError('No active Wi-Fi or Ethernet interfaces found!')
continue

def status(iface):
if iface in cfg.ifaces_list or iface+':' in cfg.ifaces_list:
Expand All @@ -27,8 +22,10 @@ def status(iface):
return True
else:
return False
elif 'inet' in get_iface_status.stdout:
return True
else:
raise ValueError('Provided interface doesn\'t have information about its status!')
raise ValueError('Can\'t find information about interface status! Probably your network configuration doesn\'t support status parameters.')
else:
raise ValueError('Unknown interface provided!')

Expand Down

0 comments on commit e582272

Please sign in to comment.