def validateBuild(args): available_build_actions = ("branch", "patch", "origin") action = args.build[0] if args.install and (args.install[1] == "repo" or args.install[1] == "develrepo"): raise Exception( "First building IPA from sources and then " "installing it from repo makes no sense. " "Think about it." ) if action not in available_build_actions: raise ValueError("Unknown build action: {s}. Choose either branch " "or patch.".format(s=action)) if action == "patch": show("Checking whether all given patches exist.") vm = VM(locals.NFS_VM, locals.DOMAIN, None, None) patches_exist = True for patch_id in args.build[1:]: num = vm.cmd("bash labtool/ipa-fun-get-patch-name.sh %s" % patch_id, allow_failure=True, silent=True) if num != 0: show("Inappropriate number of patches matching %s" % patch_id) patches_exist = False if not patches_exist: raise ValueError("One of the given patches could not be " "determined.") show("Patch check successful.") vm.close() elif action == "branch": pass # check that such branch indeed exists
def validateBuild(args): available_build_actions = ('branch', 'patch', 'origin') action = args.build[0] if args.install and (args.install[1] == 'repo' or args.install[1] == 'develrepo'): raise Exception('First building IPA from sources and then ' 'installing it from repo makes no sense. ' 'Think about it.') if action not in available_build_actions: raise ValueError('Unknown build action: {s}. Choose either branch ' 'or patch.'.format(s=action)) if action == 'patch': show('Checking whether all given patches exist.') vm = VM(locals.NFS_VM, locals.DOMAIN, None, None) patches_exist = True for patch_id in args.build[1:]: num = vm.cmd('bash labtool/ipa-fun-get-patch-name.sh %s' % patch_id, allow_failure=True, silent=True) if num != 0: show('Inappropriate number of patches matching %s' % patch_id) patches_exist = False if not patches_exist: raise ValueError("One of the given patches could not be " "determined.") show('Patch check successful.') vm.close() elif action == 'branch': pass # check that such branch indeed exists
#!/usr/bin/python3 from vm import VM from parsing import readProgram, parseInput, parseOutput import sys if __name__ == '__main__': if len(sys.argv) < 2: raise ValueError("You need to specify a program") progName = sys.argv[1] with open(progName, 'r') as f: prog = readProgram(f) progIn = input() vm = VM(istream=parseInput(progIn), dynamicMem=prog.dynamicMem, initMem=prog.initMem) vm.cmd = prog.cmds vm.run() print(parseOutput(vm.ostream))