Skip to content

Commit 73b2b0a

Browse files
committed
Implement connectivity check for analytics endpoint and update URL to localhost
1 parent 1185b7d commit 73b2b0a

551 files changed

Lines changed: 154926 additions & 2 deletions

File tree

Some content is hidden

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

pros/ga/analytics.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,43 @@ def __init__(self):
3333
self.uID = self.cli_config.ga['u_id']
3434
self.pendingRequests = []
3535

36+
self._connectivity_checked = False
37+
self._connecitivty_ok = True
38+
39+
def _check_connectivity(self) -> bool:
40+
"""
41+
Quickly test connectivity to the analytics endpoint.
42+
43+
If it fails, automatically disable analytics (like --no-analytics)
44+
for this and subsequent commands, and persist that choice.
45+
"""
46+
if self._connectivity_checked:
47+
return self._connectivity_ok
48+
49+
self._connectivity_checked = True
50+
try:
51+
r = requests.head(url, timeout=1.0)
52+
self._connectivity_ok = r.ok
53+
except Exception:
54+
self._connectivity_ok = False
55+
56+
if not self._connectivity_ok:
57+
from pros.cli.common import logger
58+
logger(__name__).warning(
59+
"Analytics server not reachable. Disabling analytics for this and future commands.",
60+
extra={'sentry': False},
61+
)
62+
self.set_use(False)
63+
64+
return self._connectivity_ok
65+
3666
def send(self,action):
3767
if not self.useAnalytics or self.sent:
3868
return
69+
70+
if not self._check_connectivity():
71+
return
72+
3973
self.sent=True # Prevent Send from being called multiple times
4074
try:
4175
#Payload to be sent to GA, idk what some of them are but it works

pros/serial/devices/vex/v5_device.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333

3434
def find_v5_ports(p_type: str):
3535
def filter_vex_ports(p):
36-
return p.vid is not None and p.vid in [0x2888, 0x0501] or \
37-
p.name is not None and ('VEX' in p.name or 'V5' in p.name)
36+
return p.vid is not None and p.vid in [0x2888, 0x0501]
3837

3938
def filter_v5_ports(p, locations, names):
4039
return (p.location is not None and any([p.location.endswith(l) for l in locations])) or \

test/.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Compiled Object files
2+
*.o
3+
*.obj
4+
5+
# Executables
6+
*.bin
7+
*.elf
8+
9+
# PROS
10+
bin/
11+
.vscode/
12+
.cache/
13+
compile_commands.json
14+
temp.log
15+
temp.errors
16+
*.ini
17+
.d/

test/Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
################################################################################
2+
######################### User configurable parameters #########################
3+
# filename extensions
4+
CEXTS:=c
5+
ASMEXTS:=s S
6+
CXXEXTS:=cpp c++ cc
7+
8+
# probably shouldn't modify these, but you may need them below
9+
ROOT=.
10+
FWDIR:=$(ROOT)/firmware
11+
BINDIR=$(ROOT)/bin
12+
SRCDIR=$(ROOT)/src
13+
INCDIR=$(ROOT)/include
14+
15+
WARNFLAGS+=
16+
EXTRA_CFLAGS=
17+
EXTRA_CXXFLAGS=
18+
19+
# Set to 1 to enable hot/cold linking
20+
USE_PACKAGE:=1
21+
22+
# Add libraries you do not wish to include in the cold image here
23+
# EXCLUDE_COLD_LIBRARIES:= $(FWDIR)/your_library.a
24+
EXCLUDE_COLD_LIBRARIES:=
25+
26+
# Set this to 1 to add additional rules to compile your project as a PROS library template
27+
IS_LIBRARY:=0
28+
# TODO: CHANGE THIS!
29+
# Be sure that your header files are in the include directory inside of a folder with the
30+
# same name as what you set LIBNAME to below.
31+
LIBNAME:=libbest
32+
VERSION:=1.0.0
33+
# EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c
34+
# this line excludes opcontrol.c and similar files
35+
EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext)))
36+
37+
# files that get distributed to every user (beyond your source archive) - add
38+
# whatever files you want here. This line is configured to add all header files
39+
# that are in the directory include/LIBNAME
40+
TEMPLATE_FILES=$(INCDIR)/$(LIBNAME)/*.h $(INCDIR)/$(LIBNAME)/*.hpp
41+
42+
.DEFAULT_GOAL=quick
43+
44+
################################################################################
45+
################################################################################
46+
########## Nothing below this line should be edited by typical users ###########
47+
-include ./common.mk

0 commit comments

Comments
 (0)