コード例 #1
0
ファイル: bpost.py プロジェクト: bartoszcisek/b1000
    def run(self):
        l.info("Running post script '%s' for job '%s'" % (self.job.post, self.job.full_name))

        try:
            run_and_log(self.job.post)
        except Exception, e:
            self.failed = True
            l.warning("Post script '%s' failed. Exception: %s" % (self.job.post, str(e)))
コード例 #2
0
ファイル: rsync.py プロジェクト: bartoszcisek/b1000
    def mkdir(self, dest):

        # this is another not-so-nasty hack to "make dirs" on server side
        if dest.startswith("rsync://"):
            try:
                chunks = re.search("(rsync://[^/]+/[^/]+)/(.*)", dest)
                root = chunks.group(1)
                subdir = chunks.group(2)
            except Exception, e:
                l.debug("No subdirectories to create on remote '%s'" % (dest))
                return

            tmpdir = tempfile.mkdtemp(prefix="b1000-rsync-mkdir-")
            the_dir = "%s/%s" % (tmpdir, subdir)
            os.makedirs(the_dir)

            cmd = "%s -arq %s %s/* %s" % (self.rsync_cmd, self.timeout, tmpdir, root)

            l.debug("Creating subdirectories '%s' on '%s'" % (subdir, root))

            run_and_log(cmd)
            os.removedirs(the_dir)
コード例 #3
0
ファイル: rsync.py プロジェクト: bartoszcisek/b1000
            if not os.path.isdir(dest):
                l.debug("Creating local subdirectories: '%s'" % dest)
                os.makedirs(dest)
            else:
                l.debug("Local directory '%s' exists, no need to create one" % dest)

        # we don't know how to handle other types
        else:
            raise OSError("Don't know how to make proper subdirs for destination: %s" % dest)

    # --------------------------------------------------------------------
    def run(self):

        # first create necessary directory structure on remote server
        try:
            self.mkdir(self.dst)
        except Exception, e:
            raise OSError("Could not create remote directory '%s'. Exception: %s" % (self.dst, str(e)))

        # start rsync process
        try:
            cmd = "%s %s %s %s %s %s" % (self.rsync_cmd, self.exclude, self.timeout, self.__prep_opts(), self.src, self.dst)
            l.debug("Running rsync command: %s" % cmd)
            run_and_log(cmd, "rsync " + self.name)
        except Exception, e:
            raise OSError("Exception while running rsync: %s" % str(e))



# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4