def testSync(self, stdout): commands.sync(self.pathB) calls = list(map(unittest.mock.call, [self.pathA, self.pathB])) self.getSyncInputM.assert_has_calls(calls, any_order=True) self.assertEqual(self.getSyncInputM.call_count, len(calls)) self.getSyncResultM.assert_called_once_with( self.dummySyncInputA, self.dummySyncInputB) calls = list(map( lambda i: unittest.mock.call( syncResult=self.dummySyncResult, syncInput=i), [self.dummySyncInputA, self.dummySyncInputB])) self.syncTreeM.assert_has_calls(calls, any_order=True) self.assertEqual(self.syncTreeM.call_count, len(calls)) calls = list(map( lambda i: unittest.mock.call( files.MetaData(replicaID=i.replicaID, versionVector=self.dummySyncResult.versionVector, treeHash=self.dummySyncResult.treeHash), i.replicaRoot, overwrite=True), [self.dummySyncInputA, self.dummySyncInputB])) self.setMetaDataM.assert_has_calls(calls, any_order=True) self.assertEqual(self.setMetaDataM.call_count, len(calls))
def _sync(self): time.sleep(.05) self._write(commands.sync()) read = self.ser.read(6) if self._matches(commands.ack('0d', '..'), read): if self._matches(commands.sync(), self.ser.read(6)): self._write(commands.ack('0d', '00')) return True return False
def subc_status(sock, args): """Request device status""" state = txn_sync(sock, cmd.sync()) assert_frame(state) modenames = { 205: 'meteor', 206: 'breathing', 207: 'stack', 208: 'flow', 209: 'wave', 210: 'flash', 211: 'static', 212: 'catch-up', 219: 'custom_effect', 0xfc: 'auto', } if state[2] in modenames: modename = modenames[state[2]] else: modename = '' # TODO - move this into the library and object model print("lamp =", state[1]) print("mode = {} {}".format(state[2], modename)) print("speed =", state[3]) print("brightness =", state[4]) print("rgb_order =", state[5]) print("dotperseg =", state[6] * 256 + state[7]) print("segs =", state[8] * 256 + state[9]) print("staticcolor = {}".format(structures.RGB(state[10:13]))) print("ic_model =", state[13]) assert_status_unknown(state)
def main(): if contains_confgit_command(): # if user has specified confgit command args = vars(parse_confgit_args()) if args['debug']: debug_mode = True print_debug(args) if args['command'] == 'init': init(args['init_path'], args['CONFIG_PATH']) config = load_config(args['CONFIG_PATH']) print_debug(config) if args['command'] == 'include': for i in args['paths']: include(i, config, args['CONFIG_PATH']) if args['command'] == 'exclude': for i in args['paths']: exclude(i, config, args["CONFIG_PATH"]) if args['command'] == 'sync': sync(config) if args['command'] == 'update': update(config) if args['command'] == 'backup': backup(config, args['backup_path']) else: # if user has not specified confgit command #! doesn't check if it's a valid git command, could be problem later - g3ner1c config, git_command = parse_git_args() print_debug(git_command) cd(config["repo_dir"]) send_to_git(git_command)
def parseArgs(args=None): parser = argparse.ArgumentParser(description='''Synchronize directory replicas using version vectors.''') subparsers = parser.add_subparsers(dest='command') subparsers.required = True initP = subparsers.add_parser('init', help='''Initialize a new replica in the current directory''') initP.add_argument('ID', help='ID for the new Replica') initP.set_defaults(func=lambda args: commands.init(args.ID)) syncP = subparsers.add_parser('sync', help='''Synchronize with another replica''') syncP.add_argument('path', help='path/to/another replica') syncP.set_defaults(func=lambda args: commands.sync(args.path)) parsedArgs = parser.parse_args(args) parsedArgs.func(parsedArgs)
def test_sync(): assert b'\x38\x00\x00\x00\x10\x83' == commands.sync()