Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions pros/ga/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,43 @@ def __init__(self):
self.uID = self.cli_config.ga['u_id']
self.pendingRequests = []

self._connectivity_checked = False
self._connecitivty_ok = True

def _check_connectivity(self) -> bool:
"""
Quickly test connectivity to the analytics endpoint.

If it fails, automatically disable analytics (like --no-analytics)
for this and subsequent commands, and persist that choice.
"""
if self._connectivity_checked:
return self._connectivity_ok

self._connectivity_checked = True
try:
r = requests.head(url, timeout=1.0)
self._connectivity_ok = r.ok
except Exception:
self._connectivity_ok = False

if not self._connectivity_ok:
from pros.cli.common import logger
logger(__name__).warning(
"Analytics server not reachable. Disabling analytics for this and future commands.",
extra={'sentry': False},
)
self.set_use(False)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should permanently disable it if the user doesn't have internet once. User preferences should only be set by users, not automatically IMO. It is fine to just not send it for this command, and go back to user preferences for the next one.


return self._connectivity_ok

def send(self,action):
if not self.useAnalytics or self.sent:
return

if not self._check_connectivity():
return

self.sent=True # Prevent Send from being called multiple times
try:
#Payload to be sent to GA, idk what some of them are but it works
Expand Down
3 changes: 1 addition & 2 deletions pros/serial/devices/vex/v5_device.py
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why we are changing the vex port filter in an internet connectivity check PR, this should be removed/moved to a different PR

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

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

def filter_v5_ports(p, locations, names):
return (p.location is not None and any([p.location.endswith(l) for l in locations])) or \
Expand Down
17 changes: 17 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Compiled Object files
*.o
*.obj

# Executables
*.bin
*.elf

# PROS
bin/
.vscode/
.cache/
compile_commands.json
temp.log
temp.errors
*.ini
.d/
47 changes: 47 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
################################################################################
######################### User configurable parameters #########################
# filename extensions
CEXTS:=c
ASMEXTS:=s S
CXXEXTS:=cpp c++ cc

# probably shouldn't modify these, but you may need them below
ROOT=.
FWDIR:=$(ROOT)/firmware
BINDIR=$(ROOT)/bin
SRCDIR=$(ROOT)/src
INCDIR=$(ROOT)/include

WARNFLAGS+=
EXTRA_CFLAGS=
EXTRA_CXXFLAGS=

# Set to 1 to enable hot/cold linking
USE_PACKAGE:=1

# Add libraries you do not wish to include in the cold image here
# EXCLUDE_COLD_LIBRARIES:= $(FWDIR)/your_library.a
EXCLUDE_COLD_LIBRARIES:=

# Set this to 1 to add additional rules to compile your project as a PROS library template
IS_LIBRARY:=0
# TODO: CHANGE THIS!
# Be sure that your header files are in the include directory inside of a folder with the
# same name as what you set LIBNAME to below.
LIBNAME:=libbest
VERSION:=1.0.0
# EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c
# this line excludes opcontrol.c and similar files
EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext)))

# files that get distributed to every user (beyond your source archive) - add
# whatever files you want here. This line is configured to add all header files
# that are in the directory include/LIBNAME
TEMPLATE_FILES=$(INCDIR)/$(LIBNAME)/*.h $(INCDIR)/$(LIBNAME)/*.hpp

.DEFAULT_GOAL=quick

################################################################################
################################################################################
########## Nothing below this line should be edited by typical users ###########
-include ./common.mk
Loading
Loading