Ejemplo n.º 1
0
    def isfile(self, filename):
        """Return true, if filename is exists."""
        cmd = "if [ `ls %s 2> /dev/null` ]; then echo 1; fi;" % filename

        r = Request(action="read")
        r.machine = self._server_name()
        r.data = json.dumps({"action": "isfile", "cmd": cmd})
        r.user = self.user
        r.save()

        stdout, stderr, retcode = self._run(cmd)

        r.done_date = datetime.today()
        r.done = True
        r.stdout = stdout
        r.stderr = stderr
        r.retcode = retcode

        r.save()

        return stdout.strip() == "1"
Ejemplo n.º 2
0
    def isfile(self, filename):
        """Return true, if filename is exists."""
        cmd = "if [ `ls %s 2> /dev/null` ]; then echo 1; fi;" % filename

        r = Request(action="read")
        r.machine = self._server_name()
        r.data = json.dumps({"action": "isfile", "cmd": cmd})
        r.user = self.user
        r.save()

        stdout, stderr, retcode = self._run(cmd)

        r.done_date = datetime.today()
        r.done = True
        r.stdout = stdout
        r.stderr = stderr
        r.retcode = retcode

        r.save()

        return stdout.strip() == "1"
Ejemplo n.º 3
0
    def read(self, filename):
        """Read filename promtly."""
        cmd = "cat %s" % filename

        r = Request(action="read")
        r.machine = self._server_name()
        r.data = json.dumps({"action": "read", "cmd": cmd})
        r.user = self.user
        r.save()

        stdout, stderr, retcode = self._run(cmd)

        r.done_date = datetime.today()
        r.done = True
        r.stdout = stdout
        r.stderr = stderr
        r.retcode = retcode

        r.save()

        return stdout
Ejemplo n.º 4
0
    def read(self, filename):
        """Read filename promtly."""
        cmd = "cat %s" % filename

        r = Request(action="read")
        r.machine = self._server_name()
        r.data = json.dumps({"action": "read", "cmd": cmd})
        r.user = self.user
        r.save()

        stdout, stderr, retcode = self._run(cmd)

        r.done_date = datetime.today()
        r.done = True
        r.stdout = stdout
        r.stderr = stderr
        r.retcode = retcode

        r.save()

        return stdout