Beispiel #1
0
    def do_replace(self):
        self.replace_state = 'running'
        self.save()

        for r in self.get_results():
            if JobKill.objects.filter(ds=self).count() > 0:
                self.killed = True
                self.save()
                print 'Job Killed'
                return

            needle = self.make_needle()
            opts = self.get_opts()
            rlines = [x[0] for x in r[2]]

            grep = Grep(r[0], needle)
            grep.replace(opts['replace'], rlines)
            if self.replace_results:
                self.replace_results += '\n' + r[0]

            else:
                self.replace_results = r[0]

            self.save()

        self.replace_state = 'complete'
        self.save()
Beispiel #2
0
 def do_replace (self):
   self.replace_state = 'running'
   self.save()
   
   for r in self.get_results():
     if JobKill.objects.filter(ds=self).count() > 0:
       self.killed = True
       self.save()
       print 'Job Killed'
       return
       
     needle = self.make_needle()
     opts = self.get_opts()
     rlines = [x[0] for x in r[2]]
     
     grep = Grep(r[0], needle)
     grep.replace(opts['replace'], rlines)
     if self.replace_results:
       self.replace_results += '\n' + r[0]
       
     else:
       self.replace_results = r[0]
       
     self.save()
     
   self.replace_state = 'complete'
   self.save()
Beispiel #3
0
    def do_search(self):
        self.state = 'running'
        self.save()
        opts = self.get_opts()
        needle = self.make_needle()
        results = []

        for root, dirs, files in os.walk(opts['dir']):
            if opts['glob']:
                files = glob.glob(root + '/' + opts['glob'])

            if files:
                for file in files:
                    if JobKill.objects.filter(ds=self).count() > 0:
                        self.killed = True
                        self.save()
                        print 'Job Killed'
                        return

                    fp = os.path.join(root, file)
                    uid = hashstr(fp)

                    if opts['needle']:
                        grep = Grep(fp, needle)
                        grep_results = grep.results()
                        if grep_results:
                            results.append((fp, uid, grep_results))

                    else:
                        results.append((fp, uid, []))

                self.set_results(results)

        self.state = 'complete'
        self.save()
Beispiel #4
0
 def do_search (self):
   self.state = 'running'
   self.save()
   opts = self.get_opts()
   needle = self.make_needle()
   results = []
   
   for root, dirs, files in os.walk(opts['dir']):
     if opts['glob']:
       files = glob.glob(root + '/' + opts['glob'])
       
     if files:
       for file in files:
         if JobKill.objects.filter(ds=self).count() > 0:
           self.killed = True
           self.save()
           print 'Job Killed'
           return
           
         fp = os.path.join(root, file)
         uid = hashstr(fp)
         
         if opts['needle']:
           grep = Grep(fp, needle)
           grep_results = grep.results()
           if grep_results:
             results.append((fp, uid, grep_results))
             
         else:
           results.append((fp, uid, []))
           
       self.set_results(results)
       
   self.state = 'complete'
   self.save()