Revision c2cf27e8 image_creator/main.py

b/image_creator/main.py
64 64
    usage = "Usage: %prog [options] <input_media>"
65 65
    parser = optparse.OptionParser(version=version, usage=usage)
66 66

  
67
    token = os.environ["OKEANOS_TOKEN"] if "OKEANOS_TOKEN" in os.environ \
68
        else None
69

  
70 67
    parser.add_option("-o", "--outfile", type="string", dest="outfile",
71 68
                      default=None, action="callback",
72 69
                      callback=check_writable_dir, help="dump image to FILE",
......
95 92
                      action="append", metavar="KEY=VALUE")
96 93

  
97 94
    parser.add_option("-t", "--token", dest="token", type="string",
98
                      default=token, help="use this authentication token when "
99
                      "uploading/registering images [Default: %s]" % token)
95
                      default=None, help="use this authentication token when "
96
                      "uploading/registering images")
100 97

  
101 98
    parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
102 99
                      help="print the enabled and disabled system preparation "
......
190 187
                                 "(use --force to overwrite it)" % filename)
191 188

  
192 189
    # Check if the authentication token is valid. The earlier the better
193
    try:
194
        account = Kamaki.get_account(options.token)
195
        if account is None:
196
            raise FatalError("The authentication token you provided is not "
197
                             "valid!")
198
    except ClientError as e:
199
        raise FatalError("Astakos client: %d %s" % (e.status, e.message))
190
    if options.token is not None:
191
        try:
192
            account = Kamaki.get_account(options.token)
193
            if account is None:
194
                raise FatalError("The authentication token you provided is not"
195
                                 " valid!")
196
        except ClientError as e:
197
            raise FatalError("Astakos client: %d %s" % (e.status, e.message))
198

  
200 199

  
201 200
    disk = Disk(options.source, out, options.tmp)
202 201

  

Also available in: Unified diff