# Publish to NEW VPS folder research/popular-strategies/ (backs up first if exists). Same pattern as recov/publish_recov.py. import paramiko,os,glob,time,html N='popular-strategies'; R=f'/opt/apps/rl-trading-nifty/results/research/{N}'; L='/workspace/research/popular-strategies' for sub in ['results','scripts','charts']: fs=sorted(os.path.basename(f) for f in glob.glob(f'{L}/{sub}/*') if os.path.isfile(f) and not f.endswith(('.pyc','index.html'))) open(f'{L}/{sub}/index.html','w').write('

'+sub+'

back

") c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) c.connect('187.127.176.216',username='root',key_filename='/home/box/.ssh/vps_aitrade',timeout=25) def run(cmd): i,o,e=c.exec_command(cmd); out=o.read().decode()+e.read().decode(); print(out.strip()); return out ts=time.strftime('%Y%m%d-%H%M%S') run(f'if [ -e {R} ]; then mkdir -p /opt/apps/rl-trading-nifty/backups && tar czf /opt/apps/rl-trading-nifty/backups/{N}.{ts}.tgz -C {os.path.dirname(R)} {N} && echo backed-up; else echo new-folder; fi') run(f'mkdir -p {R}/charts {R}/results {R}/scripts') s=c.open_sftp(); n=0 for f in ['index.html','PREREG.md']: s.put(f'{L}/{f}',f'{R}/{f}'); n+=1 for sub in ['charts','results','scripts']: for f in glob.glob(f'{L}/{sub}/*'): if os.path.isfile(f) and not f.endswith('.pyc'): s.put(f,f'{R}/{sub}/'+os.path.basename(f)); n+=1 s.close(); print('uploaded',n) run(f'chmod -R a+rX {R}; du -sh {R}') for u in ['','PREREG.md','charts/rolling60.png','results/','results/primary_results.csv','scripts/','scripts/lib.py']: run(f'curl -sk -o /dev/null -w "%{{http_code}} {u}\\n" --max-time 15 --resolve aitradeanalytics.tech:443:127.0.0.1 https://aitradeanalytics.tech/rl-trading/research/{N}/{u}')