@@ -0,0 +1,2548 @@
+#!/usr/bin/env python%0A%0Aimport getpass%0Aimport sys%0A%0Afrom optparse import OptionParser%0A%0Atry:%0A    from ZSI.client import AUTH%0Aexcept ImportError:%0A    print '==%3E Failed to import ZSI'%0A    print '===%3E Please make sure you have it installed and locatable from PYTHONPATH'%0A    print '     http://pywebsvcs.sourceforge.net/'%0A    print %0A    sys.exit(-1)%0A%0Aclass GetTokenError(Exception):%0A    pass%0A%0Adef getToken(opts, password):%0A    if not opts.production:%0A        from staging import CommonService_client%0A        from staging import CommonService_types%0A    else:%0A        from production import CommonService_client%0A        from production import CommonService_types%0A%0A    locator = CommonService_client.CommonServiceLocator()%0A    service = locator.getCommonServiceSoap(auth=(4, opts.user, password))%0A    request = CommonService_client.GetClientTokenSoapIn()%0A    request._request = CommonService_types.ns0.GetClientToken_Dec()%0A    request._specification = CommonService_types.ns0.TokenSpecification_Def(opts.user)%0A    request._specification._ClientIPAddress = opts.clientip%0A    request._specification._TokenValidityDurationMinutes = int(opts.tokenvalidity)%0A%0A    result = service.GetClientToken(request)%0A    if result.__class__.__name__ == 'GetClientTokenResponse_Holder':%0A        return result._GetClientTokenResult%0A    raise GetTokenError('Web service failed to return a proper response! %25s' %25 result)%0A%0A%0Adef main():%0A    _op = OptionParser()%0A    _op.add_option('--user', dest='user', help='User ID for Virtual Earth%5C's Web Services')%0A    _op.add_option('--production', dest='production', action='store_true', help='Generate a token for production use')%0A    _op.add_option('--clientip', dest='clientip', default='0.0.0.0', help='Specify the ClientIPAddress argument for the CommonService.GetClientToken() API')%0A    _op.add_option('--tokenvalidity', dest='tokenvalidity', default='480', help='Specify to TokenValidityDurationInMinutes argument for CommonService.GetClientToken(), must be between 15 and 480')%0A    _op.add_option('--password', dest='password', default=None, help='Password for Virtual Earth%5C's Web Services')%0A    opts, args = _op.parse_args()%0A%0A    if not opts.user:%0A        print '==%3E Missing %22user%22 argument'%0A        print%0A        _op.print_help()%0A        return -1%0A%0A    password = opts.password%0A    if not opts.password:%0A        password = getpass.getpass(prompt='Virtual Earth Password: ')%0A    token = getToken(opts, password)%0A    print '==%3E Generated token: %25s' %25 token%0A    return 0%0A%0Aif __name__ == '__main__':%0A    rc = main()%0A    sys.exit(rc)%0A

Add a basic module and command-line tool for generating tokens