Esempio n. 1
0
 def sysSyncStatus(self, *args):
     filePath = args[0]
     
     isDir = os.path.isdir(filePath)
     
     moduleName, relativePath = self._getRelativePath(filePath)
     
     localPath = os.path.dirname(filePath) if isDir else filePath
      
     command = '/usr/bin/rsync -zrtni  --password-file=%s %[email protected]%s::%s/%s %s' \
         %(setting.password_file, setting.auth_user, g.TcpIp, moduleName, \
           util.escapeshellarg(relativePath), util.escapeshellarg(localPath))
     
     status, output = commands.getstatusoutput(command)
     
     g.logger.debug('sysSyncStatus command: %s, output: %s' %(command, output))
     return not bool(output)
Esempio n. 2
0
 def sysForceSync(self, *args):
     filePath = args[0]
     
     if self.rsyncFile(*args):
         command = "chown -R %s:%s %s" %(g.user, g.group, util.escapeshellarg(filePath))
         status, output = commands.getstatusoutput(command)
         return not status
     else:
         return False
Esempio n. 3
0
 def rsyncFile(self, *args):
     filePath = args[0]
     
     moduleName, relativePath = self._getRelativePath(filePath)
     
     if not moduleName:
         g.logger.error('filePath:%s get moduleName error' %filePath)
         return False
     
     command = '/usr/bin/rsync -zrt --delete  --password-file=%s %[email protected]%s::%s/%s %s' \
         %(setting.password_file, setting.auth_user, g.TcpIp, moduleName, \
           util.escapeshellarg(relativePath), util.escapeshellarg(os.path.dirname(filePath))) 
         
     status, output = commands.getstatusoutput(command)
     
     if status:
         g.logger.error('rsync command:%s error:%s' %(command, output))
         return False
     else:
         g.logger.info('rsync command:%s success' %command)
         return True
Esempio n. 4
0
    def execDelete(self, *args):
        #args = map(util.escapeshellarg, args)

        filePath = util.escapeshellarg(args[0])
        
        command = 'mv ' + filePath + ' ' + os.path.dirname(filePath) + os.path.sep + "." + os.path.basename(filePath)
        command = 'rm -rf ' + filePath
        status, output = commands.getstatusoutput(command)
        if not status:
            return True
        else:
            g.logger.error('delete filepath: %s fail msg: %s' %(filePath, output))
            return False
Esempio n. 5
0
    def execCreate(self, *args):
        #args = map(util.escapeshellarg, args)
       
        filePath = args[0]

        if self.rsyncFile(*args):
            command = "chown -R %s:%s %s" %(g.user, g.group, util.escapeshellarg(filePath))
            status, output = commands.getstatusoutput(command)
            if not status:
                return True
            else:
                g.logger.error('create filePath: %s fail msg: %s' %(filePath, output))
        
        g.logger.error('create filePath: %s rsync fail' %filePath)
        return False