Пример #1
0
    def setupPushCmd(self):
        '''
        called by TransferBase in order to create a push command
        '''
        if self.ctl_file_path != None:
            try:
                os.remove(self.ctl_file_path)
            except:
                pass
        if self.rcpt_file_path != None:
            try:
                os.remove(self.rcpt_file_path)
            except:
                pass
        f = self.getFile()
        if not self.checkFileExists(self.config.get("data_stream.directory") + "/" + f):
            return None
        if self.config.get("outgoing.target_uses_arrival_monitor"):
            item_name = f
            item_path = (os.path.join(self.config.get("data_stream.directory"),
                os.path.basename(item_name)))
            ctl_file_name = (".%s.%s" % (item_name, self.config.get(
                "outgoing.control_file_extension")))
            ctl_file_path = (os.path.join(self.config.get(
                "data_stream.directory"), os.path.basename(ctl_file_name)))
            self.ctl_file_path = ctl_file_path
            item_size = os.path.getsize(item_path)
            item_cksum = TransferUtils.calcChecksum(item_path)
            ts = "%.2f" % time.time()
            rcpt_file_name = (".%s.%s.%s" % (item_name, ts, self.config.get(
                "outgoing.receipt_file_extension")))
            ctl_file = ControlFile(ctl_file_path, can_overwrite=True)
            ctl_file.create(item_name, item_size, item_cksum, rcpt_file_name)
            self.rcpt_file_name = rcpt_file_name
            self.rcpt_file_path = (TransferUtils.getPathInDir(rcpt_file_name,
                self.config.get("data_stream.directory")))

        rsc = self.cmd + " -avz --password-file=" + self.passwordfile + " "
        if self.config.get("rsync_native.use_checksum") == True:
            rsc += " --checksum "
        if self.config.get("rsync_native.check_size") == True:
            rsc += " --size-only "
        if not self.config.get("outgoing.target_uses_arrival_monitor"):
            pushcmd = (rsc + self.config.get("data_stream.directory") + "/" +f
                + " " + "rsync://" + self.config.get("rsync_native.username")
                + "@" + self.config.get("outgoing.target_host") + "/" +
                self.config.get("outgoing.target_dir") + "/" + f)
        else:
            pushcmd = (rsc + self.config.get("data_stream.directory") + "/" +f
                + " " + self.config.get("data_stream.directory") + "/" +
               ctl_file_name + " " + "rsync://" + self.config.get(
               "rsync_native.username") + "@" + self.config.get(
               "outgoing.target_host") + "/" + self.config.get(
               "outgoing.target_dir"))
        self.info("setupPushCmd %s " % pushcmd)
        return pushcmd
Пример #2
0
    def setupPushCmd(self):
        '''
        called by TransferBase in order to create a push command
        '''
        if self.ctl_file_path != None:
            try:
                os.remove(self.ctl_file_path)
            except:
                pass
        if self.rcpt_file_path != None:
            try:
                os.remove(self.rcpt_file_path)
            except:
                pass
        f = self.getFile()
        if not self.checkFileExists(self.config.get("data_stream.directory") + "/" + f):
            return None
        # set up a control file
        if self.config.get("outgoing.target_uses_arrival_monitor"):
            # set up a control file
            item_name = self.getFile()
            item_path = (os.path.join(self.config.get("data_stream.directory"),
                os.path.basename(item_name)))
            ctl_file_name = (".%s.%s" % (item_name, self.config.get(
                "outgoing.control_file_extension")))
            ctl_file_path = (os.path.join(self.config.get(
                "data_stream.directory"), os.path.basename(ctl_file_name)))
            self.ctl_file_path = ctl_file_path
            item_size = os.path.getsize(item_path)
            item_cksum = TransferUtils.calcChecksum(item_path)
            ts = "%.2f" % time.time()
            rcpt_file_name = (".%s.%s.%s" % (item_name, ts, self.config.get(
                "outgoing.receipt_file_extension")))
            ctl_file = ControlFile(ctl_file_path, can_overwrite=True)
            ctl_file.create(item_name, item_size, item_cksum, rcpt_file_name)
            self.rcpt_file_name = rcpt_file_name
            self.rcpt_file_path = (TransferUtils.getPathInDir(rcpt_file_name,
                self.config.get("data_stream.directory")))

        f = self.getFile()
        gftp = self.cmd
        if self.config.get("outgoing.target_uses_arrival_monitor") == False:
            gftp += " -sync -sync-level 3"
        pushcmd = (gftp + " " + self.config.get("data_stream.directory") + "/"
            + f + " gsiftp://" + self.config.get("outgoing.target_host") + ":" 
            + str(self.config.get("gridftp_myproxy.port")) + "//" +  
            self.config.get("outgoing.target_dir") + "/" + f)
        if self.config.get("outgoing.target_uses_arrival_monitor"):
            pushcmd += ("; " + gftp + " " + self.config.get(
                "data_stream.directory") + "/" + ctl_file_name + " gsiftp://"
                + self.config.get("outgoing.target_host") + ":" +
                str(self.config.get("gridftp_myproxy.port")) +
                self.config.get("outgoing.target_dir") + "/" + ctl_file_name)
        self.info("setupPushCmd %s " % pushcmd)
        return pushcmd
Пример #3
0
 def setupPushCmd(self):
     '''
     called by TransferBase in order to create a push command
     '''
     if self.ctl_file_path != None:
         try:
             os.remove(self.ctl_file_path)
         except:
             pass
     if self.rcpt_file_path != None:
         try:
             os.remove(self.rcpt_file_path)
         except:
             pass
     # set up a control file
     item_name = self.getFile()
     if not self.checkFileExists(self.config.get("data_stream.directory") + "/" + item_name):
         return None
     item_path = (os.path.join(self.config.get("data_stream.directory"),
         os.path.basename(item_name)))
     ctl_file_name = (".%s.%s" % (item_name, self.config.get(
         "outgoing.control_file_extension")))
     ctl_file_path = (os.path.join(self.config.get("data_stream.directory"),
         os.path.basename(ctl_file_name)))
     self.ctl_file_path = ctl_file_path
     item_size = os.path.getsize(item_path)
     item_cksum = TransferUtils.calcChecksum(item_path)                                               
     ts = "%.2f" % time.time()
     rcpt_file_name = (".%s.%s.%s" % (item_name, ts, self.config.get(
         "outgoing.receipt_file_extension")))
     ctl_file = ControlFile(ctl_file_path, can_overwrite=True)
     ctl_file.create(item_name, item_size, item_cksum, rcpt_file_name)
     self.rcpt_file_name = rcpt_file_name
     self.rcpt_file_path = (TransferUtils.getPathInDir(rcpt_file_name,
         self.config.get("data_stream.directory")))
     # set up ftp transfer + control file
     tf, name = tempfile.mkstemp()
     (os.write(tf, "user " + self.config.get("ftp.username") + " " +
         self.config.get("ftp.password") + "\n"))
     os.write(tf, "cd " + self.config.get("outgoing.target_dir") + "\n")
     os.write(tf, "lcd " + self.config.get("data_stream.directory") + "\n")
     os.write(tf, "put " + self.getFile() + "\n")
     if self.config.get("outgoing.target_uses_arrival_monitor"):
         os.write(tf, "put " + ctl_file_name + "\n")
     os.write(tf, "exit\n")
     os.fsync(tf)
     os.close(tf)
     pushcmd = ("/usr/bin/ftp -n " + self.config.get("outgoing.target_host")
         + " < " + name)
     self.info("setupPushCmd %s" % pushcmd)
     self.pushtf = tf
     self.pushname = name
     return pushcmd