(self, args)
| 85 | |
| 86 | @enter_temp_path |
| 87 | def do_register(self, args): |
| 88 | from base64 import urlsafe_b64decode |
| 89 | filename = args.get('filename') |
| 90 | with open(filename, 'wb') as f: |
| 91 | i = args['filedata'].find('base64,') + len('base64,') |
| 92 | f.write(urlsafe_b64decode(args['filedata'][i:])) |
| 93 | |
| 94 | cmd_args = ['reg'] |
| 95 | is_initial = filename.endswith('.txt') |
| 96 | if is_initial: |
| 97 | self._check_arg('product', args) |
| 98 | cmd_args.extend(['-y', '-p', args.get('product')]) |
| 99 | if filename[-8:-4].isdigit() and filename[-9] == '-': |
| 100 | if int(filename[-8:-4]) < 4000: |
| 101 | cmd_args.append('-u') |
| 102 | cmd_args.append(filename) |
| 103 | call_pyarmor(cmd_args, homepath=self._config['homepath']) |
| 104 | |
| 105 | if is_initial: |
| 106 | regfiles = glob.glob('pyarmor-reg*.zip') |
| 107 | if not regfiles: |
| 108 | raise RuntimeError('Abort registration') |
| 109 | os.makedirs(self.homepath, exist_ok=True) |
| 110 | dest = os.path.join(self.homepath, regfiles[0]) |
| 111 | logging.info('Store registration file "%s"', dest) |
| 112 | os.rename(regfiles[0], dest) |
| 113 | return dest |
| 114 | return 'OK' |
| 115 | |
| 116 | |
| 117 | class ProjectHandler(BaseHandler): |
nothing calls this directly
no test coverage detected