~muffinresearch/bzr-email/bzr-email-keychain

« back to all changes in this revision

Viewing changes to smtp_connection.py

  • Committer: Stuart Colville
  • Date: 2007-08-14 15:15:32 UTC
  • Revision ID: scol@yahoo-inc.com-20070814151532-ryhx5tptqj4wha86
Failures to find keychain items now raise proper bzr errors + Item and keychain strings are now quoted

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
            
113
113
    def _getKeychainCredentials(self,keychain,item):
114
114
      import commands,re
115
 
      resp = commands.getoutput("security find-generic-password -g -s "+item+" "+keychain+".keychain") 
 
115
      resp = commands.getoutput("security find-generic-password -g -s '"+item+"' '"+keychain+".keychain'") 
116
116
      if resp.find('The specified item could not be found') != -1:
117
 
        print 'The specified item could not be found'
 
117
        raise errors.BzrCommandError('The specified keychain item(s) could not be found') 
118
118
      if resp:
119
119
        password = re.search('password: "(.*?)"', resp, re.DOTALL)
120
120
        account = re.search('"acct"<blob>="(.*?)"', resp, re.DOTALL)
121
121
        if password and account:
122
122
          return {"account":account.group(1),"password":password.group(1)}
123
123
        else:
124
 
          print 'Keychain item not found'        
 
124
          raise errors.BzrCommandError('The specified keychain item(s) could not be found')
125
125
 
126
126
    @staticmethod
127
127
    def _split_address(address):