def do_delivery(self): """ Deliver the staged delivery folder using rsync :returns: True if delivery was successful, False if unsuccessful :raises DelivererRsyncError: if an exception occurred during transfer """ agent = transfer.RsyncAgent( self.expand_path(self.stagingpath), dest_path=self.expand_path(self.deliverypath), digestfile=self.delivered_digestfile(), remote_host=getattr(self, 'remote_host', None), remote_user=getattr(self, 'remote_user', None), log=logger, opts={ '--files-from': [self.staging_filelist()], '--copy-links': None, '--recursive': None, '--perms': None, '--chmod': 'ug+rwX,o-rwx', '--verbose': None, '--exclude': ["*rsync.out", "*rsync.err"] }) create_folder(os.path.dirname(self.transfer_log())) try: return agent.transfer(transfer_log=self.transfer_log()) except transfer.TransferError as e: raise DelivererRsyncError(e)
def test_init(self): """Test initiation of agent instance.""" args = ['arg1'] kwargs = { 'dest_path': 'arg2', 'remote_host': 'arg3', 'remote_user': '******', 'validate': True, 'digestfile': 'arg5' } agent = transfer.RsyncAgent(*args, **kwargs) self.assertEqual(getattr(agent, 'src_path'), args[0]) for attribute, value in kwargs.items(): self.assertEqual(getattr(agent, attribute), value) self.assertEqual(agent.cmdopts, agent.DEFAULT_OPTS)
def test_init(self): """ test initiation of agent instance """ # initiate with some values args = ["arg1"] kwargs = {"dest_path": "arg2", "remote_host": "arg3", "remote_user": "******", "validate": True, "digestfile": "arg5"} agent = transfer.RsyncAgent(*args, **kwargs) # assert that the initialized values are what is set on the instance self.assertEqual(getattr(agent,"src_path"),args[0]) for attribute, value in kwargs.items(): self.assertEqual(getattr(agent, attribute), value) self.assertEqual(agent.cmdopts, agent.DEFAULT_OPTS)
def setUp(self): self.destdir = tempfile.mkdtemp(prefix="test_taca_transfer_dest") self.agent = transfer.RsyncAgent(self.rootdir, dest_path=self.destdir, validate=False)