63 lines
2.5 KiB
Python
63 lines
2.5 KiB
Python
import io
|
|
p = r'C:\Users\locpham\SonicForgeStudio\native_bridge\src\gui_probe.cpp'
|
|
s = io.open(p, encoding='utf-8', newline='').read()
|
|
|
|
def crlf(x): return x.replace('\n', '\r\n')
|
|
|
|
old = crlf(''' auto t0 = std::chrono::steady_clock::now();
|
|
while (!done.load() && std::chrono::duration_cast<std::chrono::seconds>(
|
|
std::chrono::steady_clock::now() - t0).count() < secs) {
|
|
MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}
|
|
Sleep(2);
|
|
}''')
|
|
new = crlf(''' auto t0 = std::chrono::steady_clock::now();
|
|
try {
|
|
while (!done.load() && std::chrono::duration_cast<std::chrono::seconds>(
|
|
std::chrono::steady_clock::now() - t0).count() < secs) {
|
|
MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}
|
|
Sleep(2);
|
|
}
|
|
} catch (const std::exception& e) { printf("[main] PUMP1 EXCEPTION: %s\\n", e.what()); fflush(stdout); }
|
|
catch (...) { printf("[main] PUMP1 UNKNOWN EXCEPTION\\n"); fflush(stdout); }''')
|
|
n = s.count(old)
|
|
print('pump1 count:', n)
|
|
s = s.replace(old, new)
|
|
|
|
old2 = crlf(''' auto t1 = std::chrono::steady_clock::now();
|
|
while (std::chrono::duration_cast<std::chrono::seconds>(
|
|
std::chrono::steady_clock::now() - t1).count() < 5) {
|
|
MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}
|
|
Sleep(2);
|
|
}''')
|
|
new2 = crlf(''' auto t1 = std::chrono::steady_clock::now();
|
|
try {
|
|
while (std::chrono::duration_cast<std::chrono::seconds>(
|
|
std::chrono::steady_clock::now() - t1).count() < 5) {
|
|
MSG msg;
|
|
while (PeekMessageW(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
|
TranslateMessage(&msg);
|
|
DispatchMessageW(&msg);
|
|
}
|
|
Sleep(2);
|
|
}
|
|
} catch (const std::exception& e) { printf("[main] PUMP2 EXCEPTION: %s\\n", e.what()); fflush(stdout); }
|
|
catch (...) { printf("[main] PUMP2 UNKNOWN EXCEPTION\\n"); fflush(stdout); }''')
|
|
n2 = s.count(old2)
|
|
print('pump2 count:', n2)
|
|
s = s.replace(old2, new2)
|
|
|
|
io.open(p, 'w', encoding='utf-8', newline='').write(s)
|
|
print('written')
|