Advertisement
Guest User

En entier

a guest
Aug 13th, 2017
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.92 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. from __future__ import unicode_literals
  4. from prompt_toolkit import prompt
  5. from prompt_toolkit.history import InMemoryHistory
  6. from urllib.request import urlopen
  7. import bs4 as BeautifulSoup
  8. import webbrowser
  9. import paramiko
  10. import getpass
  11.  
  12. def main():
  13.     history = InMemoryHistory()
  14.    
  15.     #login = input('Login as: ')
  16.     #passd = getpass.getpass(prompt='Password for ' + login + ': ')
  17.  
  18.     while True:
  19.         text = prompt("> ", history=history)
  20.         while text == '':
  21.             text = prompt("> ", history=history)
  22.            
  23.         if text == 'verif':
  24.             print(main_1)
  25.        
  26.         if text == 'help':
  27.             print('''Help commands: cpe dsl help load main show www''')
  28.        
  29.         # Available commands
  30.         elif text == 'load':
  31.             print('Choose a number between 1 and 10')
  32.        
  33.         elif text == 'en 1':
  34.             while True:
  35.                 text = prompt("(en 1)> ", history=history)
  36.                 while text == '':
  37.                     text = prompt("(en 1)> ", history=history)
  38.            
  39.                 if text == 'load':
  40.                     main1 = urlopen('file:///C:/Users/gperru/Desktop/main1.jsp').read()
  41.                     msoup1 = BeautifulSoup.BeautifulSoup(main1, 'lxml')
  42.                     lmain1 = msoup1.get_text().split('\n')
  43.                     id_se1 = lmain1[lmain1.index('/bds/id_service_administratif') +1]
  44.                     nom_u1 = lmain1[lmain1.index('/bds/contrat/site_coord/nom_usuel') +1]
  45.                     siren1 = lmain1[lmain1.index('/bds/contrat/siren') +1]
  46.                     nom_p1 = lmain1[lmain1.index('/facturation/gestionnaire_flotte/nom_prenom') + 1]
  47.                     telep1 = lmain1[lmain1.index('/facturation/gestionnaire_flotte/telephone') + 1]
  48.                     cdp_n1 = lmain1[lmain1.index('/bds/Cdp_Nom') +1]
  49.                     cdp_t1 = lmain1[lmain1.index('/bds/Cdp_Tel') +1]
  50.                     cdp_e1 = lmain1[lmain1.index('/bds/Cdp_Email') +1]
  51.                     inter1 = lmain1[lmain1.index('/intervention/installateur/@value') +1]
  52.        
  53.                     cpe1 = urlopen('file:///C:/Users/gperru/Desktop/cpe1.jsp').read()
  54.                     csoup1 = BeautifulSoup.BeautifulSoup(cpe1, 'lxml')
  55.                     lcpe1 = csoup1.get_text().split('\n')
  56.                     id_co1 = lcpe1[lcpe1.index('/bds/id_commande') +1]
  57.                     id_pa1 = lcpe1[lcpe1.index('/bds/cpe/config/id_package') +1]
  58.                     ip_lo1 = lcpe1[lcpe1.index('/bds/confip/ip_loopback_ce') +1]
  59.                     data21 = lcpe1[lcpe1.index('/temp/data224') +1]
  60.                     adres1 = lcpe1[lcpe1.index('/bds/config/priseip/vlan1/adresse_lan1') +1]
  61.            
  62.                     dsl1 = urlopen('file:///C:/Users/gperru/Desktop/dsl1.jsp').read()
  63.                     dsoup1 = BeautifulSoup.BeautifulSoup(dsl1, 'lxml')
  64.                     ldsl1 = dsoup1.get_text().split('\n')
  65.                     ref_s1 = ldsl1[ldsl1.index('/bds/acces/ref_service_activation_bipaire') +1]
  66.                     code_1 = ldsl1[ldsl1.index('/bds/acces/code_offre') +1]
  67.                     degro1 = ldsl1[ldsl1.index('/bds/acces/degroupage/type') +1]
  68.                     const1 = ldsl1[ldsl1.index('/bds/acces/constitution_ft') +1]
  69.                     nom_s1 = ldsl1[ldsl1.index('/bds/acces/nom_service') +1]
  70.                     condu1 = ldsl1[ldsl1.index('/bds/acces/conduit') +1]
  71.                     niv2_1 = ldsl1[ldsl1.index('/bds/acces/niv2_acces') +1]
  72.                     logi_1 = ldsl1[ldsl1.index('/bds/acces/login_ppp') +1]
  73.                    
  74.                 elif text == 'save':
  75.                     list_of_1 = id_se1, nom_u1, siren1, nom_p1, telep1, cdp_n1, cdp_t1,
  76.                     cdp_e1, inter1
  77.                     main_1 = en_1(list_of_1)
  78.                     #main_1 = en_1(list_of_1)
  79.                     print('Saved')
  80.                    
  81.                     #cpe_1 = id_co1, id_pa1, ip_lo1, data21, adres1
  82.                     #dsl_1 = ref_s1, code_1, degro1, const1, nom_s1, condu1, niv2_1,
  83.                     #logi_1
  84.                    
  85.                 elif text == 'main':
  86.                     print(id_se1+',', nom_u1+',', siren1+',', nom_p1+',', telep1+',',
  87.                     cdp_n1+',', cdp_t1+',', cdp_e1+',', inter1)
  88.        
  89.                 elif text == 'cpe':
  90.                     print(id_co1+',', id_pa1+',', ip_lo1+',', data21+',', adres1)
  91.            
  92.                 elif text == 'dsl':
  93.                     print(ref_s1+',', code_1+',', degro1+',', const1+',', nom_s1+',',
  94.                     condu1+',', niv2_1+',', logi_1+',')
  95.            
  96.                 elif text == 'router':
  97.                     try:
  98.                         ssh = paramiko.SSHClient()
  99.                         ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  100.                         ssh.connect('192.168.1.20', port=22, username='gregory', password='tirelli32')
  101.                         stdin, stdout, stderr = ssh.exec_command('ps x')
  102.                         stdin1, stdout1, stderr1 = ssh.exec_command('ls -la')
  103.                         stdin2, stdout2, stderr2 = ssh.exec_command('pwd')
  104.                         output = stdout.readlines()
  105.                         output1 = stdout1.readlines()
  106.                         output2 = stdout2.readlines()
  107.                         print('\n'.join(output))
  108.                         print('\n'.join(output1))
  109.                         print('\n'.join(output2))
  110.                     except:
  111.                         return main()
  112.                    
  113.                 elif text == 'exit':
  114.                     return main()
  115.                 else:
  116.                     print('error')
  117.        
  118.         elif text == 'www':
  119.             print('Select a bookmark')
  120.         elif text == 'www bao':
  121.             webbrowser.open('http://intranetstc.private.sfr.com:8081/auth/index.php')
  122.         elif text == 'www cerbere':
  123.             webbrowser.open('http://cerbere-portal.private.sfr.com/')
  124.         elif text == 'www comon':
  125.             webbrowser.open('http://comon.prod.ld/comon/')
  126.         elif text == 'www cpe':
  127.             webbrowser.open('http://recette-cpe.private.sfr.com/recette/index.php')
  128.         elif text == 'www diag':
  129.             webbrowser.open('https://www.diag.sfr.net/index.php')
  130.         elif text == 'www doris':
  131.             webbrowser.open('http://doris.private.sfr.com/doris/')
  132.         elif text == 'www extranet':
  133.             webbrowser.open('https://intranetclient.private.sfr.com/intra/servlet/IntranetApplicationServlet/')
  134.         elif text == 'www gix':
  135.             webbrowser.open('http://gix-prod-neufcegetel.private.sfr.com:6665/authentification.php')
  136.         elif text == 'www icare':
  137.             webbrowser.open('https://p2s.9services.com/ICARE_IHM/login.aspx')
  138.         elif text == 'www kpsa':
  139.             webbrowser.open('http://intra-oss/trans_Web/pageAccueil.do')
  140.         elif text == 'www pacman':
  141.             webbrowser.open('http://pacman.private.sfr.com:8097/formulaireConnexionLDAP.php')
  142.         elif text == 'www pegase':
  143.             webbrowser.open('http://ulysseservices-prod-neuf.private.sfr.com:8083/pegase/')
  144.         elif text == 'www reflex':
  145.             webbrowser.open('http://reflex.private.sfr.com/secure/Dashboard.jspa')
  146.         elif text == 'www sigma':
  147.             webbrowser.open('http://sigmaent.private.sfr.com/sigmaent/login/LoginPage?-1.IFormSubmitListener-loginForm')
  148.         elif text == 'www ulysse':
  149.             webbrowser.open('http://ulysseservices-prod-neuf.private.sfr.com:8083/ULYSSE_SERVICES_2/')
  150.            
  151.         # Help commands
  152.         elif text == 'help help':
  153.             print('Displays the documentation for the given command')
  154.            
  155.         elif text == 'help www':
  156.             print('''Bookmarks: bao cerbere comon cpe diag doris extranet gix icare kpsa pacman
  157. pegase reflex sigma ulysse''')
  158.         else:
  159.             print('Unknown command:', text)
  160.  
  161. if __name__ == '__main__':
  162.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement