OpenSecurity/bin/ui/format_drive_dialog.py
changeset 213 2e0b94e12bfc
parent 208 973b5888eec6
child 240 d7ef04254e9c
     1.1 --- a/OpenSecurity/bin/ui/format_drive_dialog.py	Thu Jun 26 12:14:08 2014 +0200
     1.2 +++ b/OpenSecurity/bin/ui/format_drive_dialog.py	Fri Jul 18 13:45:09 2014 +0100
     1.3 @@ -35,13 +35,15 @@
     1.4  import base64
     1.5  import sys
     1.6  
     1.7 +import urllib
     1.8 +import urllib2
     1.9 +
    1.10  from PyQt4 import QtCore
    1.11  from PyQt4 import QtGui
    1.12  
    1.13  from ui_FormatDriveDialog import Ui_FormatDriveDialog 
    1.14  from about_dialog import AboutDialog
    1.15  
    1.16 -
    1.17  # ------------------------------------------------------------
    1.18  # code
    1.19  
    1.20 @@ -61,7 +63,7 @@
    1.21  <br/>
    1.22  <b>This is irreversible.</b><br/>
    1.23  <br/>
    1.24 -Please provide an approbitate password and keyfile to proceed:
    1.25 +Please provide an appropriate password or keyfile to proceed:
    1.26  """ % ip
    1.27  
    1.28          # setup the user interface
    1.29 @@ -104,10 +106,10 @@
    1.30          
    1.31          """Ok button has been clicked."""
    1.32  
    1.33 -        init_data = {}
    1.34 +        init_data = dict()
    1.35          
    1.36          # pick the password
    1.37 -        init_data['password'] = self.ui.edtPassword.text()
    1.38 +        init_data['password'] = str(self.ui.edtPassword.text())
    1.39          if len(init_data['password']) == 0:
    1.40              QtGui.QMessageBox.critical(self, 'Format error', 'Please specify a password.')
    1.41              return
    1.42 @@ -128,17 +130,19 @@
    1.43              keyfile_content_base64 = base64.b64encode(keyfile_content)
    1.44              init_data['keyfile'] = keyfile_content_base64
    1.45  
    1.46 +        res = ""
    1.47          try:
    1.48 -            req = urllib2.Request('http://' + ip + ':58081/init', urllib.urlencode(init_data))
    1.49 +            req_data = urllib.urlencode(init_data)
    1.50 +            req = urllib2.Request('http://' + ip + ':58081/init', req_data)
    1.51              res = urllib2.urlopen(req)
    1.52          except:
    1.53 -            print('EXCEPTION')
    1.54 +            print('EXCEPTION ' + res)
    1.55              pass
    1.56  
    1.57          self.accept()
    1.58  
    1.59  
    1.60 -    def set_user_text(user_text):
    1.61 +    def set_user_text(self, user_text):
    1.62  
    1.63          """Set a text to explain which password we need."""
    1.64          self.ui.lblText.setText(user_text)