-
Notifications
You must be signed in to change notification settings - Fork 62
Made it possible to let the agent use system binaries if exists #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| from pathlib import Path | ||
|
|
||
| import os | ||
| import shutil | ||
| import subprocess | ||
|
|
||
| from htpclient.dicts import copy_and_set_token, dict_clientError | ||
|
|
@@ -66,7 +67,7 @@ def start_uftpd(os_extension, config): | |
| subprocess.check_output("killall -s 9 uftpd", shell=True) # stop running service to make sure we can start it again | ||
| except subprocess.CalledProcessError: | ||
| pass # ignore in case uftpd was not running | ||
| path = './uftpd' + os_extension | ||
| path = retrieveBinary('uftpd' + os_extension) | ||
|
jessevz marked this conversation as resolved.
Outdated
|
||
| cmd = path + ' ' | ||
| if config.get_value('multicast-device'): | ||
| cmd += "-I " + config.get_value('multicast-device') + ' ' | ||
|
|
@@ -132,3 +133,20 @@ def update_files(command, prince=False): | |
| def escape_ansi(line): | ||
| ansi_escape = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -/]*[@-~]') | ||
| return ansi_escape.sub('', line) | ||
|
|
||
| # function to retrieve a system or local binary. | ||
| def retrieveBinary(binary): | ||
|
||
| cwd = Path.cwd() | ||
| # use full path so that it works on Windows and Linux | ||
| local_binary = cwd / binary | ||
|
|
||
| # First check if there is a local binary and use that if it is there | ||
| if local_binary.exists() and local_binary.is_file() and os.access(local_binary, os.X_OK): | ||
| return str(local_binary) | ||
|
jessevz marked this conversation as resolved.
Outdated
|
||
|
|
||
| # Fall back on sytem binary | ||
|
jessevz marked this conversation as resolved.
Outdated
|
||
| systemBinary = shutil.which(binary) | ||
|
|
||
| if systemBinary: | ||
| return systemBinary | ||
|
jessevz marked this conversation as resolved.
Outdated
|
||
| return None | ||
|
jessevz marked this conversation as resolved.
Outdated
jessevz marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.