def newProject(args=None): ''' >>> p = newProject() >>> p['message'] 'Project has been created' ''' filename = _check_project_index() with open(filename, 'r') as fp: pindexes = json.load(fp) counter = pindexes['counter'] + 1 name = 'project-%d' % counter path = os.path.join(project_base_path, name) if os.path.exists(path): logging.warning('Project path %s has been exists', path) else: logging.info('Make project path %s', path) os.mkdir(path) args = ['init', '--src', path, path] _pyarmor(args) pindexes['projects'][name] = os.path.abspath(path) pindexes['counter'] = counter with open(filename, 'w') as fp: json.dump(pindexes, fp) project = Project() project.open(path) project['name'] = name project['title'] = name project['output'] = build_path('dist', path) return dict(project=project, message='Project has been created')
def buildProject(args): ''' >>> p = newProject()['project'] >>> p['src'] = '' >>> p['output'] = os.path.join('projects', 'build') >>> buildProject(p) 'Build project OK.' ''' name = args['name'] path = os.path.join(project_base_path, name) _pyarmor(['build', path]) return 'Build project OK.'
def newLicense(args): ''' >>> p = newProject()['project'] >>> p['rcode'] = 'Curstomer-Tom' >>> a1 = newLicense(p) >>> p['expired'] = '2017-11-20' >>> a2 = newLicense(p) ''' name = args['name'] path = os.path.join(project_base_path, name) title = args['rcode'].strip() params = ['licenses', '--project', path] for opt in ('expired', 'bind_disk', 'bind_ipv4', 'bind_mac'): if args[opt]: params.extend(['--%s' % opt, args[opt]]) params.append(title) _pyarmor(params) output = os.path.join(path, 'licenses', title, 'license.lic') return dict(title=title, filename=output)