mirror of
https://github.com/HorlogeSkynet/archey4
synced 2025-04-13 16:00:15 +02:00
Add config options for timeout (#21)
* Adds config.get('timeout')['ipv6'] and config.get('timeout')['ipv4'] to archey * Add timeout option with separate timers for ipv6 and ipv4. * Renames option name + PEP8 * Adds new options to documentation * Adds new timeout option to default values (in case of standalone execution) * Sets default timeouts to 1 second instead of 5
This commit is contained in:
parent
9aa7291ef4
commit
adf5fc3f14
@ -126,6 +126,9 @@ Below, some further explanations of each option available :
|
||||
"char_before_unit": " ",
|
||||
// Display temperature values in Fahrenheit instead of Celsius.
|
||||
"use_fahrenheit": false
|
||||
},
|
||||
"timeout": {
|
||||
// Some values you can adjust if the default ones look undersized for your system (seconds)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
16
archey
16
archey
@ -399,6 +399,10 @@ class Configuration():
|
||||
'temperature': {
|
||||
'char_before_unit': ' ',
|
||||
'use_fahrenheit': False
|
||||
},
|
||||
'timeout': {
|
||||
'ipv4_detection': 1,
|
||||
'ipv6_detection': 1
|
||||
}
|
||||
}
|
||||
|
||||
@ -861,13 +865,15 @@ class WAN_IP:
|
||||
ipv6_value = check_output([
|
||||
'dig', '+short', '-6', 'aaaa', 'myip.opendns.com',
|
||||
'@resolver1.ipv6-sandbox.opendns.com'
|
||||
], timeout=0.5, stderr=DEVNULL).decode().rstrip()
|
||||
], timeout=config.get('timeout')['ipv6_detection'],
|
||||
stderr=DEVNULL).decode().rstrip()
|
||||
|
||||
except (FileNotFoundError, TimeoutExpired):
|
||||
try:
|
||||
ipv6_value = check_output([
|
||||
'wget', '-qO-', 'https://v6.ident.me/'
|
||||
], timeout=1).decode()
|
||||
], timeout=config.get('timeout')['ipv6_detection']
|
||||
).decode()
|
||||
|
||||
except (CalledProcessError, TimeoutExpired):
|
||||
# It looks like this user doesn't have any IPv6 address...
|
||||
@ -881,13 +887,15 @@ class WAN_IP:
|
||||
try:
|
||||
ipv4_value = check_output([
|
||||
'dig', '+short', 'myip.opendns.com', '@resolver1.opendns.com'
|
||||
], timeout=0.5, stderr=DEVNULL).decode().rstrip()
|
||||
], timeout=config.get('timeout')['ipv4_detection'],
|
||||
stderr=DEVNULL).decode().rstrip()
|
||||
|
||||
except (FileNotFoundError, TimeoutExpired):
|
||||
try:
|
||||
ipv4_value = check_output([
|
||||
'wget', '-qO-', 'https://v4.ident.me/'
|
||||
], timeout=1).decode()
|
||||
], timeout=config.get('timeout')['ipv4_detection']
|
||||
).decode()
|
||||
|
||||
except (CalledProcessError, TimeoutExpired):
|
||||
# This user looks not connected to Internet...
|
||||
|
@ -34,5 +34,9 @@
|
||||
"temperature": {
|
||||
"char_before_unit": " ",
|
||||
"use_fahrenheit": false
|
||||
},
|
||||
"timeout": {
|
||||
"ipv4_detection": 1,
|
||||
"ipv6_detection": 1
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user