Skip to content

Commit b310e20

Browse files
authored
Merge branch 'main' into greenlet-segfault
2 parents 2f196b2 + 9429694 commit b310e20

File tree

680 files changed

+7096
-14417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

680 files changed

+7096
-14417
lines changed

.github/workflows/get-envs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def main(f):
2525
filtered_envs = environments[GROUP_NUMBER::TOTAL_GROUPS]
2626
joined_envs = ",".join(filtered_envs)
2727

28-
assert joined_envs, f"No environments found.\nenvironments = {str(environments)}\nGROUP_NUMBER = {GROUP_NUMBER + 1}\nTOTAL_GROUPS = {TOTAL_GROUPS}"
28+
assert joined_envs, (
29+
f"No environments found.\nenvironments = {str(environments)}\nGROUP_NUMBER = {GROUP_NUMBER + 1}\nTOTAL_GROUPS = {TOTAL_GROUPS}"
30+
)
2931
print(joined_envs)
3032

3133

newrelic/admin/debug_console.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@
1414

1515
from newrelic.admin import command, usage
1616

17-
@command('debug-console', 'config_file [session_log]',
18-
"""Runs the client for the embedded agent debugging console.
19-
""", hidden=True, log_intercept=False)
17+
18+
@command(
19+
"debug-console",
20+
"config_file [session_log]",
21+
"""Runs the client for the embedded agent debugging console.
22+
""",
23+
hidden=True,
24+
log_intercept=False,
25+
)
2026
def debug_console(args):
2127
import sys
2228

2329
if len(args) == 0:
24-
usage('debug-console')
30+
usage("debug-console")
2531
sys.exit(1)
2632

2733
from newrelic.console import ClientShell
@@ -30,7 +36,7 @@ def debug_console(args):
3036
log_object = None
3137

3238
if len(args) >= 2:
33-
log_object = open(args[1], 'w')
39+
log_object = open(args[1], "w")
3440

3541
shell = ClientShell(config_file, log=log_object)
3642
shell.cmdloop()

newrelic/admin/generate_config.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,31 @@
1414

1515
from newrelic.admin import command, usage
1616

17-
@command('generate-config', 'license_key [output_file]',
18-
"""Generates a sample agent configuration file for <license_key>.""")
17+
18+
@command(
19+
"generate-config", "license_key [output_file]", """Generates a sample agent configuration file for <license_key>."""
20+
)
1921
def generate_config(args):
2022
import os
2123
import sys
2224

2325
if len(args) == 0:
24-
usage('generate-config')
26+
usage("generate-config")
2527
sys.exit(1)
2628

2729
from newrelic import __file__ as package_root
30+
2831
package_root = os.path.dirname(package_root)
2932

30-
config_file = os.path.join(package_root, 'newrelic.ini')
33+
config_file = os.path.join(package_root, "newrelic.ini")
3134

32-
content = open(config_file, 'r').read()
35+
content = open(config_file, "r").read()
3336

3437
if len(args) >= 1:
35-
content = content.replace('*** REPLACE ME ***', args[0])
38+
content = content.replace("*** REPLACE ME ***", args[0])
3639

37-
if len(args) >= 2 and args[1] != '-':
38-
output_file = open(args[1], 'w')
40+
if len(args) >= 2 and args[1] != "-":
41+
output_file = open(args[1], "w")
3942
output_file.write(content)
4043
output_file.close()
4144
else:

newrelic/admin/local_config.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@
1515
from newrelic.admin import command, usage
1616

1717

18-
@command('local-config', 'config_file [log_file]',
19-
"""Dumps out the local agent configuration after having loaded the settings
20-
from <config_file>.""")
18+
@command(
19+
"local-config",
20+
"config_file [log_file]",
21+
"""Dumps out the local agent configuration after having loaded the settings
22+
from <config_file>.""",
23+
)
2124
def local_config(args):
2225
import os
2326
import sys
2427
import logging
2528

2629
if len(args) == 0:
27-
usage('local-config')
30+
usage("local-config")
2831
sys.exit(1)
2932

3033
from newrelic.config import initialize
@@ -33,7 +36,7 @@ def local_config(args):
3336
if len(args) >= 2:
3437
log_file = args[1]
3538
else:
36-
log_file = '/tmp/python-agent-test.log'
39+
log_file = "/tmp/python-agent-test.log"
3740

3841
log_level = logging.DEBUG
3942

@@ -43,13 +46,12 @@ def local_config(args):
4346
pass
4447

4548
config_file = args[0]
46-
environment = os.environ.get('NEW_RELIC_ENVIRONMENT')
49+
environment = os.environ.get("NEW_RELIC_ENVIRONMENT")
4750

48-
if config_file == '-':
49-
config_file = os.environ.get('NEW_RELIC_CONFIG_FILE')
51+
if config_file == "-":
52+
config_file = os.environ.get("NEW_RELIC_CONFIG_FILE")
5053

51-
initialize(config_file, environment, ignore_errors=False,
52-
log_file=log_file, log_level=log_level)
54+
initialize(config_file, environment, ignore_errors=False, log_file=log_file, log_level=log_level)
5355

5456
for key, value in sorted(global_settings()):
55-
print(f'{key} = {value!r}')
57+
print(f"{key} = {value!r}")

newrelic/admin/network_config.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@
1515
from newrelic.admin import command, usage
1616

1717

18-
@command('network-config', 'config_file [log_file]',
19-
"""Prints out the network configuration after having loaded the settings
20-
from <config_file>.""")
18+
@command(
19+
"network-config",
20+
"config_file [log_file]",
21+
"""Prints out the network configuration after having loaded the settings
22+
from <config_file>.""",
23+
)
2124
def network_config(args):
2225
import os
2326
import sys
2427
import logging
2528

2629
if len(args) == 0:
27-
usage('network-config')
30+
usage("network-config")
2831
sys.exit(1)
2932

3033
from newrelic.config import initialize
@@ -33,7 +36,7 @@ def network_config(args):
3336
if len(args) >= 2:
3437
log_file = args[1]
3538
else:
36-
log_file = '/tmp/python-agent-test.log'
39+
log_file = "/tmp/python-agent-test.log"
3740

3841
log_level = logging.DEBUG
3942

@@ -43,20 +46,19 @@ def network_config(args):
4346
pass
4447

4548
config_file = args[0]
46-
environment = os.environ.get('NEW_RELIC_ENVIRONMENT')
49+
environment = os.environ.get("NEW_RELIC_ENVIRONMENT")
4750

48-
if config_file == '-':
49-
config_file = os.environ.get('NEW_RELIC_CONFIG_FILE')
51+
if config_file == "-":
52+
config_file = os.environ.get("NEW_RELIC_CONFIG_FILE")
5053

51-
initialize(config_file, environment, ignore_errors=False,
52-
log_file=log_file, log_level=log_level)
54+
initialize(config_file, environment, ignore_errors=False, log_file=log_file, log_level=log_level)
5355

5456
_settings = global_settings()
5557

56-
print(f'host = {_settings.host!r}')
57-
print(f'port = {_settings.port!r}')
58-
print(f'proxy_scheme = {_settings.proxy_scheme!r}')
59-
print(f'proxy_host = {_settings.proxy_host!r}')
60-
print(f'proxy_port = {_settings.proxy_port!r}')
61-
print(f'proxy_user = {_settings.proxy_user!r}')
62-
print(f'proxy_pass = {_settings.proxy_pass!r}')
58+
print(f"host = {_settings.host!r}")
59+
print(f"port = {_settings.port!r}")
60+
print(f"proxy_scheme = {_settings.proxy_scheme!r}")
61+
print(f"proxy_host = {_settings.proxy_host!r}")
62+
print(f"proxy_port = {_settings.proxy_port!r}")
63+
print(f"proxy_user = {_settings.proxy_user!r}")
64+
print(f"proxy_pass = {_settings.proxy_pass!r}")

newrelic/admin/record_deploy.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@
2323

2424
def fetch_app_id(app_name, client, headers):
2525
status, data = client.send_request(
26-
"GET",
27-
"/v2/applications.json",
28-
params={"filter[name]": app_name},
29-
headers=headers,
26+
"GET", "/v2/applications.json", params={"filter[name]": app_name}, headers=headers
3027
)
3128

3229
if not 200 <= status < 300:
@@ -97,9 +94,7 @@ def record_deploy(
9794
data = {"deployment": deployment}
9895
payload = encoding_utils.json_encode(data).encode("utf-8")
9996

100-
status_code, response = client.send_request(
101-
"POST", path, headers=headers, payload=payload
102-
)
97+
status_code, response = client.send_request("POST", path, headers=headers, payload=payload)
10398

10499
if status_code != 201:
105100
raise RuntimeError(
@@ -119,9 +114,7 @@ def record_deploy_cmd(args):
119114
usage("record-deploy")
120115
sys.exit(1)
121116

122-
def _args(
123-
config_file, description, revision="Unknown", changelog=None, user=None, *args
124-
):
117+
def _args(config_file, description, revision="Unknown", changelog=None, user=None, *args):
125118
return config_file, description, revision, changelog, user
126119

127120
config_file, description, revision, changelog, user = _args(*args)

newrelic/admin/run_program.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,79 +15,79 @@
1515
from newrelic.admin import command, usage
1616

1717

18-
@command('run-program', '...',
19-
"""Executes the command line but forces the initialisation of the agent
18+
@command(
19+
"run-program",
20+
"...",
21+
"""Executes the command line but forces the initialisation of the agent
2022
automatically at startup.
2123
2224
If using an agent configuration file the path to the file should be
2325
supplied by the environment variable NEW_RELIC_CONFIG_FILE. Alternatively,
2426
just the licence key, application and log file details can be supplied via
2527
environment variables NEW_RELIC_LICENSE_KEY, NEW_RELIC_APP_NAME and
26-
NEW_RELIC_LOG.""")
28+
NEW_RELIC_LOG.""",
29+
)
2730
def run_program(args):
2831
import os
2932
import sys
3033
import time
3134

3235
if len(args) == 0:
33-
usage('run-program')
36+
usage("run-program")
3437
sys.exit(1)
3538

36-
startup_debug = os.environ.get('NEW_RELIC_STARTUP_DEBUG',
37-
'off').lower() in ('on', 'true', '1')
39+
startup_debug = os.environ.get("NEW_RELIC_STARTUP_DEBUG", "off").lower() in ("on", "true", "1")
3840

3941
def log_message(text, *args):
4042
if startup_debug:
4143
text = text % args
42-
timestamp = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
43-
print(f'NEWRELIC: {timestamp} ({os.getpid()}) - {text}')
44+
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
45+
print(f"NEWRELIC: {timestamp} ({os.getpid()}) - {text}")
4446

45-
log_message('New Relic Admin Script (%s)', __file__)
47+
log_message("New Relic Admin Script (%s)", __file__)
4648

47-
log_message('working_directory = %r', os.getcwd())
48-
log_message('current_command = %r', sys.argv)
49+
log_message("working_directory = %r", os.getcwd())
50+
log_message("current_command = %r", sys.argv)
4951

50-
log_message('sys.prefix = %r', os.path.normpath(sys.prefix))
52+
log_message("sys.prefix = %r", os.path.normpath(sys.prefix))
5153

5254
try:
53-
log_message('sys.real_prefix = %r', sys.real_prefix)
55+
log_message("sys.real_prefix = %r", sys.real_prefix)
5456
except AttributeError:
5557
pass
5658

57-
log_message('sys.version_info = %r', sys.version_info)
58-
log_message('sys.executable = %r', sys.executable)
59-
log_message('sys.flags = %r', sys.flags)
60-
log_message('sys.path = %r', sys.path)
59+
log_message("sys.version_info = %r", sys.version_info)
60+
log_message("sys.executable = %r", sys.executable)
61+
log_message("sys.flags = %r", sys.flags)
62+
log_message("sys.path = %r", sys.path)
6163

6264
for name in sorted(os.environ.keys()):
63-
if name.startswith('NEW_RELIC_') or name.startswith('PYTHON'):
64-
if name == 'NEW_RELIC_LICENSE_KEY':
65+
if name.startswith("NEW_RELIC_") or name.startswith("PYTHON"):
66+
if name == "NEW_RELIC_LICENSE_KEY":
6567
continue
66-
log_message('%s = %r', name, os.environ.get(name))
68+
log_message("%s = %r", name, os.environ.get(name))
6769

6870
from newrelic import __file__ as root_directory
6971

7072
root_directory = os.path.dirname(root_directory)
71-
boot_directory = os.path.join(root_directory, 'bootstrap')
73+
boot_directory = os.path.join(root_directory, "bootstrap")
7274

73-
log_message('root_directory = %r', root_directory)
74-
log_message('boot_directory = %r', boot_directory)
75+
log_message("root_directory = %r", root_directory)
76+
log_message("boot_directory = %r", boot_directory)
7577

7678
python_path = boot_directory
7779

78-
if 'PYTHONPATH' in os.environ:
79-
path = os.environ['PYTHONPATH'].split(os.path.pathsep)
80+
if "PYTHONPATH" in os.environ:
81+
path = os.environ["PYTHONPATH"].split(os.path.pathsep)
8082
if boot_directory not in path:
8183
python_path = f"{boot_directory}{os.path.pathsep}{os.environ['PYTHONPATH']}"
8284

83-
os.environ['PYTHONPATH'] = python_path
85+
os.environ["PYTHONPATH"] = python_path
8486

85-
os.environ['NEW_RELIC_ADMIN_COMMAND'] = repr(sys.argv)
87+
os.environ["NEW_RELIC_ADMIN_COMMAND"] = repr(sys.argv)
8688

87-
os.environ['NEW_RELIC_PYTHON_PREFIX'] = os.path.realpath(
88-
os.path.normpath(sys.prefix))
89-
os.environ['NEW_RELIC_PYTHON_VERSION'] = '.'.join(
90-
map(str, sys.version_info[:2]))
89+
os.environ["NEW_RELIC_PYTHON_PREFIX"] = os.path.realpath(os.path.normpath(sys.prefix))
90+
os.environ["NEW_RELIC_PYTHON_VERSION"] = ".".join(map(str, sys.version_info[:2]))
9191

9292
# If not an absolute or relative path, then we need to
9393
# see if program can be found in PATH. Note that can
@@ -97,14 +97,14 @@ def log_message(text, *args):
9797
program_exe_path = args[0]
9898

9999
if not os.path.dirname(program_exe_path):
100-
program_search_path = os.environ.get('PATH', '').split(os.path.pathsep)
100+
program_search_path = os.environ.get("PATH", "").split(os.path.pathsep)
101101
for path in program_search_path:
102102
path = os.path.join(path, program_exe_path)
103103
if os.path.exists(path) and os.access(path, os.X_OK):
104104
program_exe_path = path
105105
break
106106

107-
log_message('program_exe_path = %r', program_exe_path)
108-
log_message('execl_arguments = %r', [program_exe_path] + args)
107+
log_message("program_exe_path = %r", program_exe_path)
108+
log_message("execl_arguments = %r", [program_exe_path] + args)
109109

110110
os.execl(program_exe_path, *args)

0 commit comments

Comments
 (0)