[PythonCE] PyCrypto binaries -- nearly there..
Marc Horst
marc.horst at scarlet.be
Sun Aug 5 22:16:45 CEST 2007
Hi Alexandre,
Thanks for your help! I made the change to Agent.py and my PDA is now
able to connect to the notebook, but then it crashes (see the logging
below):
>>> execfile('\\Flash
Disk\\Programmabestanden\\Python25\\Lib\\demo_pda.py')
*** Unable to open host keys file
*** WARNING: Unknown host key!
*** Here we go!
Line-buffered terminal emulation. Press F6 or ^Z to send EOF. Linux
marc-laptop 2.6.15-28-386 #1 PREEMPT Wed Jul 18 22:50:32 UTC 2007 i686
GNU/Linux The programs included with the Ubuntu system are free
software; the exact distribution terms for each program are described in
the individual files in /usr/share/doc/*/copyright. Ubuntu comes with
ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last
login: Sun Aug 5 20:53:55 2007 from 192.168.0.9
*** Caught exception: <type 'exceptions.IOError'>: [Errno 0] Error
Traceback (most recent call last):
File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
179, in <module>
interactive.interactive_shell(chan)
File "\Flash Disk\Programmabestanden\Python25\lib\interactive.py",
line 36, in interactive_shell
windows_shell(chan)
File "\Flash Disk\Programmabestanden\Python25\lib\interactive.py",
line 91, in windows_shell
d = sys.stdin.read(1)
IOError: [Errno 0] Error
*** EOF *** Traceback (most recent call last):
File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
190, in <module>
sys.exit(1)
File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
41, in dummy_exit
raise ExitError()
ExitError
>>>
I'm a newbee in Python and with ssh, so I can't make any conclusions
from this message; hopefully you can ;-)
Furthermore I tried the program you sent me as a replacement for demo.py
(I just changed the servername, username and password; that was all I
had to change, right?), but this didn't work (I tried it on my PC). When
trying it in IDLE, it gives the following message:
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from paramiko import SSHClient, AutoAddPolicy
>>>
>>> def main():
... client = SSHClient()
... client.set_missing_host_key_policy(AutoAddPolicy())
... client.connect('nyservername', username='myusername',
password='mypassword')
... stdin, stdout, stderr = client.exec_command('ls -l')
... print stdout.read()
... client.close()
...
>>> if __name__ == '__main__' : main()
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in main
File "C:\Python25\lib\site-packages\paramiko\client.py", line 266, in
connect
sock.connect((hostname, port))
File "<string>", line 1, in connect
TypeError: an integer is required
>>>
Could you please give me some help on this one too, as I would like to
avoid using the demo.py script ?
Thanks a lot,
Marc
alexandre.delattre at enst-bretagne.fr wrote:
> Marc Horst <marc.horst at scarlet.be> a écrit :
>
>> Hi Alexandre,
>>
>> That is a good hint! I tried it and here is the result:
>>
>> Python 2.5 (release25-maint, Dec 19 2006, 23:22:00) [MSC v.1201 32 bit
>> (ARM)] on win32
>>>>> execfile('\\Flash
>>>>> Disk\\Programmabestanden\\Python25\\Lib\\demo_pda.py')
>> *** Unable to open host keys file
>> *** WARNING: Unknown host key!
>> *** Caught exception: <type 'exceptions.ImportError'>: No module
>> named mmap
>> Traceback (most recent call last):
>> File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
>> 166, in <module>
>> agent_auth(t, username)
>> File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
>> 53, in agent_auth
>> agent = paramiko.Agent()
>> File "\Flash Disk\Programmabestanden\Python25\lib\paramiko\agent.py",
>> line 68, in __init__
>> import win_pageant
>> File "\Flash
>> Disk\Programmabestanden\Python25\lib\paramiko\win_pageant.py", line 27,
>> in <module>
>> import mmap
>> ImportError: No module named mmap
>> Traceback (most recent call last):
>> File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
>> 190, in <module>
>> sys.exit(1)
>> File "\Flash Disk\Programmabestanden\Python25\Lib\demo_pda.py", line
>> 41, in dummy_exit
>> raise ExitError()
>> ExitError
>>>>>
>>
>>
>> I looked on my __PC__ (as I guessed that if it worked on my PC, mmap
>> should be called here too) for a file named mmap and for files with as
>> content mmap, but found only test_mmap.py. So I'm not sure what should
>> be concluded from this. Maybe that on my __PDA__ a different execution
>> path is used, in which mmap is/should be imported, which results in the
>> error message above.
>>
>> Maybe you can conclude more from this error message.
>>
>>
>> Regards,
>>
>> Marc
>>
>>
>> alexandre.delattre at enst-bretagne.fr wrote:
>>> I will try to run paramiko+pycrypto myself, i strongly suspect
>>> paramiko to call sys.exit on some condition, so in the meantime you
>>> can try to insert this in the beginning of your code (before any
>>> other import):
>>>
>>> import sys
>>>
>>> class ExitError(Exception):
>>> pass
>>>
>>> def dummy_exit(code=0):
>>> raise ExitError()
>>>
>>> sys.exit = dummy_exit
>>>
>>> and see if it raises an exception instead of quitting, then you can
>>> track-down the source to locate the condition ...
>>>
>>> I'm not sure if it will help, but it may be worth trying.
>>>
>>> Alexandre.
>>>
>
> The mmap module hasn't been ported yet to PythonCE, this afternoon I
> have tried to use paramiko on my pda and found the same error. I have
> managed to bypass it by modifying agent.py, around line 67 make the
> following modifications :
>
> Replace :
> ...
> elif sys.platform == 'win32':
> import win_pageant
> ...
> by
> ...
> elif sys.platform == 'win32':
> if os.name == 'ce':
> return
> import win_pageant
> ...
>
> this deactivates the Agent features of paramiko but it makes ssh
> connection possible !
>
> Besides, I suggest you to use the new SSHClient class that basically
> wraps the whole demo script, I had success with the following script :
>
> from paramiko import SSHClient, AutoAddPolicy
>
> def main():
> client = SSHClient()
> client.set_missing_host_key_policy(AutoAddPolicy())
> client.connect('the server', username='****', password='****')
> stdin, stdout, stderr = client.exec_command('ls -l')
> print stdout.read()
> client.close()
>
> if __name__ == '__main__' : main()
>
> Good continuation on your project ;)
> Alexandre.
>
More information about the PythonCE
mailing list