Skip to content

Instantly share code, notes, and snippets.

@lsabiao
Created August 8, 2018 18:48
Show Gist options
  • Save lsabiao/c1ddcc783f1f51685e7a5ce91344f40a to your computer and use it in GitHub Desktop.
Save lsabiao/c1ddcc783f1f51685e7a5ce91344f40a to your computer and use it in GitHub Desktop.
Cansado de timeout no vTiger? você achou sua solução! Esse script printa o conteúdo das tarefas abertdas do desenvolvimento no seu console.
import requests
from bs4 import BeautifulSoup
from colorama import init,Fore,Back,Style
import sys
init()
class Chamado:
idGlobal = 1
def __init__(self):
self.id = Chamado.idGlobal
Chamado.idGlobal+=1
self.assunto = ""
self.responsavel= ""
self.cliente = ""
self.dataAbertura = ""
self.horaAbertura = ""
self.dataFechamento = ""
self.horaFechamento = ""
self.status = ""
self.prioriedade = ""
self.tipo = ""
self.origem = ""
self.titulo = ""
self.cores = {"Baixo":Fore.GREEN,"Média":Fore.YELLOW,"Alto":Fore.RED}
def parse(self,bs):
self.assunto = bs[0].get_text().strip()
self.responsavel = bs[1].get_text().strip()
self.cliente = bs[2].get_text().strip()
self.dataAbertura = bs[3].get_text().strip()
self.horaAbertura = bs[4].get_text().strip()
self.dataFechamento = bs[5].get_text().strip()
self.horaFechamento = bs[6].get_text().strip()
self.status = bs[7].get_text().strip()
self.prioriedade = self.cores[bs[8].get_text().strip()]
self.tipo = bs[9].get_text().strip()
self.origem = bs[10].get_text().strip()
self.titulo = bs[11].get_text().strip()
def __str__(self):
self.format = "{cor}Chamado{reset} {0} {cor}criado em{reset} {1} {cor}esta com o{reset} {2}".format(self.assunto,self.dataAbertura,self.responsavel,cor=self.prioriedade,reset=Style.RESET_ALL)
return self.format
def go(usr,passw):
retorno = []
payload ={'username':usr,'password':passw,'action':'Login','module':'Users'}
s = requests.Session()
if(args.q is False):print("Tentando Logar:",end='',flush=True)
try:
req = s.post('http://crm.wancorarh.com.br/vtigercrm/index.php',data=payload)
except:
if(args.q is False):print(Fore.RED+"Parece que você está sem internet"+Style.RESET_ALL)
sys.exit(1)
agenda = s.get('http://crm.wancorarh.com.br/vtigercrm/index.php?module=Calendar&parent=&page=&view=List&viewname=118&orderby=&sortorder=&app=MARKETING&tag_params=%5B%5D&nolistcache=0&list_headers=&tag=')
if(agenda.url == "http://crm.wancorarh.com.br/vtigercrm/index.php"):
if(args.q is False):print(Fore.RED+"recusado"+Style.RESET_ALL)
sys.exit(1)
else:
if(args.q is False):print(Fore.GREEN+"aceito"+Style.RESET_ALL)
if(args.q is False):print("Procurando chamados...",flush=True)
soup = BeautifulSoup(agenda.content,'html.parser')
firstParse = soup.find_all('tr',"listViewEntries")
if(args.q is False):print(u"{cor}{0}{reset} chamado(s) encontrado(s)".format(len(firstParse),cor=Fore.CYAN,reset=Style.RESET_ALL))
for item in firstParse:
soup2 = BeautifulSoup(str(item),'html.parser')
seccondParse = soup2.find_all('td','listViewEntryValue')
c = Chamado()
c.parse(seccondParse)
retorno.append(c)
return retorno
banner = '''{red}
██╗ ██╗████████╗██╗ ██████╗ ███████╗██████╗
██║ ██║╚══██╔══╝██║██╔════╝ ██╔════╝██╔══██╗
██║ ██║ ██║ ██║██║ ███╗█████╗ ██████╔╝
╚██╗ ██╔╝ ██║ ██║██║ ██║██╔══╝ ██╔══██╗
╚████╔╝ ██║ ██║╚██████╔╝███████╗██║ ██║
╚═══╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
{bl}é uma bosta{reset}
'''.format(red=Fore.RED,bl=Fore.BLUE,reset=Style.RESET_ALL)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Procura no vTiger e printa as tarefas")
parser.add_argument('-u', action='store', required = True, help='O usuário no vTtiger')
parser.add_argument('-p', action='store', required = True, help='A senha no vTtiger')
parser.add_argument('-q', action='store_true',help='Modo Silencioso')
parser.add_argument('-v', action='store_true',help='Modo Verboso')
args = parser.parse_args()
if(args.q is False):
print(banner)
result = go(args.u,args.p)
if(args.v):
for c in result:
print(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment