Last active
September 24, 2018 16:53
-
-
Save spookyahell/a7097cdcb9dcbfb3e99d92900410ae9f to your computer and use it in GitHub Desktop.
Returns the maximum connections per server you can make (can vary if you make a manual build)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import check_output | |
import re | |
from shutil import which | |
def getMaxConnPerServer(): | |
x = which('aria2c') | |
if x is None: | |
print('You have to add aria2c to your path first') | |
return | |
res = check_output(['aria2c','--help=#basic']).decode() | |
lines = res.split('\n') | |
result = None | |
found_max = 0 | |
for line in lines: | |
#~ print([line]) | |
if 'max-connection-per-server' in line: | |
found_max += 1 | |
if 'Possible Values' in line: | |
if found_max == 2: | |
result = line.strip() | |
break | |
if result is not None: | |
x = re.fullmatch('Possible Values: 1-(\d+)', result) | |
if x is not None: | |
return x.group(1) | |
if __name__ == '__main__': | |
max = getMaxConnPerServer() | |
if max is not None: | |
print(f'The maximum connections per server are: {max}') | |
else: | |
print('Analysing failed... contact dev...') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment