def main(argv):
    '''Main function.'''

    sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)

    opt_parser = OptionParser()

    opt_parser.add_option('--description', dest='description', 
                          action='store',
                          help='description for service secret file')

    opt_parser.add_option('--output-file', dest='output_file_name',
                          action='store',
                          help='destination file for service secret')

    #   Explicit reference to argv is for benefit of unittest.
    opt, leftover_arg_list = opt_parser.parse_args(argv[1:])

    if len(leftover_arg_list):
        print >> sys.stderr, opt_parser.get_usage()
        sys.exit(1)

    write_hexdigest(generate_hexdigest(), 
                    path_random=opt.output_file_name, 
                    description=opt.description)

    sys.exit(0)
示例#2
0
    def __init__(self, **kw_arg_dict):
        if not 'application_id' in kw_arg_dict:
            raise KeyError('application_id not specified')

        application_id = kw_arg_dict.pop('application_id')

        super(WSAPIAnnouncer, self).__init__(**kw_arg_dict)

        #   Save application ID.
        self.application_id     = application_id

        #   Generate private and public key pair.
        self.session_private    = hexdigest.generate_hexdigest()
        self.session_public     = self._hash_with_service_secret \
                                    (self.session_private)
        return None