Jon Salz | f10ef79 | 2014-04-01 14:25:36 +0800 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | # |
| 3 | # Copyright (c) 2014 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | |
| 8 | """A command-line tool for reg code handling.""" |
| 9 | |
| 10 | |
| 11 | import factory_common # pylint: disable=W0611 |
| 12 | from cros.factory.hacked_argparse import CmdArg, Command, ParseCmdline |
| 13 | from cros.factory.test.registration_codes import RegistrationCode |
| 14 | |
| 15 | |
| 16 | @Command('decode', |
| 17 | CmdArg('regcode', metavar='REGCODE', |
| 18 | help='Encoded registration code string')) |
| 19 | def Decode(options): |
| 20 | reg_code = RegistrationCode(options.regcode) |
| 21 | if reg_code.proto: |
| 22 | print reg_code.proto |
| 23 | else: |
| 24 | print reg_code |
| 25 | |
| 26 | |
| 27 | def main(): |
| 28 | options = ParseCmdline('Registration code tool.') |
| 29 | options.command(options) |
| 30 | |
| 31 | |
| 32 | if __name__ == '__main__': |
| 33 | main() |