Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from __future__ import unicode_literals
- from prompt_toolkit import prompt
- from prompt_toolkit.history import InMemoryHistory
- from urllib.request import urlopen
- import bs4 as BeautifulSoup
- import webbrowser
- import paramiko
- import getpass
- def main():
- history = InMemoryHistory()
- #login = input('Login as: ')
- #passd = getpass.getpass(prompt='Password for ' + login + ': ')
- while True:
- text = prompt("> ", history=history)
- while text == '':
- text = prompt("> ", history=history)
- if text == 'verif':
- print(main_1)
- if text == 'help':
- print('''Help commands: cpe dsl help load main show www''')
- # Available commands
- elif text == 'load':
- print('Choose a number between 1 and 10')
- elif text == 'en 1':
- while True:
- text = prompt("(en 1)> ", history=history)
- while text == '':
- text = prompt("(en 1)> ", history=history)
- if text == 'load':
- main1 = urlopen('file:///C:/Users/gperru/Desktop/main1.jsp').read()
- msoup1 = BeautifulSoup.BeautifulSoup(main1, 'lxml')
- lmain1 = msoup1.get_text().split('\n')
- id_se1 = lmain1[lmain1.index('/bds/id_service_administratif') +1]
- nom_u1 = lmain1[lmain1.index('/bds/contrat/site_coord/nom_usuel') +1]
- siren1 = lmain1[lmain1.index('/bds/contrat/siren') +1]
- nom_p1 = lmain1[lmain1.index('/facturation/gestionnaire_flotte/nom_prenom') + 1]
- telep1 = lmain1[lmain1.index('/facturation/gestionnaire_flotte/telephone') + 1]
- cdp_n1 = lmain1[lmain1.index('/bds/Cdp_Nom') +1]
- cdp_t1 = lmain1[lmain1.index('/bds/Cdp_Tel') +1]
- cdp_e1 = lmain1[lmain1.index('/bds/Cdp_Email') +1]
- inter1 = lmain1[lmain1.index('/intervention/installateur/@value') +1]
- cpe1 = urlopen('file:///C:/Users/gperru/Desktop/cpe1.jsp').read()
- csoup1 = BeautifulSoup.BeautifulSoup(cpe1, 'lxml')
- lcpe1 = csoup1.get_text().split('\n')
- id_co1 = lcpe1[lcpe1.index('/bds/id_commande') +1]
- id_pa1 = lcpe1[lcpe1.index('/bds/cpe/config/id_package') +1]
- ip_lo1 = lcpe1[lcpe1.index('/bds/confip/ip_loopback_ce') +1]
- data21 = lcpe1[lcpe1.index('/temp/data224') +1]
- adres1 = lcpe1[lcpe1.index('/bds/config/priseip/vlan1/adresse_lan1') +1]
- dsl1 = urlopen('file:///C:/Users/gperru/Desktop/dsl1.jsp').read()
- dsoup1 = BeautifulSoup.BeautifulSoup(dsl1, 'lxml')
- ldsl1 = dsoup1.get_text().split('\n')
- ref_s1 = ldsl1[ldsl1.index('/bds/acces/ref_service_activation_bipaire') +1]
- code_1 = ldsl1[ldsl1.index('/bds/acces/code_offre') +1]
- degro1 = ldsl1[ldsl1.index('/bds/acces/degroupage/type') +1]
- const1 = ldsl1[ldsl1.index('/bds/acces/constitution_ft') +1]
- nom_s1 = ldsl1[ldsl1.index('/bds/acces/nom_service') +1]
- condu1 = ldsl1[ldsl1.index('/bds/acces/conduit') +1]
- niv2_1 = ldsl1[ldsl1.index('/bds/acces/niv2_acces') +1]
- logi_1 = ldsl1[ldsl1.index('/bds/acces/login_ppp') +1]
- elif text == 'save':
- list_of_1 = id_se1, nom_u1, siren1, nom_p1, telep1, cdp_n1, cdp_t1,
- cdp_e1, inter1
- main_1 = en_1(list_of_1)
- #main_1 = en_1(list_of_1)
- print('Saved')
- #cpe_1 = id_co1, id_pa1, ip_lo1, data21, adres1
- #dsl_1 = ref_s1, code_1, degro1, const1, nom_s1, condu1, niv2_1,
- #logi_1
- elif text == 'main':
- print(id_se1+',', nom_u1+',', siren1+',', nom_p1+',', telep1+',',
- cdp_n1+',', cdp_t1+',', cdp_e1+',', inter1)
- elif text == 'cpe':
- print(id_co1+',', id_pa1+',', ip_lo1+',', data21+',', adres1)
- elif text == 'dsl':
- print(ref_s1+',', code_1+',', degro1+',', const1+',', nom_s1+',',
- condu1+',', niv2_1+',', logi_1+',')
- elif text == 'router':
- try:
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect('192.168.1.20', port=22, username='gregory', password='tirelli32')
- stdin, stdout, stderr = ssh.exec_command('ps x')
- stdin1, stdout1, stderr1 = ssh.exec_command('ls -la')
- stdin2, stdout2, stderr2 = ssh.exec_command('pwd')
- output = stdout.readlines()
- output1 = stdout1.readlines()
- output2 = stdout2.readlines()
- print('\n'.join(output))
- print('\n'.join(output1))
- print('\n'.join(output2))
- except:
- return main()
- elif text == 'exit':
- return main()
- else:
- print('error')
- elif text == 'www':
- print('Select a bookmark')
- elif text == 'www bao':
- webbrowser.open('http://intranetstc.private.sfr.com:8081/auth/index.php')
- elif text == 'www cerbere':
- webbrowser.open('http://cerbere-portal.private.sfr.com/')
- elif text == 'www comon':
- webbrowser.open('http://comon.prod.ld/comon/')
- elif text == 'www cpe':
- webbrowser.open('http://recette-cpe.private.sfr.com/recette/index.php')
- elif text == 'www diag':
- webbrowser.open('https://www.diag.sfr.net/index.php')
- elif text == 'www doris':
- webbrowser.open('http://doris.private.sfr.com/doris/')
- elif text == 'www extranet':
- webbrowser.open('https://intranetclient.private.sfr.com/intra/servlet/IntranetApplicationServlet/')
- elif text == 'www gix':
- webbrowser.open('http://gix-prod-neufcegetel.private.sfr.com:6665/authentification.php')
- elif text == 'www icare':
- webbrowser.open('https://p2s.9services.com/ICARE_IHM/login.aspx')
- elif text == 'www kpsa':
- webbrowser.open('http://intra-oss/trans_Web/pageAccueil.do')
- elif text == 'www pacman':
- webbrowser.open('http://pacman.private.sfr.com:8097/formulaireConnexionLDAP.php')
- elif text == 'www pegase':
- webbrowser.open('http://ulysseservices-prod-neuf.private.sfr.com:8083/pegase/')
- elif text == 'www reflex':
- webbrowser.open('http://reflex.private.sfr.com/secure/Dashboard.jspa')
- elif text == 'www sigma':
- webbrowser.open('http://sigmaent.private.sfr.com/sigmaent/login/LoginPage?-1.IFormSubmitListener-loginForm')
- elif text == 'www ulysse':
- webbrowser.open('http://ulysseservices-prod-neuf.private.sfr.com:8083/ULYSSE_SERVICES_2/')
- # Help commands
- elif text == 'help help':
- print('Displays the documentation for the given command')
- elif text == 'help www':
- print('''Bookmarks: bao cerbere comon cpe diag doris extranet gix icare kpsa pacman
- pegase reflex sigma ulysse''')
- else:
- print('Unknown command:', text)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement