Пример #1
0
    def apply(self, context):
        changed = False

        if not os.path.exists("/usr/bin/rsync"):
            context.changelog.info(
                "'/usr/bin/rsync' command is not available.")
            if not context.simulate:
                raise MissingDependency(
                    "Cannot continue with unmet dependency")

        if not os.path.exists(self.resource.name):
            command = ["/bin/mkdir", self.resource.name]
            rv, out, err = context.shell.execute(command, exceptions=False)
            changed = True

        if context.simulate and changed:
            context.changelog.info(
                "Root directory not found; assuming rsync will occur")
            return True

        ac = AttributeChanger(context,
                              self.resource.name,
                              self.resource.user,
                              mode=0755)
        ac.apply(context)
        changed = changed or ac.changed

        if self._sync(context, True):
            self._sync(context)
            changed = True

        return changed
Пример #2
0
    def apply(self, context):
        changed = False

        if not os.path.exists("/usr/bin/rsync"):
            context.changelog.info("'/usr/bin/rsync' command is not available.")
            if not context.simulate:
                raise MissingDependency("Cannot continue with unmet dependency")

        if not os.path.exists(self.resource.name):
            command = ["/bin/mkdir", self.resource.name]
            rv, out, err = context.shell.execute(command, exceptions=False)
            changed = True

        if context.simulate and changed:
            context.changelog.info("Root directory not found; assuming rsync will occur")
            return True

        ac = AttributeChanger(context, self.resource.name, self.resource.user, mode=0755)
        ac.apply(context)
        changed = changed or ac.changed

        if self._sync(context, True):
            self._sync(context)
            changed = True

        return changed
Пример #3
0
 def apply(self, context):
     changed = False
     self.check_path(os.path.dirname(self.resource.name), context.simulate)
     ac = AttributeChanger(context, self.resource.name, self.resource.owner,
                           self.resource.group, self.resource.mode)
     if not os.path.exists(self.resource.name):
         command = ["/bin/mkdir"]
         if self.resource.parents:
             command.append("-p")
         command.append(self.resource.name.encode("utf-8"))
         context.shell.execute(command)
         changed = True
     ac.apply(context)
     if changed or ac.changed:
         return True
     else:
         return False
Пример #4
0
 def apply(self, context):
     changed = False
     self.check_path(os.path.dirname(self.resource.name), context.simulate)
     ac = AttributeChanger(context,
                           self.resource.name,
                           self.resource.owner,
                           self.resource.group,
                           self.resource.mode)
     if not os.path.exists(self.resource.name):
         command = ["/bin/mkdir"]
         if self.resource.parents:
             command.append("-p")
         command.append(self.resource.name.encode("utf-8"))
         context.shell.execute(command)
         changed = True
     ac.apply(context)
     if changed or ac.changed:
         return True
     else:
         return False