Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. Process Process-3:
  2. Traceback (most recent call last):
  3. File "/usr/local/lib/python3.4/pickle.py", line 272, in _getattribute
  4. obj = getattr(obj, subpath)
  5. AttributeError: 'module' object has no attribute 'SRE_Match'
  6.  
  7. During handling of the above exception, another exception occurred:
  8.  
  9. Traceback (most recent call last):
  10. File "/usr/local/lib/python3.4/pickle.py", line 909, in save_global
  11. obj2 = _getattribute(module, name, allow_qualname=self.proto >= 4)
  12. File "/usr/local/lib/python3.4/pickle.py", line 275, in _getattribute
  13. .format(name, obj))
  14. AttributeError: Can't get attribute 'SRE_Match' on <module '_sre' (built-in)>
  15.  
  16. During handling of the above exception, another exception occurred:
  17.  
  18. Traceback (most recent call last):
  19. File "/home/ande/.local/lib/python3.4/site-packages/multiprocess-0.70.4-py3.4-linux-x86_64.egg/multiprocess/process.py", line 254, in _bootstrap
  20. self.run()
  21. File "/home/ande/.local/lib/python3.4/site-packages/multiprocess-0.70.4-py3.4-linux-x86_64.egg/multiprocess/process.py", line 93, in run
  22. self._target(*self._args, **self._kwargs)
  23. File "./SSHHandlerMin.py", line 41, in testSSH
  24. mDict[devName] = child
  25. ...
  26.  
  27. #!/usr/local/bin/python3
  28.  
  29. import pexpect
  30. import getpass
  31.  
  32. from multiprocess import Process, Manager
  33.  
  34.  
  35. def wLauncher(workerDef, maxWorkers, *args):
  36. workQueue = args[0]
  37. wQLen = workQueue.qsize()
  38. procNum = 0
  39. if (maxWorkers > wQLen):
  40. procNum = wQLen
  41. else:
  42. procNum = maxWorkers
  43.  
  44. #Create Workers
  45. processes = list()
  46. for worker in range(procNum):
  47. workerProcess = Process(target=workerDef, args=(args))
  48. workerProcess.start()
  49. processes.append(workerProcess)
  50. workQueue.put('STOP')
  51. # Wait for all workers to complete their tasks
  52. for process in processes:
  53. process.join()
  54.  
  55. def testSSH(*args):
  56. wQ = args[0]
  57. user = args[1]
  58. password = args[2]
  59. mDict = args[3]
  60. cmd = args[4]
  61.  
  62.  
  63. for device in iter(wQ.get, 'STOP'):
  64. child = pexpect.spawn("ssh -t "+user+"@"+device)
  65. i = child.expect(['assword:', r'yes/no',pexpect.EOF,pexpect.TIMEOUT],timeout=30)
  66. if i == 0:
  67. mDict[devName] = child
  68. elif i == 1:
  69. mDict[devName] = child
  70.  
  71. #__main__
  72. if __name__ == "__main__":
  73.  
  74. username = getpass.getuser()
  75. passPrompt = username+' password:'
  76. password = getpass.getpass(passPrompt)
  77. devName = input('Enter Device Name/IP: ')
  78. cmd = 'date'
  79. workQueue = Manager().Queue()
  80. mDict = Manager().dict()
  81.  
  82. deviceList = []
  83. workQueue.put(devName)
  84. wLauncher(testSSH,30,workQueue,username,password,mDict,cmd)
  85.  
  86. print(mDict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement