Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.45 KB | None | 0 0
  1. import paramiko
  2.  
  3. from flask import render_template, redirect, url_for, flash
  4. from buvr import app
  5.  
  6. @app.route("/")
  7. def index1():
  8.     return render_template('first.html')
  9.  
  10. @app.route("/single_units")
  11. def index2():
  12.     return render_template('second.html')  
  13.  
  14. @app.route("/start_all")
  15. def start_all():
  16.     host = '16.10.155.2'
  17.     user = 'bkc'
  18.     secret = 'buvr2016'
  19.     port = 30022
  20.    
  21.     client = paramiko.SSHClient()
  22.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  23.     client.connect(hostname=host, username=user, password=secret, port=port)
  24.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  25.     data = stdout.read() + stderr.read()
  26.     client.close()
  27.     flash("ok")
  28.     return redirect(url_for('index1'))
  29.    
  30. @app.route("/stop_all")
  31. def stop_all():
  32.     host = '16.10.155.2'
  33.     user = 'bkc'
  34.     secret = 'buvr2016'
  35.     port = 30022
  36.    
  37.     client = paramiko.SSHClient()
  38.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  39.     client.connect(hostname=host, username=user, password=secret, port=port)
  40.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  41.     data = stdout.read() + stderr.read()
  42.     client.close()
  43.     flash("ok")
  44.     return redirect(url_for('index1'))
  45.    
  46. @app.route("/start3")
  47. def start3():
  48.     host = '16.10.155.3'
  49.     user = 'bkc'
  50.     secret = 'buvr2016'
  51.     port = 30022
  52.    
  53.     client = paramiko.SSHClient()
  54.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  55.     client.connect(hostname=host, username=user, password=secret, port=port)
  56.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  57.     data = stdout.read() + stderr.read()
  58.     client.close()
  59.     flash("ok")
  60.     return redirect(url_for('index2'))
  61.    
  62. @app.route("/start4")
  63. def start4():
  64.     host = '16.10.155.4'
  65.     user = 'bkc'
  66.     secret = 'buvr2016'
  67.     port = 30022
  68.    
  69.     client = paramiko.SSHClient()
  70.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  71.     client.connect(hostname=host, username=user, password=secret, port=port)
  72.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  73.     data = stdout.read() + stderr.read()
  74.     client.close()
  75.     flash("ok")
  76.     return redirect(url_for('index2'))
  77.    
  78. @app.route("/start5")
  79. def start5():
  80.     host = '16.10.155.5'
  81.     user = 'bkc'
  82.     secret = 'buvr2016'
  83.     port = 30022
  84.    
  85.     client = paramiko.SSHClient()
  86.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  87.     client.connect(hostname=host, username=user, password=secret, port=port)
  88.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  89.     data = stdout.read() + stderr.read()
  90.     client.close()
  91.     flash("ok")
  92.     return redirect(url_for('index2'))
  93.    
  94. @app.route("/start6")
  95. def start6():
  96.     host = '16.10.155.6'
  97.     user = 'bkc'
  98.     secret = 'buvr2016'
  99.     port = 30022
  100.    
  101.     client = paramiko.SSHClient()
  102.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  103.     client.connect(hostname=host, username=user, password=secret, port=port)
  104.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  105.     data = stdout.read() + stderr.read()
  106.     client.close()
  107.     flash("ok")
  108.     return redirect(url_for('index2'))
  109.    
  110. @app.route("/start7")
  111. def start7():
  112.     host = '16.10.155.7'
  113.     user = 'bkc'
  114.     secret = 'buvr2016'
  115.     port = 30022
  116.    
  117.     client = paramiko.SSHClient()
  118.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  119.     client.connect(hostname=host, username=user, password=secret, port=port)
  120.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  121.     data = stdout.read() + stderr.read()
  122.     client.close()
  123.     flash("ok")
  124.     return redirect(url_for('index2'))
  125.    
  126. @app.route("/start8")
  127. def start8():
  128.     host = '16.10.155.8'
  129.     user = 'bkc'
  130.     secret = 'buvr2016'
  131.     port = 30022
  132.    
  133.     client = paramiko.SSHClient()
  134.     client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  135.     client.connect(hostname=host, username=user, password=secret, port=port)
  136.     stdin, stdout, stderr = client.exec_command('vlc -vvv --play-and-exit /home/buvr/sirena8.mp3')
  137.     data = stdout.read() + stderr.read()
  138.     client.close()
  139.     flash("ok")
  140.     return redirect(url_for('index2'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement