changeset 140:3e0868f4509e

Fix ssh_key_fingerprint to remove the created file and return the proper fingerprint
author Jonathan Gonzalez V <zeus@gnu.org>
date Sat, 19 Sep 2009 17:50:30 -0400
parents 68c7c716d012
children 590011d54cca
files src/savane/utils/__init__.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/savane/utils/__init__.py
+++ b/src/savane/utils/__init__.py
@@ -17,6 +17,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 import os
+import random
+import time
+import re
 from subprocess import Popen, PIPE
 
 def ssh_key_fingerprint( ssh_key ):
@@ -31,9 +34,14 @@
 
     cmd = 'ssh-keygen -l -f %s' % file_name
     pipe = Popen( cmd, shell=True, stdout=PIPE).stdout
-    res = re.search("not a public key file", pipe.readline())
+    ssh_fp = pipe.readline()
+
+    cmd = 'rm %s' % file_name
+    piep = Popen( cmd, shell=True, stdout=PIPE)
+
+    res = re.search("not a public key file", ssh_fp)
     if res is not None:
-        raise forms.ValidationError( "The uploaded string is not a public key file" )
+        raise 'Not a public key'
 
-    return ssh_key
+    return ssh_fp