import os import re import sys import paramiko pw = os.environ["DEPLOY_PASSWORD"] c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect("20.191.152.26", username="wakka", password=pw, timeout=30) cmd = r""" html=$(curl -s "http://127.0.0.1:7777/cw/widget?website_token=j1UAjqBgZMWQ8WfczgJSymQx" -H "Host: 20.191.152.26:7777") python3 - <<'PY' import os, re, subprocess, tempfile html = os.popen('''curl -s "http://127.0.0.1:7777/cw/widget?website_token=j1UAjqBgZMWQ8WfczgJSymQx" -H "Host: 20.191.152.26:7777"''').read() print('len', len(html)) print('pullTags', html.count('function pullTags')) print('tagOpen.replace', html.count('tagOpen.replace')) print('polishQuickQuestions', html.count('polishQuickQuestions')) print('PROMO_SRC', 'PROMO_SRC' in html) print('{3,}', '{3,}' in html) # extract all script bodies and node-check scripts = re.findall(r'', html) print('scripts', len(scripts)) ok = 0 fail = 0 for i, s in enumerate(scripts): with tempfile.NamedTemporaryFile('w', suffix='.js', delete=False) as f: f.write(s) path = f.name r = subprocess.run(['node', '--check', path], capture_output=True, text=True) if r.returncode != 0: fail += 1 print('FAIL script', i, r.stderr[:400]) # show around error line m = re.search(r':(\d+)', r.stderr) if m: ln = int(m.group(1)) lines = s.splitlines() for j in range(max(0, ln-3), min(len(lines), ln+2)): print(f'{j+1}: {lines[j][:160]}') else: ok += 1 print('node_ok', ok, 'node_fail', fail) PY """ _, o, e = c.exec_command(cmd, timeout=60) sys.stdout.write(o.read().decode("utf-8", "replace")) err = e.read().decode("utf-8", "replace") if err: sys.stderr.write(err[:1000]) c.close()