Skip to content

Commit 4a18439

Browse files
committed
Added startup/shutdown messages
1 parent 2433c98 commit 4a18439

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

osc-chat-tools.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import time
3-
#import threading
3+
import threading
44
from threading import Thread, Lock
55
import ast
66
import sys
@@ -121,19 +121,19 @@
121121
def afk_handler(unused_address, args):
122122
global isAfk
123123
isAfk = args
124-
print('isAfk', isAfk)
124+
#print('isAfk', isAfk)
125125
outputLog('isAfk', isAfk)
126126

127127
def mute_handler(unused_address, args):
128128
global isMute
129129
isMute = args
130-
print('isMute',isMute)
130+
#print('isMute',isMute)
131131
outputLog('isMute',isMute)
132132

133133
def inSeat_handler(unused_address, args):
134134
global isInSeat
135135
isInSeat = args
136-
print('isInSeat',isInSeat)
136+
#print('isInSeat',isInSeat)
137137
outputLog('isInSeat',isInSeat)
138138

139139
def volume_handler(unused_address, args):
@@ -144,7 +144,7 @@ def volume_handler(unused_address, args):
144144
def usingEarmuffs_handler(unused_address, args):
145145
global isUsingEarmuffs
146146
isUsingEarmuffs = args
147-
print('isUsingEarmuffs', isUsingEarmuffs)
147+
#print('isUsingEarmuffs', isUsingEarmuffs)
148148
outputLog('isUsingEarmuffs', isUsingEarmuffs)
149149

150150
def vr_handler(unused_address, args):# The game never sends this value from what I've seen
@@ -153,7 +153,7 @@ def vr_handler(unused_address, args):# The game never sends this value from what
153153
isVR == True
154154
else:
155155
isVR == False
156-
print('isVR', isVR)
156+
#print('isVR', isVR)
157157
outputLog('isVR', isVR)
158158

159159
"""def thread_exists(name):
@@ -164,12 +164,15 @@ def vr_handler(unused_address, args):# The game never sends this value from what
164164

165165
message_queue = []
166166
queue_lock = Lock()
167-
168167
def outputLog(text):
168+
print(text)
169+
global threadName
170+
threadName = threading.current_thread().name
169171
def waitThread():
172+
global threadName
170173
timestamp = datetime.now()
171174
with queue_lock:
172-
message_queue.append((timestamp, text))
175+
message_queue.append((timestamp, "["+threadName+"] "+text))
173176
while windowAccess is None:
174177
time.sleep(.01)
175178
with queue_lock:
@@ -179,6 +182,8 @@ def waitThread():
179182
message_queue.clear()
180183
waitThreadHandler = Thread(target=waitThread)
181184
waitThreadHandler.start()
185+
186+
outputLog("OCT Starting...")
182187

183188
def update_checker(a):
184189
global updatePrompt
@@ -191,7 +196,7 @@ def update_checker(a):
191196
if response.ok:
192197
data = response.json()
193198
if int(data[0]["tag_name"].replace('v', '').replace('.', '').replace(' ', '').replace('Version', '').replace('version', '')) != int(version.replace('v', '').replace('.', '').replace(' ', '').replace('Version', '').replace('version', '')):
194-
print("A new version is available! "+ data[0]["tag_name"].replace('v', '').replace(' ', '').replace('Version', '').replace('version', '')+" > " + version.replace('v', '').replace(' ', '').replace('Version', '').replace('version', ''))
199+
#print("A new version is available! "+ data[0]["tag_name"].replace('v', '').replace(' ', '').replace('Version', '').replace('version', '')+" > " + version.replace('v', '').replace(' ', '').replace('Version', '').replace('version', ''))
195200
outputLog("A new version is available! "+ data[0]["tag_name"].replace('v', '').replace(' ', '').replace('Version', '').replace('version', '')+" > " + version.replace('v', '').replace(' ', '').replace('Version', '').replace('version', ''))
196201
if updatePrompt:
197202
def updatePromptWaitThread():
@@ -212,11 +217,11 @@ def waitThread():
212217
else:
213218
if a:
214219
windowAccess.write_event_value('popup', "Program is up to date! Version "+version)
215-
print("Program is up to date! Version "+version)
220+
#print("Program is up to date! Version "+version)
216221
outputLog("Program is up to date! Version "+version)
217222

218223
else:
219-
print('Update Checking Error occurred:', response.status_code)
224+
#print('Update Checking Error occurred:', response.status_code)
220225
outputLog('Update Checking Error occurred:', response.status_code)
221226

222227

@@ -273,13 +278,13 @@ def mediaIs(state):
273278
for i, x in enumerate(confDataDict[fixed_list[0]]):
274279
globals()[x] = fixed_list[i]
275280
#print(f"{x} = {fixed_list[i]}")
276-
print("Successfully Loaded config file version "+fixed_list[0])
281+
#print("Successfully Loaded config file version "+fixed_list[0])
277282
outputLog("Successfully Loaded config file version "+fixed_list[0])
278283
else:
279-
print('Config file is Too Old! Not Updating Values...')
284+
#print('Config file is Too Old! Not Updating Values...')
280285
outputLog('Config file is Too Old! Not Updating Values...')
281286
except:
282-
print('Config File Load Error! Not Updating Values...')
287+
#print('Config File Load Error! Not Updating Values...')
283288
outputLog('Config File Load Error! Not Updating Values...')
284289
def uiThread():
285290
global version
@@ -614,7 +619,7 @@ def updateUI():
614619
while True:
615620
event, values = window.read()
616621
#print(event, values)
617-
if event == sg.WIN_CLOSED or event == "Exit" or event == "You thought":
622+
if event == sg.WIN_CLOSED or event == "Exit":
618623
break
619624
if values['topNone']:
620625
window['topText'].update(value=False)
@@ -838,19 +843,13 @@ def checkPressThread():
838843
window['output'].update(new_text)
839844
if logOutput:
840845
with open('OCT_debug_log.txt', 'a+', encoding="utf-8") as f:
841-
if f.read() == '':
842-
f.write(values[event])
843-
else:
844-
f.write("\n"+values[event])
846+
f.write("\n"+values[event])
845847
window.close()
846848
playMsg = False
847849
run = False
848-
if listenServer != None:
849-
try:
850-
listenServer.shutdown()
851-
listenServer.server_close()
852-
except:
853-
pass
850+
if logOutput:
851+
with open('OCT_debug_log.txt', 'a+', encoding="utf-8") as f:
852+
f.write("\n"+str(datetime.now())+" OCT Shutting down...")
854853
def processMessage(a):
855854
returnList = []
856855
if messageString.count('\n')>0:
@@ -922,7 +921,7 @@ def dataSender():
922921
global useForewordMemory
923922
global oscForeword
924923
runForewordServer = True
925-
print('Starting Forwarding server on '+str(forward_addresses))
924+
#print('Starting Forwarding server on '+str(forward_addresses))
926925
outputLog('Starting Forwarding server on '+str(forward_addresses))
927926
oscListenAddressMemory = oscListenAddress
928927
oscListenPortMemory = oscListenPort
@@ -949,7 +948,7 @@ def dataSender():
949948
time.sleep(.1)
950949
if oscListenAddressMemory != oscListenAddress or oscListenPortMemory != oscListenPort or oscForewordPortMemory != oscForewordPort or oscForewordAddressMemory != oscForewordAddress or useForewordMemory != oscForeword or useForewordMemory != oscForeword or ((oscForeword or oscListen) and not runForewordServer):
951950
if oscForeword or oscListen:
952-
print('Foreword/Listen Server Config Updated, Restarting Forwarding Server...\n')
951+
#print('Foreword/Listen Server Config Updated, Restarting Forwarding Server...\n')
953952
outputLog('Foreword/Listen Server Config Updated, Restarting Forwarding Server...\n')
954953
runForewordServer = False
955954
time.sleep(.5)
@@ -958,7 +957,7 @@ def dataSender():
958957
dataSenderThread.start()
959958
if runForewordServer and not(oscForeword or oscListen):
960959
runForewordServer = False
961-
print('No OSC Foreword/Listening Options are selected, stopping Forwarding Server...')
960+
#print('No OSC Foreword/Listening Options are selected, stopping Forwarding Server...')
962961
outputLog('No OSC Foreword/Listening Options are selected, stopping Forwarding Server...')
963962
time.sleep(.5)
964963
oscForwardingManagerThread = Thread(target=oscForwardingManager)
@@ -985,7 +984,7 @@ def listenServerThread():
985984
try:
986985
listenServer = osc_server.ThreadingOSCUDPServer(
987986
(args.ip, args.port), dispatcher)
988-
print("Osc Listen Server Serving on {}".format(listenServer.server_address))
987+
#print("Osc Listen Server Serving on {}".format(listenServer.server_address))
989988
outputLog("Osc Listen Server Serving on {}".format(listenServer.server_address))
990989
sockett = listenServer.socket
991990
sockett.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
@@ -994,15 +993,15 @@ def listenServerThread():
994993

995994
listenServer.serve_forever()
996995
except Exception as e:
997-
print('Osc Listen Server Failed to Start, Retying...'+str(e))
996+
#print('Osc Listen Server Failed to Start, Retying...'+str(e))
998997
outputLog('Osc Listen Server Failed to Start, Retying...'+str(e))
999998
pass
1000999

10011000
if not isListenServerRunning:
10021001
oscServerThread = Thread(target=listenServerThread)
10031002
oscServerThread.start()
10041003
if not oscListen and isListenServerRunning:
1005-
print('No OSC Listen Options are Selected, Shutting Down OSC Listen Server...')
1004+
#print('No OSC Listen Options are Selected, Shutting Down OSC Listen Server...')
10061005
outputLog('No OSC Listen Options are Selected, Shutting Down OSC Listen Server...')
10071006
isListenServerRunning = False
10081007
listenServer.shutdown()
@@ -1077,6 +1076,7 @@ def sendMsg(a):
10771076
else:
10781077
if windowAccess != None:
10791078
try:
1079+
logOutput('mediaManagerError! '+str(e))
10801080
windowAccess.write_event_value('mediaManagerError', e)
10811081
except:
10821082
pass
@@ -1262,15 +1262,15 @@ def blinkHR():
12621262
time.sleep(60/int(heartRate))
12631263
blinkHRThread = Thread(target=blinkHR)
12641264
blinkHRThread.start()
1265-
print('Pulsoid Connection Started...')
1265+
#print('Pulsoid Connection Started...')
12661266
outputLog('Pulsoid Connection Started...')
12671267
except Exception as e:
12681268
if windowAccess != None:
12691269
if playMsg:
12701270
windowAccess.write_event_value('pulsoidError', e)
12711271
if ((not topHRToggle and not bottomHRToggle and not avatarHR) or not (playMsg or avatarHR)) and hrConnected:
12721272
hrConnected = False
1273-
print('Pulsoid Connection Stopped')
1273+
#print('Pulsoid Connection Stopped')
12741274
outputLog('Pulsoid Connection Stopped')
12751275
time.sleep(.3)
12761276
hrConnectionThreadRun = Thread(target=hrConnectionThread)

0 commit comments

Comments
 (0)