~marcoceppi/charm-tools/icon-template

« back to all changes in this revision

Viewing changes to scripts/subscribers

  • Committer: Mark Mims
  • Date: 2013-04-02 23:00:31 UTC
  • mfrom: (172.1.2 charm-tools)
  • Revision ID: mark.mims@canonical.com-20130402230031-59d5omk2rzrmkx8v
merging lp:~ubuntuone-pqm-team/charm-tools/trunk from https://code.launchpad.net/~ubuntuone-pqm-team/charm-tools/trunk/+merge/156709, really should wait til packaging changes land https://code.launchpad.net/~ubuntuone-pqm-team/ubuntu/raring/charm-tools/raring/+merge/156710 but the head is already broken so it wont matter

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    in the specified repository so that metadata.yaml can be inspected
37
37
    to find the maintainer.""")
38
38
parser.add_argument('--subscribed', default=False, action='store_true',
39
 
    help='Show maintainers who are properly subscribed instead of '
40
 
    + 'unsubscribed')
 
39
                    help='Show maintainers who are properly subscribed '
 
40
                    'instead of unsubscribed')
41
41
parser.add_argument('--repository', default=None, type=str,
42
 
    help='Repository to look for charms in. Defaults to $JUJU_REPOSITORY '
43
 
    + 'or getcwd')
 
42
                    help='Repository to look for charms in. Defaults to '
 
43
                    '$JUJU_REPOSITORY or getcwd')
44
44
parser.add_argument('--quiet', default=False, action='store_true',
45
 
    help='Hide everything except maintainer subscription lists.')
 
45
                    help='Hide everything except maintainer subscription '
 
46
                    'lists.')
46
47
parser.add_argument('--series', '-s', default=None,
47
 
    help='Which series of the charm store to run against. Defaults to '
48
 
    + 'current dev focus')
 
48
                    help='Which series of the charm store to run against. '
 
49
                    'Defaults to current dev focus')
49
50
parser.add_argument('--maintainer', default=None,
50
 
    help='Limit output to this maintainer\'s charms only.')
 
51
                    help='Limit output to this maintainer\'s charms only.')
51
52
parser.add_argument('--log-priority', default='WARNING')
52
53
parser.add_argument('--launchpad-instance', default='production')
53
54
parser.add_argument('--fix-unsubscribed', default=False, action='store_true',
54
 
    help='Add a bug subscription for any unsubscribed maintainers. Requires '
55
 
    + '--maintainer')
 
55
                    help='Add a bug subscription for any unsubscribed '
 
56
                    'maintainers. Requires --maintainer')
56
57
parser.add_argument('--force-fix-all', default=False, action='store_true',
57
 
    help=argparse.SUPPRESS)
 
58
                    help=argparse.SUPPRESS)
58
59
parser.add_argument('charms', default=[], nargs='*',
59
 
    help='Charms to check for subscriptions')
 
60
                    help='Charms to check for subscriptions')
60
61
 
61
62
args = parser.parse_args()
62
63
 
79
80
    log_prio = logging.DEBUG
80
81
 
81
82
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
82
 
    level=log_prio)
 
83
                    level=log_prio)
83
84
 
84
85
if args.quiet:
85
86
    logging.disable(logging.WARNING)
86
87
 
87
88
if args.maintainer is None and args.fix_unsubscribed:
88
89
    warn('Running --fix-unsubscribed and without --maintainer is against'
89
 
        + ' policy.')
 
90
         ' policy.')
90
91
    if not args.force_fix_all:
91
92
        warn('Use --force-fix-all to override policy')
92
93
        sys.exit(1)
103
104
    login = launchpad.Launchpad.login_anonymously
104
105
 
105
106
lp = login(app_name, args.launchpad_instance,
106
 
        version='devel', launchpadlib_dir=launchpadlib_dir)
 
107
           version='devel', launchpadlib_dir=launchpadlib_dir)
107
108
 
108
109
charmdistro = lp.distributions['charms']
109
110
 
132
133
for charm_name in charms:
133
134
    try:
134
135
        with open('%s/%s/%s/metadata.yaml' % (repository, current_series,
135
 
                charm_name)) as mdata:
 
136
                                              charm_name)) as mdata:
136
137
            mdata_parsed = yaml.safe_load(mdata)
137
138
    except IOError:
138
139
        warn('%s/%s has no metadata in charm repo' % (current_series,
139
 
            charm_name))
 
140
                                                      charm_name))
140
141
        continue
141
142
    try:
142
143
        maintainers = mdata_parsed['maintainer']
153
154
                               for m in maintainers]
154
155
            if args.maintainer not in maints_by_email:
155
156
                debug('%s not in maintainer list %s' % (args.maintainer,
156
 
                    maintainers))
 
157
                                                        maintainers))
157
158
                continue
158
159
 
159
160
    for maintainer in maintainers:
178
179
                print msg
179
180
            if args.fix_unsubscribed:
180
181
                info('adding bug subscription to %s for %s' % (charm_name,
181
 
                    maint_email))
 
182
                                                               maint_email))
182
183
                pkg.addBugSubscription(subscriber=lp_maintainer)