Exemplo n.º 1
0
Arquivo: cli.py Projeto: bjmc/gs2dv
 def match_domains(self, database_list, access_domain):
     prefix = 'db' + get_siteid(access_domain)
     #This regular expression will extract the domain name and subdomain (if found) from a file path on the dv:
     extract_names = re.compile(r'/var/www/vhosts/(?P<domain>[^/]+)/(subdomains/(?P<subdomain>[^/]+)/httpdocs|httpdocs)/')
     regex_string = '|'.join(database_list)
     all_dbs = re.compile(regex_string)
     path = '/var/www/vhosts/'        
     #Does the actual search, returns a dictionary with keys of file names and values of lines containing the DB names.
     grep_results = scriptutil.ffindgrep(path, namefs=(self._suffixes,), regexl=((regex_string, re.I)))    
     matches = {}
     count = 0
     for file, line in grep_results.iteritems():
         
         match_object = extract_names.match(file)
         domain = match_object.group('domain')
         subdomain = match_object.group('subdomain')
         if subdomain:
             site = subdomain + '.' + domain
         else:
             site = domain           
         
         db = re.search(all_dbs, line).group()
         
         if domain in matches:
             if db in matches[domain]:
                 matches[domain][db].update(site, file)
             else:
                 matches[domain][db] = Database(db, site, file, prefix, count)
                 count = count + 1
         else:
             matches[domain] = dict.fromkeys([db], Database(db, site, file, prefix, count))
             count = count + 1            
     return matches       
Exemplo n.º 2
0
    def buscaConteudo(self):
        conteudo = self.conteudo
        print "buscaConteudo::", conteudo

        flist = SU.ffindgrep(diretorio, regexl=(conteudo, ))

        self.resultado = flist
        return flist
Exemplo n.º 3
0
	def buscaConteudo(self): 
		conteudo=self.conteudo
		print "buscaConteudo::", conteudo

		flist = SU.ffindgrep(diretorio, regexl=(conteudo,))

		self.resultado=flist
		return flist