~ubuntu-branches/ubuntu/trusty/screenlets/trusty

« back to all changes in this revision

Viewing changes to src/share/screenlets/MailCheck/keyring-test.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2011-02-24 00:51:35 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110224005135-p65cxwmpfwwy3woi
Tags: 0.1.2+bzr616-0ubuntu1
* New upstream snapshot.
 - Move individual screenlets into another source package.
 - Many bug fixes since 0.1.2.
* Convert to source format 3.0 (quilt).
* debian/patches
 - Removed all patches, merged upstream.
* debian/rules:
 - Convert to dh7.
 - Don't remove copies of feedparser, not in this package.
 - Don't remove empty directory for the individual screenlets.
* debian/screenlets.install:
 - Update installed files.
* debian/compat
 - Bump to level 7.
* debian/control:
 - Rewrite Depends and build-depends.
* README.Debian :
 - Mention mutter as a composite manager.
* debian/README.source:
 - Remove the README.source.
* debian/screenlets.manpages:
 - Add the manpages.
* debian/copyright:
 - Rewrite with dep5 style.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This application is released under the GNU General Public License 
2
 
# v3 (or, at your option, any later version). You can find the full 
3
 
# text of the license under http://www.gnu.org/licenses/gpl.txt. 
4
 
# By using, editing and/or distributing this software you agree to 
5
 
# the terms and conditions of this license. 
6
 
# Thank you for using free software!
7
 
 
8
 
#  keyring-test.py(c) RYX 2007 <ryx [at] ryxperience [dot] com>
9
 
 
10
 
import gtk
11
 
 
12
 
 
13
 
try: 
14
 
        import gnomekeyring 
15
 
except ImportError: 
16
 
        HAVE_GNOMEKEYRING = False 
17
 
else: 
18
 
        HAVE_GNOMEKEYRING = True 
19
 
 
20
 
# TEST:
21
 
#import gobject
22
 
#gtk.set_application_name("keyring-test")
23
 
if HAVE_GNOMEKEYRING:
24
 
        # check availability
25
 
        if not gnomekeyring.is_available():
26
 
                print "Keyring not available."
27
 
        # list names of keyrings and use the first one we can find
28
 
        keyring_list = gnomekeyring.list_keyring_names_sync()
29
 
        if len(keyring_list) == 0:
30
 
                print "No keyrings available."
31
 
                import sys
32
 
                sys.exit(1)
33
 
        else:
34
 
                print "We have %i keyrings" % len(keyring_list)
35
 
                print "KEYRING: %s" % keyring_list[0]
36
 
        # name/password to store
37
 
        name            = 'myname'
38
 
        password        = 'mysecret'
39
 
        # get default keyring
40
 
        keyring = gnomekeyring.get_default_keyring_sync()       # crashes if no default exists
41
 
        # create attributes
42
 
        attribs = dict(name=name, magic='something')
43
 
        
44
 
        # create keyring item with password
45
 
        auth_token = gnomekeyring.item_create_sync(keyring, 
46
 
                gnomekeyring.ITEM_GENERIC_SECRET, name, attribs, password, True) 
47
 
        print auth_token
48
 
        print "save: token for account %s: %i" % (name, auth_token) 
49
 
        token = "gnomekeyring:%i" % (auth_token,) 
50
 
        print token
51
 
        
52
 
        # now read it back from the keyring
53
 
        print "Password read from keyring is:"
54
 
        print gnomekeyring.item_get_info_sync(keyring, auth_token).get_secret()
55