Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #!/usr/bin/python3.5
  2.  
  3. import os
  4. import sys
  5. import subprocess
  6.  
  7. #p = subprocess.Popen('whoami', shell=True, stdout=subprocess.PIPE)
  8. #username = p.communicate()
  9. username = 'usuario'
  10. userHome = '/home/'+username
  11. #print (username)
  12. #print (userHome)
  13.  
  14. #El primer argumendo de la lista de argumentos es la ruta del propio fichero .py
  15. if len(sys.argv) != 2:
  16. print("Necesitas pasar como argumento un fichero con extensión .idsl o .ice ")
  17. else:
  18. if sys.argv[1].count('.idsl') == 0 and sys.argv[1].count('.ice') == 0 :
  19. print ("Necesitas pasar como argumento un fichero con extensión .idsl o .ice. "
  20. "Tienen que estar ambos ficheros.")
  21. else:
  22. if sys.argv[1].count('.idsl') > 0:
  23. interfaz = sys.argv[1].replace('.idsl', '')
  24. elif sys.argv[1].count('.ice') > 0:
  25. interfaz = sys.argv[1].replace('.ice', '')
  26.  
  27.  
  28. print (interfaz)
  29. command1 = 'cp '+ interfaz +'.ice /opt/robocomp/interfaces'
  30. command2 = 'cp ' + interfaz + '.idsl /opt/robocomp/interfaces/IDSLs'
  31. command3 = 'cp ' + interfaz + '.ice /home/' + username + '/robocomp/interfaces'
  32. command4 = 'cp ' + interfaz + '.idsl /home/' + username + '/robocomp/interfaces/IDSLs'
  33.  
  34. print ("Copiando interfaz...")
  35. print('Ejecutamos comando ' + command1)
  36. os.system(command1)
  37. print('Ejecutamos comando ' + command2)
  38. os.system(command2)
  39. print('Ejecutamos comando ' + command3)
  40. os.system(command3)
  41. print('Ejecutamos comando ' + command4)
  42. os.system(command4)
  43. #os.system('cp '+interfaz+'.ice' )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement