def start(self, direction, path=''): self.ensureKeyPerms() unisonPath = self.getUnisonBin() unisonArgs = self.getUnisonArgs(direction, path) unisonEnv = self.getUnisonEnv() if self.ignoreArchives: # It seems that in certain cases, unison does not observe the -ignorearchives flag correctly # So to make sure, we forcibly delete previous archives on both sides res = Try.sequence([ # Delete host archives Shell.call(["rm", "-rf", unisonEnv['UNISON']], shell=False), # Delete guest archives self.engine.readLink().bind(Link.runCommand, 'rm -rf /substance/.unison') ]) if res.isFail(): return res logger.info("Syncing local directory %s to remote directory %s", unisonArgs[-2], unisonArgs[-1]) logger.debug("EXEC: %s", Shell.stringify([unisonPath] + unisonArgs, unisonEnv)) os.execve(unisonPath, unisonArgs, unisonEnv)
def sync(self): op = Shell.call(self.getCommand()) if op.isFail(): print("%s" % op) return op return OK(self)
def commitToSystem(self): hostsPath = self.determine_hosts_path() logger.debug("Commiting '%s' to system '%s'" % (self.hosts_path, hostsPath)) return Shell.call(["cp", self.hosts_path, self.determine_hosts_path()], shell=False, sudo=True) \ .then(lambda: os.remove(self.tempFile.name))