Skip to content

Commit 5b2c3e2

Browse files
committed
1.55 hopefully final
1 parent fd59b39 commit 5b2c3e2

9 files changed

Lines changed: 74 additions & 35 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dist/
99
installer
1010
lib/__pycache__/
1111
output/
12-
src/__pycache__/
12+
src/__pycache__/
13+
tach.toml

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ echo "Installation finished with no errors."
6868

6969
ATTENTION - If you use an old version of this software, it might ask you for a "product key." This system has been retired, so it may confuse you. Please paste the code `4p6jgtnatqj5svb4` if it asks you for one.
7070

71+
### Telemetry and Data sharing
72+
73+
In order to catch more bugs, v1.55 introduces opt-in telemetry that will transmit crash logs to Enderbyte Programs. This is in an effort to find more bugs and issues. You will be prompted to select a telemetry level on your first startup after updating. To opt in to sending crash reports, please select level 2 or 3 for telemetry. If you would not like to, please select level 1 or 0. You may change the telemetry level at any time by going to Settings -> Telemetry level.
74+
7175
## Integrating Third Party Software
7276

7377
If you would like to make your application work with CRSS, here is how to do so

assets/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: craftserversetup
2-
Version: 1.54.9
2+
Version: 1.55
33
Maintainer: Enderbyte Programs <enderbyte09@gmail.com>
44
Homepage: https://github.com/Enderbyte-Programs/CraftServerSetup
55
Architecture: all

src/chatutils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import logutils
1111
import dirstack
1212
import utils
13+
import telemetry
1314

1415
def who_said_what(stdscr,serverdir):
16+
telemetry.telemetric_action("chatutils")
1517
if uicomponents.resource_warning(stdscr):
1618
return
1719
renaminghandler.autoupdate_cache(stdscr,serverdir)

src/eptel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ def send_action(actionname:str) -> None:
4646
def send_crash(ex:Exception) -> None:
4747

4848
#Process exception
49-
tb = traceback.format_exception(ex)
49+
tb = "\n".join(traceback.format_exception(ex))
5050

5151
try:
52-
threading.Thread(target=_send,args=[Constants.ACTION_REPORT_ENDPOINT,{
52+
threading.Thread(target=_send,args=[Constants.CRASH_REPORT_ENDPOINT,{
5353
"version" : 1,#EPTEL request format v1
5454
"payload" : {
5555
"productname" : Constants.product_name,

src/main.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import random #Random number generation
2626
import traceback #Error management
2727
import webbrowser #Open links like the bug link
28-
import tarfile #Create archives
2928
import gzip #Compression utilities
3029
import time #Timezone data
3130
import copy #Object copies
@@ -241,13 +240,11 @@ def error_handling(e:Exception,message="A serious error has occured"):
241240
_SCREEN.clear()
242241
_SCREEN.nodelay(0)
243242
_SCREEN.bkgd(cursesplus.set_colour(cursesplus.BLUE,cursesplus.WHITE))
244-
#cursesplus.messagebox.showerror(_SCREEN,[
245-
# "o3 / We are sorry, but a serious error occured ",
246-
# " - | In the next menu, you will choose some options",
247-
# "o3 \\ You should probably report this as a bug "
248-
#])
243+
244+
telemetry.crash_report(e)
245+
249246
while True:
250-
erz = cursesplus.optionmenu(_SCREEN,["Exit Program","View Error info","Return to main menu","Advanced options","Report bug on GitHub"],f"{message}. What do you want to do?")
247+
erz = cursesplus.optionmenu(_SCREEN,["Exit Program","View Error info","Return to main menu","Advanced options","Report bug on GitHub"],f":( {message}. What do you want to do?")
251248
if erz == 0:
252249
safe_exit(1)
253250
elif erz == 1:
@@ -302,16 +299,16 @@ def safe_error_handling(e:Exception):
302299
raw = f"TYPE: {type(e)}"+"\n"+f"MESSAGE: {str(e)[0:os.get_terminal_size()[0]-1]}"+"\n"+traceback.format_exc()
303300
#splitext = textwrap.wrap(raw,_SCREEN.getmaxyx()[1]-1)
304301
splitext = raw.splitlines()
302+
303+
telemetry.crash_report(e)
304+
305305
while True:
306306
_SCREEN.clear()
307307
my,mx = _SCREEN.getmaxyx()
308-
cursesplus.utils.fill_line(_SCREEN,0,cursesplus.set_colour(cursesplus.RED,cursesplus.WHITE))
309-
cursesplus.utils.fill_line(_SCREEN,1,cursesplus.set_colour(cursesplus.RED,cursesplus.WHITE))
310-
cursesplus.utils.fill_line(_SCREEN,2,cursesplus.set_colour(cursesplus.RED,cursesplus.WHITE))
311308
_SCREEN.addstr(3,0,"─"*(mx-1))
312-
_SCREEN.addstr(0,0,"A fatal error has occured in CraftServerSetup. Info is listed below.",cursesplus.set_colour(cursesplus.RED,cursesplus.WHITE))
313-
_SCREEN.addstr(1,0,"Press C to return to the main menu.",cursesplus.set_colour(cursesplus.RED,cursesplus.WHITE))
314-
_SCREEN.addstr(2,0,"Press R to open a bug report on Github. Include information listed below.",cursesplus.set_colour(cursesplus.RED,cursesplus.WHITE))
309+
_SCREEN.addstr(0,0,":( A fatal error has occured in CraftServerSetup. Info is listed below.",cursesplus.set_colour(cursesplus.BLUE,cursesplus.WHITE))
310+
_SCREEN.addstr(1,0,">>> Press C to return to the main menu.",cursesplus.set_colour(cursesplus.BLUE,cursesplus.WHITE))
311+
_SCREEN.addstr(2,0,">>> Press R to open a bug report on Github. Include information listed below.",cursesplus.set_colour(cursesplus.BLUE,cursesplus.WHITE))
315312
ey = 3
316313
for eline in splitext:
317314
ey += 1
@@ -2068,6 +2065,7 @@ def formattediplist_getindexbyip(search:str,haystack:list[FormattedIP]):
20682065
return None
20692066

20702067
def ip_lookup(stdscr,serverdir):
2068+
telemetry.telemetric_action("iplookup")
20712069
if uicomponents.resource_warning(stdscr):
20722070
return
20732071
renaminghandler.autoupdate_cache(stdscr,serverdir)
@@ -2508,7 +2506,7 @@ def write(path:str,data:dict) -> None:
25082506
f.write(gzip.compress(json.dumps(data).encode()))
25092507

25102508
def sanalytics(stdscr,serverdir):
2511-
2509+
telemetry.telemetric_action("analytics")
25122510
if uicomponents.resource_warning(stdscr):
25132511
return
25142512
renaminghandler.autoupdate_cache(stdscr,serverdir)
@@ -3287,6 +3285,7 @@ def create_uuid_index(stdscr) -> None:
32873285
appdata.updateappdata()
32883286

32893287
def playerstat(stdscr,serverdir):
3288+
telemetry.telemetric_action("playerstat")
32903289
worlds = find_world_folders(serverdir)
32913290
selworld = uicomponents.menu(stdscr,["Cancel"]+worlds,"Choose a world to search statistics for")
32923291
if selworld == 0:
@@ -4120,6 +4119,11 @@ def main(stdscr):
41204119
threading.Thread(target=internet_thread,args=(stdscr,)).start()
41214120
appdata.setup_appdata()
41224121
#Telemetry demands special startup
4122+
4123+
if appdata.APPDATA["telemetry"]["level"] == -1:
4124+
cursesplus.messagebox.showinfo(stdscr,["On the next screen, you will be prompted to","choose a telemetry level ","(how much data is sent to Enderbyte Programs)"])
4125+
telemetry.set_telemetry_level(stdscr,False)
4126+
41234127
eptel.startup(appdata.APPDATA["telemetry"]["telkey"],"CraftServerSetup",APP_UF_VERSION)
41244128
telemetry.telemetric_action("startup")
41254129

src/renaminghandler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Handle players renaming themselves"""
2+
13
import appdata
24
import os
35
import datetime
@@ -8,6 +10,7 @@
810
import re
911
import cursesplus
1012
import uicomponents
13+
import telemetry
1114

1215
NAMECHANGETRACKFILE = appdata.APPDATADIR + os.sep + "playeraliases.json"
1316
nctf_template = {
@@ -90,6 +93,7 @@ def autoupdate_cache(stdscr,serverdir):
9093
update_cache_custom(stdscr,logloader.load_logs(stdscr,serverdir,logfilters.player_rename,lastupdatetime))
9194

9295
def player_naming_history(stdscr):
96+
telemetry.telemetric_action("renhan")
9397
srch = uicomponents.crssinput(stdscr,"What player do you want to learn about?").lower()
9498
if not has_known_aliases(srch):
9599
cursesplus.messagebox.askyesno(stdscr,["This player has no known former names"])

src/telemetry.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class TelemetryLevels(enum.Enum):
1616

1717

1818
def get_telemetry_level() -> int:
19-
return appdata.APPDATA["telemetry"]["level"]
19+
try:
20+
return appdata.APPDATA["telemetry"]["level"]
21+
except:
22+
return 2#It's got to be contingent
2023

2124
def telemetric_action(actionname:str):
2225

@@ -29,23 +32,40 @@ def telemetric_action(actionname:str):
2932
#Send everything with COMPREHENSIVE
3033

3134
def crash_report(ex:Exception):
35+
3236
if get_telemetry_level() >= 2:
3337
eptel.send_crash(ex)
3438

35-
def set_telemetry_level(stdscr) -> None:
39+
def set_telemetry_level(stdscr,cancellable = True) -> None:
3640
"""Show the user a screen to select their telemetry level, and set this telemetry level"""
37-
op = uicomponents.menu(stdscr,["Cancel","0 - Nothing","1 - Basic Only","2 - Crash reports","3 - Comprehensive"],f"Please choose a telemetry level. Current level is: {get_telemetry_level()}",peroptionfooters=[
38-
"Do not change the telemetry level",
39-
"Send no telemetry whatsoever",
40-
"Send only a single 'installation exists' telemetry event",
41-
"Basic + send error details if a crash occurs",
42-
"Send comprehensive usage statistics"
43-
],preselected=3)
44-
45-
if op == 0:
46-
return
47-
48-
appdata.APPDATA["telemetry"]["level"] = op - 1
41+
42+
if cancellable:
43+
op = uicomponents.menu(stdscr,["Cancel","0 - Nothing","1 - Basic Only","2 - Crash reports","3 - Comprehensive"],f"Please choose a telemetry level. Current level is: {get_telemetry_level()}",peroptionfooters=[
44+
"Do not change the telemetry level",
45+
"Send no telemetry whatsoever",
46+
"Send only a single 'installation exists' telemetry event",
47+
"Basic + send error details if a crash occurs",
48+
"Send comprehensive usage statistics"
49+
],preselected=3)
50+
51+
if op == 0:
52+
return
53+
54+
appdata.APPDATA["telemetry"]["level"] = op - 1
55+
56+
else:
57+
op = uicomponents.menu(stdscr,["0 - Nothing","1 - Basic Only","2 - Crash reports","3 - Comprehensive"],f"Please choose a telemetry level.",peroptionfooters=[
58+
"Send no telemetry whatsoever",
59+
"Send only a single 'installation exists' telemetry event",
60+
"Basic + send error details if a crash occurs",
61+
"Send comprehensive usage statistics"
62+
],preselected=2)
63+
64+
if op == 0:
65+
return
66+
67+
appdata.APPDATA["telemetry"]["level"] = op
68+
4969
appdata.updateappdata()
5070

5171
cursesplus.messagebox.showinfo(stdscr,["Telemetry level updated successfully."])

src/usersettings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
import staticflags
1212
import backups
1313
import javamanager
14+
import telemetry
1415

1516
def manage_user_settings(stdscr):
17+
telemetry.telemetric_action("settings")
1618

1719
while True:
18-
m = uicomponents.menu(stdscr,["BACK","ADVANCED OPTIONS","MANAGE JAVA INSTALLATIONS","CHANGE LANGUAGE","BACKUP PROFILES"]+[d["display"] + " : " + str(d["value"]) for d in list(appdata.APPDATA["settings"].values())],"Please choose a setting to modify")
20+
m = uicomponents.menu(stdscr,["BACK","ADVANCED OPTIONS","Java Installations","Change Language","Manage Backup Profiles","Telemetry Level"]+[d["display"] + " : " + str(d["value"]) for d in list(appdata.APPDATA["settings"].values())],"Please choose a setting to modify")
1921
if m == 0:
2022
appdata.updateappdata()
2123
return
@@ -47,9 +49,11 @@ def manage_user_settings(stdscr):
4749
cursesplus.displaymsg(stdscr,["Craft Server Setup"],False)
4850
elif m == 4:
4951
backups.backup_manager(stdscr)
52+
elif m == 5:
53+
telemetry.set_telemetry_level(stdscr)
5054
else:
51-
selm = list(appdata.APPDATA["settings"].values())[m-5]
52-
selk = list(appdata.APPDATA["settings"].keys())[m-5]
55+
selm = list(appdata.APPDATA["settings"].values())[m-6]
56+
selk = list(appdata.APPDATA["settings"].keys())[m-6]
5357
if selm["type"] == "bool":
5458
selm["value"] = uicomponents.menu(stdscr,["True (Yes)","False (No)"],f"New value for {selm['display']}") == 0
5559
elif selm["type"] == "int":

0 commit comments

Comments
 (0)