Skip to content

Commit 5e1fc82

Browse files
committed
Code corrections.
1 parent 0dd48ba commit 5e1fc82

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/backend/backend_ga4.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,21 @@ def _send_func(request_data):
2121
except Exception as err:
2222
pass # nosec
2323

24+
2425
def is_docker():
25-
def text_in_file(text, filename):
26+
def file_has_text(text, filename):
2627
try:
2728
with open(filename, encoding='utf-8') as lines:
28-
return any(text in line for line in lines)
29+
for line in lines:
30+
if text in line:
31+
return True
2932
except OSError:
3033
return False
3134

32-
return os.path.exists('/.dockerenv') or text_in_file('docker', '/proc/self/cgroup') or text_in_file('docker', '/proc/self/mountinfo')
35+
return os.path.exists('/.dockerenv') or \
36+
file_has_text('docker', '/proc/self/cgroup') or \
37+
file_has_text('docker', '/proc/self/mountinfo')
38+
3339

3440
class GA4Backend(TelemetryBackend):
3541
id = 'ga4'

0 commit comments

Comments
 (0)