[PythonCE] PyCrypto binaries -- nearly there..

alexandre.delattre at enst-bretagne.fr alexandre.delattre at enst-bretagne.fr
Sat Aug 4 20:48:48 CEST 2007


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