Commits

Ville Suoranta authored 50bfa7782d7 Merge
Merge pull request #3 in CASA/casatelemetry from fix-startup-messages to master

* commit '3345a624370ab8d058828a4e43d13c41db527b34': Write startup to stderr

casatelemetry/private/casatelemetry.py

Modified
5 5 import datetime
6 6 import time
7 7 import urllib.request
8 8 import urllib.error
9 9 import casatools
10 10 import casatasks
11 11 from casatelemetry import CrashReporter
12 12 import casatelemetry.private.TelemetryLogMonitor as TelemetryLogMonitor
13 13 import ssl
14 14 import logging
15 +import sys
15 16
16 17 class telemetry:
17 18
18 19 def __init__(self):
19 20
20 21 from pathlib import Path
21 22 home = str(Path.home())
22 23 self.casalogger = casatools.logsink()
23 24 self.setCasaVersion()
24 25 self.setHostId()
72 73 tLogSizeLimit = int(casatasks.config.telemetry_log_limit)
73 74 self.casalogger.post("tLogSizeLimit: " + str(tLogSizeLimit))
74 75 if (casatasks.config.telemetry_log_size_interval != None):
75 76 tLogSizeInterval = int(casatasks.config.telemetry_log_size_interval)
76 77 self.casalogger.post("tLogSizeInterval: " + str(tLogSizeInterval))
77 78
78 79 # Subtract the inactive log sizes from the total log file size limit
79 80 tLogSizeLimit = tLogSizeLimit - inactiveTLogSize
80 81 #print("tLogSizeLimit " + str(tLogSizeLimit))
81 82 if (tLogSizeLimit <= 0):
82 - print ("Telemetry log size limit exceeded. Disabling telemetry.")
83 + print ("Telemetry log size limit exceeded. Disabling telemetry.", file=sys.stderr)
83 84 self.telemetry_enabled = False
84 85 else :
85 86 tLogMonitor = TelemetryLogMonitor.TelemetryLogMonitor(ct_instance=self)
86 87 tLogMonitor.start(self.logfile,tLogSizeLimit, tLogSizeInterval)
87 88 if self.telemetry_enabled:
88 - print ("Telemetry initialized. Telemetry will send anonymized usage statistics to NRAO.")
89 - print ('You can disable telemetry by adding the following line to the config.py file in your rcdir (f.e. ~/.casa/config.py):')
90 - print ('telemetry_enabled = False')
89 + print ("Telemetry initialized. Telemetry will send anonymized usage statistics to NRAO.", file=sys.stderr)
90 + print ('You can disable telemetry by adding the following line to the config.py file in your rcdir (f.e. ~/.casa/config.py):', file=sys.stderr)
91 + print ('telemetry_enabled = False', file=sys.stderr)
91 92
92 93 def setNewTelemetryFile(self):
93 94 try:
94 95 self.logger.removehandler(self.loghandler)
95 96 except:
96 97 pass
97 98 self.logfile = self.logdir + '/casastats-' + self.casaver +'-' + self.hostid + "-" + time.strftime("%Y%m%d-%H%M%S", time.gmtime()) + self.variantSuffix + '.log'
98 99 self.init_log_file()
99 100
100 101 def init_log_file(self):

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut