예제 #1
0
    def apply(self):

        self.cowsay = shutil.which('cowsay')
        txt = Template.from_string(self.msg, self.resource)

        if self.cowsay and os.environ.get('MOO'):
            cmd = COWSAY.format(msg=txt)
            txt = self.run(cmd, echo=False)
        self.echo(txt)

        return self.ok()
예제 #2
0
    def apply(self):

        self.cowsay = shutil.which('cowsay')
        txt = Template.from_string(self.msg, self.resource)

        if self.cowsay and os.environ.get('MOO'):
            cmd = COWSAY.format(msg=txt)
            txt = subprocess.check_output(cmd, shell=True).decode()
        self.echo(txt)

        return self.ok()
예제 #3
0
    def should_replace_using_template(self):
        """ for from_template , should we write the template? """

        if not self.overwrite:
            return False

        data = self.slurp(self.from_template, remote=True)

        self.evaluated_template = Template.from_string(data, self.resource)

        if not FileTests.exists(self.name):
            return True
        original = self.slurp(self.name)

        return original != self.evaluated_template
예제 #4
0
파일: type.py 프로젝트: pkropf/opsmop
 def template(self, msg):
     return Template.from_string(msg, self)
예제 #5
0
파일: template.py 프로젝트: xinity/opsmop
 def evaluate(self, resource):
     return CoreTemplate.from_string(self.expr, resource)