class Descompactar:
    def __init__(self):
        self.arquivo = Arquivo()
        self.noticacao = Notification()

    def start(self, origem, destinoPasta, destinoProjeto, app_nome):
        zip_ref = zipfile.ZipFile(origem, 'r')
        zip_ref.extractall(destinoPasta)
        zip_ref.close()

        if os.path.exists(destinoProjeto):
            pass


        shutil.move(destinoPasta + app_nome + "/ios/AppIcon.appiconset", destinoProjeto)
        os.remove(origem)
        #os.remove(destinoPasta + app_nome)
        self.noticacao.send("Imagem AppIcon","AppIcon definido no projeto")

    def downloadZip(self, appName, destinoProjeto):
        app_nome = appName
        nameArquivo = app_nome + ".zip"
        localArquivo = Caminhos.caminhoTesteIOS + nameArquivo

        caminho = "https://github.com/gustaveco1997/imagens/raw/master/Imagens Apps/" + app_nome + ".zip"

        if not os.path.exists(Caminhos.caminhoTesteIOS):
            os.mkdir(Caminhos.caminhoTesteIOS)

        self.arquivo.baixarConteudo(caminho, localArquivo,False)
        self.start(localArquivo, Caminhos.caminhoTesteIOS, destinoProjeto, app_nome)
Exemple #2
0
 def handle(self):
     notification = Notification()
     notification.send()
Exemple #3
0
class JosephPy:
    def criarInstancias(self, tela):
        self.notify = Notification()
        self.googleSheets = GoogleSheets()
        self.relatorio = Relatorio()
        self.descompactar = Descompactar()
        self.email = Email()
        self.areaTeste = AreaTestes()

        self.tela = tela


    def definirConstantes(self):

        assinatura = "./gradlew assembleRelease "
        assinatura += "-Pandroid.injected.signing.store.file=" + Caminhos.keystore + " "
        assinatura += "-Pandroid.injected.signing.store.password=gtlgtlgtl "
        assinatura += "-Pandroid.injected.signing.key.alias=guilherme.vasconcelos "
        assinatura += "-Pandroid.injected.signing.key.password=gtlgtlgtl"

        build = "./gradlew build"
        task = "./gradlew task"
        clean = "./gradlew clean"
        publicar = "./gradlew publishApkRelease"

        self.tarefas = [task, build, assinatura, clean, publicar]
        self.dataInicio = datetime.datetime.now()

    def definirCaminhoCD(self):
        self.aplicativoBase = "cd " + Caminhos.aplicativoBaseNucleo
        self.prefixoAntigos = "cd " + Caminhos.todosAppsAndroidModificado
        self.prefixoNovos = "cd " + Caminhos.novosAppsAndroidModificado

    def __init__(self, tela=None):

        self.criarInstancias(tela)
        self.definirConstantes()
        self.definirCaminhoCD()

        self.situacaoAppsOk = []
        self.situacaoAppsFalha = []

        self.todosApps = sorted(os.listdir(Caminhos.todosAppsAndroid))
        self.novosApps = sorted(os.listdir(Caminhos.novosAppsAndroid))

    def makeApp(self, listaSelecionados, gerarSelecionados, publicar, caminho, emails=None):



        self.situacaoAppsOk.clear()
        self.situacaoAppsFalha.clear()

        if caminho.__eq__(Caminhos.todosAppsAndroid):
            prefixo = self.prefixoAntigos
        else:
            prefixo = self.prefixoNovos

        listaAtual = []
        listaAtual = listaSelecionados

        qnt = 0
        print("Apps a Serem Gerados:")
        print(listaAtual)

        for app in listaAtual:
            if (not app.__eq__(".idea") and not app.__eq__(".gradle") and not app.__eq__(".DS_Store")):
                nome = app.replace(" ", "\\ ")
                #pacote = self.relatorio.getpacote(caminho + app)

                # Antes de tudo criar o projeto
                self.areaTeste.iniciar(caminho=caminho + app)

                qnt += 1
                print(caminho + nome + Caminhos.logo)
                self.notify.send(app, "App iniciado: " + nome,
                                 caminho + nome.replace(" ", "\ ") + "logo.png")
                self.appIniciado(app, qnt)
                self.processos(nome, prefixo, publicar)
                self.appTerminado(app, qnt)
                self.notify.send(app, "App terminado: " + nome,
                                 caminho + nome.replace(" ", "\ ") + "logo.png")

        self.mostrarRelatorio()

        if not publicar:
            self.descompactar.compactar(Caminhos.caminhoApksGerados + Util.getDataAtual().replace("/", "."),
                                        enviarEmail=True,emails=emails)

    def gerarApkNovos(self, listaSelecionados, gerarSelecionados, publicar, emails=None):

        self.situacaoAppsOk.clear()
        self.situacaoAppsFalha.clear()

        listaAtual = []
        lista = self.novosApps
        prefixo = self.prefixoNovos

        if gerarSelecionados:
            listaAtual = listaSelecionados
        else:
            listaAtual = lista

        qnt = 0

        for app in listaAtual:
            if (not app.__eq__(".idea") and not app.__eq__(".gradle") and not app.__eq__(".DS_Store")):
                # pacote = self.relatorio.getpacote(caminho + app)

                # Antes de tudo criar o projeto
                self.areaTeste.iniciar(caminho=Caminhos.novosAppsAndroid + app)

                nome = app.replace(" ", "\\ ")
                qnt += 1
                self.notify.send(app, "App iniciado: " + nome,
                                 Caminhos.novosAppsAndroidModificado + nome + Caminhos.logo)
                self.appIniciado(app, qnt)
                self.processos(nome, prefixo, publicar)
                self.appTerminado(app, qnt)
                self.notify.send(app, "App terminado: " + nome,
                                 Caminhos.novosAppsAndroidModificado + nome + Caminhos.logo)

        print(self.dataInicio)
        print(datetime.datetime.now())

        self.mostrarRelatorio()

        if not publicar:
            self.descompactar.compactar(Caminhos.caminhoApksGerados + Util.getDataAtual().replace("/", "."),
                                        enviarEmail=True,emails=emails)

    def processos(self, nome, prefixo, isPublicarLoja, pacote=None):
        print("---------- Processo ----------")
        pastaProjeto = "/AppTemp"
        comando1 = prefixo + nome + pastaProjeto + " ; " + self.tarefas[0]
        comando2 = prefixo + nome + pastaProjeto +" ; " + self.tarefas[1]

        if isPublicarLoja:
            comando3 = prefixo + nome + pastaProjeto + " ; " + self.tarefas[3] + " ; " + prefixo + nome + pastaProjeto + " ; " + self.tarefas[4]
        else:
            comando3 = prefixo + nome + pastaProjeto + " ; " + self.tarefas[2]


        retorno = subprocess.call(comando1 + " ; " + comando2 + " ; " + comando3, shell=True)

        print("Retorno: " + retorno.__str__())


        if retorno == 0:
            self.situacaoAppsOk.append(nome)
            # Google Sheet
            if (not isPublicarLoja):

                prefixo = prefixo.replace("cd ", "").replace("\\", "")
                nome = nome.replace("\\", "")
                pasta =  prefixo + nome + "/AppTemp" + Caminhos.sufixoReleaseApk
                print(pasta)

                dataAtual = Util.getDataAtual().replace("/", ".")

                if (os.path.exists(pasta)):
                    caminho = Caminhos.caminhoApksGerados + dataAtual + "/"

                    if (not os.path.exists(caminho)):
                        os.mkdir(caminho)

                    try:
                        shutil.copy2(pasta, Caminhos.caminhoApksGerados + dataAtual + "/" + nome + ".apk")
                        shutil.rmtree(prefixo+nome+pastaProjeto)

                    except:
                        pass

                    print("Apps Copiado para pasta ApksGerados")

                else:
                    print("Falha ao mover app para pasta ApksGerados")

            if (pacote != None):
                if (self.googleSheets.existeEstabelecimento(pacote=pacote)):
                    if isPublicarLoja:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Publicação', resultado='Sucesso',
                                                       pacote=pacote, local=prefixo + nome)
                    else:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Geração', resultado='Sucesso',
                                                       pacote=pacote, local=prefixo + nome)

                else:
                    if isPublicarLoja:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Publicação", resultado='Sucesso',
                                                                 data=Util.getDataAtual())
                    else:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Geração", resultado='Sucesso',
                                                                 data=Util.getDataAtual())


        else:
            self.situacaoAppsFalha.append(nome)
            # Google Sheet
            if (pacote != None):
                if (self.googleSheets.existeEstabelecimento(pacote=pacote)):
                    if isPublicarLoja:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Publicação', resultado='Falha',
                                                       pacote=pacote)
                    else:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Geração', resultado='Falha',
                                                       pacote=pacote)

                else:
                    if isPublicarLoja:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Publicação", resultado='Falha',
                                                                 data=Util.getDataAtual())
                    else:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Geração", resultado='Falha',
                                                                 data=Util.getDataAtual())

    def appIniciado(self, nome, qnt=0):
        print("\n\n--------------------- " + nome + " Iniciado ---------------------", qnt, "\n\n")

    def appTerminado(self, nome, qnt=0):
        print("\n\n--------------------- " + nome + " Terminado --------------------- ", qnt, "\n\n")

    def mostrarRelatorio(self):

        for success in self.situacaoAppsOk:
            self.tela.areaSucesso.insert("end", success.replace("\\", "") + "\n")
        for failure in self.situacaoAppsFalha:
            self.tela.areaFalha.insert("end", failure.replace("\\", "") + "\n")
Exemple #4
0
class Arquivo:
    def __init__(self, dados=None):
        self.caminhoNovos = Caminhos.novosAppsAndroid
        self.dados = dados
        self.pacotePendente = "br.com.appsexclusivos.pendente"
        self.notification = Notification()

    def atualizarLocalProperties(self):
        caminhos = []
        caminhos.append(Caminhos.todosAppsAndroid)
        caminhos.append(Caminhos.novosAppsAndroid)
        caminhos.append(Caminhos.caminhoTeste)

        for caminho in caminhos:
            lista = os.listdir(caminho)


            for nomeProjeto in lista:
                if (not nomeProjeto.__eq__(".idea") and not nomeProjeto.__eq__(".gradle") and not nomeProjeto.__eq__(
                        ".DS_Store")):
                    properties = caminho + nomeProjeto + "/local.properties"
                    exist = os.path.exists(properties)
                    de = Caminhos.aplicativoBase + "local.properties"
                    destino = properties


                    if (not exist):
                        print(nomeProjeto)
                        shutil.copyfile(de, destino)


            self.notification.send("Local Properties Definido", "Atualização Finalizada")

    def alterarAquivoTemporario(self, localString):
        #localString = localString + "/NovoBase/ApplicationContext.swift"

        existe = os.path.exists(localString)
        if(existe):
            print("Existe:" + localString)
            pass
        else:
            print("Não EXISTE" + localString)
            return

        arquivo = open(localString, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("jsonFile = file('/home/gustavo/Downloads/PublishClienteFiel.json')"):
                linha += "\n\t\t\t} else if(System.getProperty('os.name').toLowerCase().equals('windows')) {" \
                        "\n\t\t\t\t//Windows\n" \
                        "\t\t\t\tjsonFile = file('C:/Chaves/PublishClienteFiel.json')\n"

            if linha.__contains__("storeFile file('/home/gustavo/Downloads/_guilherme.keystore')"):
                    linha += "\n\t\t\t} else if(System.getProperty('os.name').toLowerCase().equals('windows')) {" \
                             "\n\t\t\t\t//Windows\n" \
                             "\t\t\t\tstoreFile file('C:/Chaves/_guilherme.keystore')"


            novoConteudo.append(linha)

        arquivo = open(localString, 'w')
        arquivo.close()

        arquivo = open(localString, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def alteracaoEmergencial(self):
        caminho = Caminhos.todosAppsAndroid
        lista = os.listdir(caminho)

        for p in lista:
            if (not p.__eq__(".DS_Store") and not p.__eq__(".idea")):
                caminhoCompleto = caminho + p

                local = caminhoCompleto + "/pendente/build.gradle"
                self.alterarAquivoTemporario(local)


    def getVersion(self, local):
        local = local.replace("cd ", "").replace("\\", "") + "/pendente/build.gradle"
        existe = os.path.exists(local)
        self.pacote = None

        if existe:
            arquivo = open(local, 'r')
            conteudoAtual = arquivo.readlines()

            for a in conteudoAtual:
                linha = a

                if linha.__contains__("versionCode"):
                    self.code = [int(s) for s in linha.split() if s.isdigit()]
                elif linha.__contains__("applicationId"):
                    self.pacote = linha.replace("applicationId", "").replace("\"", "").replace(" ", "").replace("\\n",
                                                                                                                "").replace(
                        "\n", "")

            arquivo.close()
            return self.code[0], self.pacote


        else:
            return None, None

    def atualizarVersionText(self, versionCode, versionName, local):
        local = local + "/pendente/build.gradle"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("versionName"):
                if versionName is None:
                    linha = linha
                else:
                    linha = "\t\tversionName \"" + versionName + "\"\n"

            elif linha.__contains__("versionCode"):
                versionCodeAtual = linha.replace("versionCode", "") \
                    .replace(" ", "") \
                    .replace("\n", "") \
                    .replace("\t", "")

                if (versionCode is None or versionCode.__eq__("") or versionCode.__eq__(
                        "AUTO_INCREMENT")) and versionCodeAtual.isdigit():
                    print("1 - Teste Aqui: ", versionCodeAtual)
                    versionCode = int(versionCodeAtual) + 1
                    print("2 - Teste Aqui: ", versionCode)
                    linha = "\t\tversionCode " + versionCode.__str__() + "\n"
                else:
                    linha = "\t\tversionCode " + versionCode.__str__() + "\n"

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def baixarConteudo(self, conteudo, destino, apagar=True):
        if (apagar):
            os.remove(destino)

        wget.download(conteudo, destino)

    def stringXml(self, localString):
        localString = localString + "/pendente/src/main/res/values/strings.xml"

        arquivo = open(localString, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            #if linha.__contains__("http://ws.appaguafacil.com.br/ClienteFiel/rest/"):
            if linha.__contains__("http://ws.appclientefiel.com.br/rest/"):
                linha = "\t<string name=\"urlws\">http://ws.appclientefiel.com.br/rest/</string>\n";

            elif linha.__contains__("http://pre.appclientefiel.com.br"):
                linha = "\t<!--<string name=\"urlws\">http://pre.appclientefiel.com.br/ClienteFiel/rest/</string>-->";

            elif linha.__contains__("http://52.86.148"):
                linha = "\t<!--<string name=\"urlws\">http://52.86.148.125:8080/ClienteFiel/rest/</string>-->";


            novoConteudo.append(linha)

        arquivo = open(localString, 'w')
        arquivo.close()

        arquivo = open(localString, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def arquivoFirebase(self, localFirebase, segundoArquivo=False):
        local = localFirebase + "/pendente/src/main/java/br/com/appsexclusivos/pendente/MyFirebaseInstanceIDService.java"

        if segundoArquivo:
            if (localFirebase.__contains__("xxx")):  # recurso técnico temporário
                local = localFirebase
            else:
                local = localFirebase + "/pendente/src/main/java/br/com/appsexclusivos/pendente/MyFirebaseMessagingService.java"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__(self.pacotePendente):
                if (not localFirebase.__contains__("xxx")):  # recurso técnico temporário
                    linha = linha.replace(self.pacotePendente, self.dados.packageName)

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()
        if (not segundoArquivo):
            self.arquivoFirebase(localFirebase, segundoArquivo=True)

    def mainActivity(self, localMain):
        localMain = localMain + "/pendente/src/main/java/br/com/appsexclusivos/pendente/MainActivity.java";

        arquivo = open(localMain, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__(self.pacotePendente):
                linha = linha.replace(self.pacotePendente, self.dados.packageName)

            elif linha.__contains__("appNome ="):
                linha = "    " + "private String appNome = \"" + self.dados.appNome + "\";";

            elif linha.__contains__("private boolean notificacaoFirebase"):
                linha = linha.replace("false", "true")

            novoConteudo.append(linha)

        arquivo = open(localMain, 'w')
        arquivo.close()

        arquivo = open(localMain, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def gradle(self, localGradle):
        localGradle = localGradle + "/pendente/build.gradle"

        arquivo = open(localGradle, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__(self.pacotePendente):
                linha = linha.replace(self.pacotePendente, self.dados.packageName)
            elif linha.__contains__("//apply plugin: 'com.google.gms.google-services'"):
                linha = linha.replace("//", "")

            novoConteudo.append(linha)

        arquivo = open(localGradle, 'w')
        arquivo.close()

        arquivo = open(localGradle, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def manifest(self, localManifest):
        localManifest = localManifest + "/pendente/src/main/AndroidManifest.xml"

        arquivo = open(localManifest, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("android:label"):
                linha = "\t" + "android:label=\"" + self.dados.projectName + "\"" + "\n"

            elif linha.__contains__(self.pacotePendente):
                linha = linha.replace(self.pacotePendente, self.dados.packageName)

            novoConteudo.append(linha)

        arquivo = open(localManifest, 'w')
        arquivo.close()

        arquivo = open(localManifest, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def applicationContextIOS(self, local):
        local = local + "/NovoBase/ApplicationContext.swift"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("var nomeApp = "):
                linha = "\t" + "var nomeApp = \"" + self.dados.projectName + "\"" + "\n"

            elif linha.__contains__("var appNome = "):
                linha = "\t" + "var appNome = \"" + self.dados.appNome + "\"" + "\n"

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def infoPlistIOS(self, local):
        local = local + "/NovoBase/Info.plist"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("<string>br.com"):
                linha = "\t\t\t" + "<string>" + self.dados.packageName + "</string>" + "\n"

            elif linha.__contains__("<string>Sua Marca Delivery"):
                linha = "\t" + "<string>" + self.dados.projectName + "</string>" + "\n"

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def getNameMainActivity(self, localMain):

        arquivo = open(localMain, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("private String appNome"):
                linha = linha.replace("private String appNome", "") \
                    .replace("\"", "") \
                    .replace("\n", "") \
                    .replace("\\n", "") \
                    .replace(" ", "") \
                    .replace("=", "") \
                    .replace(";", "") \
                    .replace("\t", "")
                arquivo.close()
                return linha

        arquivo.close()
        return None

    def manifestMetadados(self, localManifest):
        localManifest = localManifest + "/pendente/src/main/AndroidManifest.xml"

        arquivo = open(localManifest, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("android:label"):
                linha = "\t" + "android:label=\"" + self.dados.projectName + "\"" + "\n"

            novoConteudo.append(linha)

        arquivo = open(localManifest, 'w')
        arquivo.close()

        arquivo = open(localManifest, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()
Exemple #5
0
class Tela:


    def __init__(self, master=None, abrirTela=True):

        if master != None:
            if abrirTela:
                self.definirConstantes(master)
                self.criarInstancias()

                self.mainPrincipal()
                self.containerTelaPublicadorAtualizador()
                self.criarTelaResultados()
                self.containerTelaGeradorAplicativos(master)
                # self.construcaoTela(master)

    def definirConstantes(self, master):
        self.ANDROID = "android"
        self.IOS = "IOS"

        self.notify = Notification()

        self.caminhoTodosApps = Caminhos.todosAppsAndroid
        self.caminhoNovosApps = Caminhos.novosAppsAndroid

        self.caminhoTodosAppsIOS = Caminhos.todosAppsIOS
        self.caminhoNovosAppsIOS = Caminhos.novosAppsIOS

        self.caminhoTodasImagens = Caminhos.origemImagens
        self.caminhoNovasImagens = Caminhos.todasImagens

        self.caminhoSelecionado = ""
        self.caminhoSelecionadoImagens = ""

        self.isGerarSelecionados = 1
        self.isPublicarLoja = 0
        self.isGerarApk = 1
        self.isAtualizarAntes = 0

        self.lista = []
        self.master = master

    def mainPrincipal(self):
        self.framePrincipal = Frame(self.master)
        self.framePrincipal["width"] = self.width*100
        self.framePrincipal["height"] = self.height*100
        self.framePrincipal.pack()


    def containerTelaPublicadorAtualizador(self):
        self.tela_publicador_atualizador = LabelFrame(self.framePrincipal, text="Publicador/Atualizador", padx=5,
                                                      pady=5)
        self.tela_publicador_atualizador.pack(padx=10, pady=10)
        #self.tela_publicador_atualizador.place(bordermode=OUTSIDE, height=560, width=510, x=5, y=30)
        self.tela_publicador_atualizador.place(bordermode=OUTSIDE, height=self.height*100, width=self.width*49.5, x=self.width*0.5  , y=0)

        textoSelecione = Label(self.tela_publicador_atualizador)
        textoSelecione["text"] = "Selecione:"
        textoSelecione.pack()
        textoSelecione.place(bordermode=OUTSIDE, height=25, x=10, y=20)

        self.listBoxProjetos = Listbox(self.tela_publicador_atualizador, name="caminhoPasta", )
        self.listBoxProjetos["selectmode"] = SINGLE
        self.listBoxProjetos.insert(0, "AND - Todos os Aplicativos")
        self.listBoxProjetos.insert(1, "AND - Novos Aplicativos")

        # la
        self.sistema = platform.system().lower()
        if self.sistema != 'linux' and self.sistema != 'windows':
            self.listBoxProjetos.insert(2, "IOS - Todos os Aplicativos")
            self.listBoxProjetos.insert(3, "IOS - Novos Aplicativos")

            self.listBoxProjetos.insert(4, "AND - TESTE")
            self.listBoxProjetos.insert(5, "IOS - TESTE")
        else:
            self.listBoxProjetos.insert(2, "AND - TESTE")
            pass

        self.listBoxProjetos.bind('<<ListboxSelect>>', self.getListBoxProjetos)
        self.listBoxProjetos.setvar(name="asd1")
        self.listBoxProjetos.pack()
        self.listBoxProjetos.place(bordermode=OUTSIDE, height=120, width=220, x=15, y=self.height*6.5)

        self.listBoxApps = Listbox(self.tela_publicador_atualizador, name="apps")
        self.listBoxApps["selectmode"] = EXTENDED
        self.listBoxApps.bind('<<ListboxSelect>>', self.getListBoxApps)
        self.listBoxApps.setvar(name="dsa2")
        self.listBoxApps.pack()
        self.listBoxApps.place(bordermode=OUTSIDE, height=self.height*90, width=self.width*24.5, x=self.width*24.0, y=self.height*6.5)

        self.isSelecionados = IntVar()
        self.checkBox = Checkbutton(self.tela_publicador_atualizador, text="Gerar Apps Selecionados",
                                    command=self.checkBox,
                                    variable=self.isSelecionados)
        self.checkBox.select()
        self.checkBox.place(bordermode=OUTSIDE, height=25, x=250, y=20)

        self.txtQntidadeApps = Label(self.tela_publicador_atualizador, fg="blue")
        self.txtQntidadeApps.pack()
        self.txtQntidadeApps.place(bordermode=OUTSIDE, height=25, x=250, y=self.height*96.5)

        self.var2 = IntVar()
        self.checkBox2 = Checkbutton(self.tela_publicador_atualizador, text="Publicar Apps na loja",
                                     command=self.checkBox2,
                                     variable=self.var2)
        self.checkBox2.place(bordermode=OUTSIDE, height=25, x=15, y=170)

        self.var3 = IntVar()
        self.checkBox3 = Checkbutton(self.tela_publicador_atualizador, text="Gerar Apk", command=self.checkBox3,
                                     variable=self.var3)
        self.checkBox3.select()
        self.checkBox3.place(bordermode=OUTSIDE, height=25, x=15, y=190)

        self.var4 = IntVar()
        self.checkBox4 = Checkbutton(self.tela_publicador_atualizador, text="Atualizar Antes de Enviar",
                                     command=self.checkBox4,
                                     variable=self.var4)
        # self.checkBox4.select()
        self.checkBox4.place(bordermode=OUTSIDE, height=25, x=15, y=210)

        self.var5 = IntVar()
        self.checkBox5 = Checkbutton(self.tela_publicador_atualizador, text="Enviar Email",
                                     command=self.checkBox5,
                                     variable=self.var5)
        self.checkBox5.select()
        self.checkBox5.place(bordermode=OUTSIDE, height=25, x=15, y=260)

        abaixar = 200

        self.version_variable = StringVar()
        self.email_variable = StringVar()

        self.txtVersion = Entry(self.tela_publicador_atualizador, textvariable=self.version_variable)
        self.txtVersion.insert(END, "8.0 RELEASE")
        self.txtVersion['state'] = 'disabled'
        self.txtVersion["width"] = 25
        self.txtVersion.pack()
        self.txtVersion.place(bordermode=OUTSIDE, height=25, width=220, x=15, y=235)

        self.txtEmail = Entry(self.tela_publicador_atualizador, textvariable=self.email_variable)
        self.txtEmail.insert(END, "")
        self.txtEmail['state'] = 'normal'
        self.txtEmail["width"] = 25
        self.txtEmail.pack()
        self.txtEmail.place(bordermode=OUTSIDE, height=25, width=220, x=15, y=285)

        botaoGerarApps = Button(self.tela_publicador_atualizador)
        botaoGerarApps["text"] = "Gerar/Publicar Apps"
        botaoGerarApps["command"] = lambda: self.gerarAppsApoio()
        botaoGerarApps["width"] = 25
        botaoGerarApps.pack()
        botaoGerarApps.place(bordermode=OUTSIDE, height=25, width=220, x=15, y=230 + abaixar)

        self.botaoAtualizarApps = Button(self.tela_publicador_atualizador)
        self.botaoAtualizarApps["text"] = "Atualizar Núcleo"
        self.botaoAtualizarApps.pack()
        self.botaoAtualizarApps.place(bordermode=OUTSIDE, height=25, width=220, x=15, y=260 + abaixar)

        botaoAdaptarAoSistema = Button(self.tela_publicador_atualizador)
        botaoAdaptarAoSistema["text"] = "------------"
        botaoAdaptarAoSistema["command"] = lambda: self.adaptarProjeto()
        botaoAdaptarAoSistema.pack()
        botaoAdaptarAoSistema.place(bordermode=OUTSIDE, height=25, width=220, x=15, y=290 + abaixar)

        botaoAtualizarMetadados = Button(self.tela_publicador_atualizador)
        botaoAtualizarMetadados["text"] = "Atualizar Metadados"
        botaoAtualizarMetadados["command"] = lambda: self.atualizarMetadados()
        botaoAtualizarMetadados.pack()
        botaoAtualizarMetadados.place(bordermode=OUTSIDE, height=25, width=220, x=15, y=320 + abaixar)

    def containerTelaGeradorAplicativos(self, master=None):
        self.tela_gerador_aplicativos = LabelFrame(self.framePrincipal, text="Gerador de Aplicativos", padx=5, pady=5)
        self.tela_gerador_aplicativos.pack(padx=10, pady=10)
        #self.tela_gerador_aplicativos.place(bordermode=OUTSIDE, height=280, width=510, x=550, y=30)
        self.tela_gerador_aplicativos.place(bordermode=OUTSIDE, height=self.height*45, width=self.width*47.5, x= self.width*52, y=0)

        textoAppName = Label(self.tela_gerador_aplicativos)
        textoAppName["text"] = "App Name:"
        textoAppName.pack()
        textoAppName.place(bordermode=INSIDE, height=25, x=10, y=15)

        self.areaAppName = Text(self.tela_gerador_aplicativos, height=2, width=30)
        self.areaAppName.insert(END, "")
        self.areaAppName.place(bordermode=OUTSIDE, height=200, width=200, x=10, y=40)

        self.variavel_multiplataforma = IntVar()
        self.multiPlataforma = Checkbutton(self.tela_gerador_aplicativos, text="Gerar Multiplataforma",
                                           command=self.gerarApenasMultiplataforma,
                                           variable=self.variavel_multiplataforma)
        self.multiPlataforma.place(bordermode=OUTSIDE, height=25, x=220, y=40)

        self.variavel_android_apenas = IntVar()
        self.apenas_android = Checkbutton(self.tela_gerador_aplicativos, text="Gerar Apenas Android",
                                          command=self.gerarApenasAndroid,
                                          variable=self.variavel_android_apenas)
        self.apenas_android.place(bordermode=OUTSIDE, height=25, x=220, y=65)

        self.variavel_ios_apenas = IntVar()
        self.apenas_ios = Checkbutton(self.tela_gerador_aplicativos, text="Gerar Apenas IOS",
                                      command=self.gerarApenasIos,
                                      variable=self.variavel_ios_apenas)
        self.apenas_ios.place(bordermode=OUTSIDE, height=25, x=220, y=90)

        sistema = platform.system().lower()
        if sistema == 'linux' or sistema == 'windows':
            self.apenas_android.select()
        else:
            self.apenas_android.select()
            #self.multiPlataforma.select()

        botaoCriarAplicativo = Button(self.tela_gerador_aplicativos)
        botaoCriarAplicativo["text"] = "Criar Aplicativo(s)"
        botaoCriarAplicativo["command"] = lambda: self.criarApps()
        botaoCriarAplicativo.pack()
        botaoCriarAplicativo.place(bordermode=OUTSIDE, height=25, width=220, x=220, y=130)

        self.progressbar = ttk.Progressbar(self.tela_gerador_aplicativos, maximum=100, mode="indeterminate")
        self.progressbar.step(0)
        # self.progressbar.place(width=200, x=10, y=225)

    def criarInstancias(self):
        self.core = Core()
        self.projeto = Projeto(tela=self)
        self.joseph = JosephPy(tela=self)
        self.arquivo = Arquivo()

        self.width, self.height = Util.getScreenSize()
        self.width = self.width/100
        self.height = (self.height- 6*(self.height/100))/100


    def atualizarMetadados(self):
        self.notify.send("Iniciando Atualização", "")
        self.core.atualizarDados(self.caminhoSelecionado, self.lista, self.isSelecionados)
        self.notify.send("Atualização Finalizada", "")

    def adaptarProjeto(self):
        self.arquivo.atualizarLocalProperties()

    def criarTelaResultados(self):

        self.tela_resultados = LabelFrame(self.framePrincipal, text="Área de Resultados", padx=5, pady=5)
        self.tela_resultados.pack(padx=10, pady=10)
        #self.tela_resultados.place(bordermode=OUTSIDE, height=280, width=640, x=550, y=320)
        self.tela_resultados.place(bordermode=OUTSIDE, height=self.height*50, width=self.width*47.5, x=self.width*52, y=self.height*48.5)

        textoResultado = Label(self.tela_resultados)
        textoResultado["text"] = "Resultado:"

        textoSucesso = Label(self.tela_resultados)
        textoSucesso["text"] = "Sucesso:"
        textoSucesso.pack()
        textoSucesso.place(bordermode=OUTSIDE, height=25, x=10, y=15)

        self.areaSucesso = Text(self.tela_resultados, height=2, width=30, fg='black')
        self.areaSucesso.insert(END, "")
        self.areaSucesso.place(bordermode=OUTSIDE, height=220, width=200, x=10, y=40)

        textoFalha = Label(self.tela_resultados)
        textoFalha["text"] = "Falha:"
        textoFalha.pack()
        textoFalha.place(bordermode=OUTSIDE, height=25, x=220, y=15)

        self.areaFalha = Text(self.tela_resultados, height=2, width=30, fg='black')
        self.areaFalha.insert(END, "")
        self.areaFalha.place(bordermode=OUTSIDE, height=220, width=200, x=220, y=40)

        botaoLimpar = Button(self.tela_resultados)
        botaoLimpar["text"] = "Limpar Resultados"
        botaoLimpar["command"] = lambda: self.limpaCampos()
        botaoLimpar.pack()
        botaoLimpar.place(bordermode=OUTSIDE, height=25, width=170, x=430, y=40)

        informacaoApps = Button(self.tela_resultados)
        informacaoApps["text"] = "Dados dos Apps"
        informacaoApps["command"] = lambda: self.verInformacaoApps()
        informacaoApps.pack()
        informacaoApps.place(bordermode=OUTSIDE, height=25, width=170, x=430, y=65)

        self.progressbarGerar2 = ttk.Progressbar(self.tela_resultados, maximum=10, mode="indeterminate")
        self.progressbarGerar2.place(width=160, x=430, y=220)

    def limpaCampos(self):
        self.areaSucesso.delete("1.0", "end-1c")
        self.areaFalha.delete("1.0", "end-1c")

    def result(self, ok, erros):
        pass

    def popUp(self, plataforma="android", semPopup=False):
        self.toplevel = Toplevel(width=200, height=200, padx=100)
        self.toplevel.title("Confirmação")
        self.toplevel.attributes('-topmost', 'true')
        self.toplevel.grab_set()
        self.toplevel.geometry('300x200+400+200')

        self.atualizar = Button(self.toplevel)  # Botão Atualizar
        self.atualizar["command"] = lambda: self.atualizarCore(plataforma)
        self.atualizar.pack()
        self.atualizar.place(bordermode=OUTSIDE, height=25, width=170, x=100, y=100)

        if (plataforma == self.ANDROID):

            self.versionCode = Label(self.toplevel)
            self.versionCode["text"] = "Version Code:"
            self.versionCode.pack()
            self.versionCode.place(bordermode=OUTSIDE, height=25, x=10, y=20)

            self.versionCodeText = Text(self.toplevel, height=1, width=30)
            self.versionCodeText.insert(END, "AUTO_INCREMENT")
            self.versionCodeText.place(bordermode=OUTSIDE, height=25, width=150, x=120, y=20)

            self.versionName = Label(self.toplevel)
            self.versionName["text"] = "Version Name:"
            self.versionName.pack()
            self.versionName.place(bordermode=OUTSIDE, height=25, x=10, y=55)

            self.versionNameText = Text(self.toplevel, height=1, width=30)
            self.atualizar["text"] = "Atualizar"

            if (semPopup):
                self.versionNameText.insert(END, self.version_variable.get())
                self.atualizarCore(plataforma)
            else:
                self.versionNameText.insert(END, "9.0 RELEASE")




        else:
            self.versionCode = Label(self.toplevel)
            self.versionCode["text"] = "Deseja mesmo atualizar os Aplicativos?"
            self.versionCode.pack()
            self.versionCode.place(bordermode=OUTSIDE, height=25, x=50, y=20)

            self.atualizar["text"] = "Confirmar"

    def criarApps(self):

        valor = self.areaAppName.get("1.0", "end-1c")
        if valor == "":
            self.notify.send("O app name não foi definido corretamente", "")
            self.areaSucesso.insert(END, "O app name não foi definido corretamente\n")

        appsNames = valor.split("\n")

        qntTotal = 0
        nApps = 0
        for app in appsNames:
            qntTotal += 1
            nApps += self.projeto.criarProjeto(app, self.variavel_multiplataforma.get(),
                                               self.variavel_android_apenas.get(),
                                               self.variavel_ios_apenas.get())



        self.areaSucesso.insert(END, "\nApps Criados " + nApps.__str__() + " de " + qntTotal.__str__() + "\n")

    def construcaoTela(self, master=None):

        self.contorno3 = LabelFrame(self.framePrincipal, text="Cortar Imagens", padx=5, pady=5)
        self.contorno3.pack(padx=10, pady=10)
        self.contorno3.place(bordermode=OUTSIDE, height=280, width=510, x=5, y=320)

        self.listBoxImagens = Listbox(self.contorno3, name="imagens")
        self.listBoxImagens.insert(0, "Imagens Novas")
        self.listBoxImagens.insert(1, "Imagens Antigas")
        self.listBoxImagens["selectmode"] = EXTENDED
        self.listBoxImagens.bind('<<ListboxSelect>>', self.getListImagem)
        self.listBoxImagens.setvar(name="parte3")
        self.listBoxImagens.pack()
        self.listBoxImagens.place(bordermode=OUTSIDE, height=80, width=180, x=10, y=25)

        self.listagemImagens = Listbox(self.contorno3, name="apps")
        self.listagemImagens["selectmode"] = EXTENDED
        self.listagemImagens.bind('<<ListboxSelect>>', self.getListBoxApps)
        self.listagemImagens.setvar(name="listagemImagem")
        self.listagemImagens.pack()
        self.listagemImagens.place(bordermode=OUTSIDE, height=200, width=250, x=240, y=25)

        self.varGerarPrint = IntVar()
        self.gerarPrint = Checkbutton(self.contorno3, text="Gerar Prints Especiais", command=self.checkBox,
                                      variable=self.varGerarPrint)
        self.gerarPrint.select()
        self.gerarPrint.place(bordermode=OUTSIDE, height=25, x=10, y=110)

        b = IntVar()
        self.gerarCapa = Checkbutton(self.contorno3, text="Gerar Capa Apenas", command=self.checkBox,
                                     variable=b)
        self.gerarCapa.place(bordermode=OUTSIDE, height=25, x=10, y=130)

        self.botaoGerarImagens = Button(self.contorno3)
        self.botaoGerarImagens["text"] = "Gerar Imagens"
        self.botaoGerarImagens["command"] = lambda: self.gerarImagens()
        self.botaoGerarImagens.pack()
        self.botaoGerarImagens.place(bordermode=OUTSIDE, height=25, width=220, x=10, y=160)

        self.notify.send("Josepy", "Ferramenta para Aplicativos", None)

    def gerarImagens(self):
        imagem = Imagem()

        imagem.redimencionarPrintGustavo(self.caminhoSelecionadoImagens, self.varGerarPrint.get())
        self.notify.send("Prints", "Prints Gerados com sucesso!", None)
        self.areaSucesso.insert("end", "Prints Gerados com sucesso!")

    def atualizarCore(self, plataforma):
        print("Atualizando...")
        if (plataforma == self.ANDROID):
            t1 = threading.Thread(name='Thread-1-Som',
                                  target=self.core.atualizar(self.caminhoSelecionado,
                                                             self.lista,
                                                             self.isSelecionados,
                                                             self.versionCodeText.get("1.0", "end-1c"),
                                                             self.versionNameText.get("1.0", "end-1c")
                                                             ))
        else:
            t1 = threading.Thread(name='Thread-1-Som',
                                  target=self.core.atualizarIOS(self.caminhoSelecionado,
                                                                self.lista,
                                                                self.isSelecionados
                                                                ))

        t1.start()
        self.toplevel.destroy()

    def gerarAppsApoio(self):

        t2 = threading.Thread(name='Thread-1-Som', target=self.gerarApps)
        t2.start()

    def gerarApps(self):

        if (self.isAtualizarAntes):
            self.adaptarProjeto()
            self.popUp(semPopup=True)

        print(self.caminhoSelecionado)
        self.progressbarGerar2.start()
        if self.caminhoSelecionado.__eq__(self.caminhoTodosApps):

            self.joseph.makeApp(self.lista, self.isSelecionados, self.isPublicarLoja, self.caminhoSelecionado,
                                emails=self.email_variable.get())

        else:
            retorno = subprocess.call("cd " + self.caminhoSelecionado.replace(" ", "\\ ") + " ; " + "chmod -R 777 * ",
                                      shell=True)
            self.joseph.gerarApkNovos(self.lista, self.isSelecionados, self.isPublicarLoja,emails=self.email_variable.get())
        self.progressbarGerar2.stop()

    def progresso(self, valor=0):
        t3 = threading.Thread(name='Thread-2-Som', target=self.progressbarGerar2.step(valor))
        t3.start()

    def checkBox(self):
        self.isGerarSelecionados = self.isSelecionados.get()

    def checkBox2(self):
        self.isPublicarLoja = self.var2.get()
        self.checkBox3.deselect()

    def checkBox3(self):
        self.isGerarApk = self.var3.get()
        self.checkBox2.deselect()

    def checkBox4(self):
        self.isAtualizarAntes = self.var4.get()

        if (not self.isAtualizarAntes):
            self.txtVersion['state'] = 'disabled'
        else:
            self.txtVersion['state'] = 'normal'

    def checkBox5(self):
        self.isEnviarEmail = self.var5.get()

        if (not self.isEnviarEmail):
            self.txtEmail['state'] = 'disabled'
        else:
            self.txtEmail['state'] = 'normal'

    def gerarApenasMultiplataforma(self):
        self.apenas_ios.deselect()
        self.apenas_android.deselect()

    def gerarApenasAndroid(self):
        self.apenas_ios.deselect()
        self.multiPlataforma.deselect()

    def gerarApenasIos(self):
        self.apenas_android.deselect()
        self.multiPlataforma.deselect()

    def getListImagem(self, evt):
        w = evt.widget
        try:
            index = int(self.listBoxImagens.curselection()[0])
            if index == 0:
                value = self.caminhoNovasImagens

            elif index == 1:
                value = self.caminhoTodasImagens

        except IndexError:
            print("Exception")
            return

        self.caminhoSelecionadoImagens = value

        self.listagemImagens.delete(0, self.listagemImagens.size() - 1)
        imgs = sorted(os.listdir(value), reverse=True)
        for img in imgs:
            if (not img.__eq__(".idea") and not img.__eq__(".gradle") and not img.__eq__(".DS_Store")):
                self.listagemImagens.insert(0, img)

    def getListBoxApps(self, evt):

        w = evt.widget

        self.lista.clear()
        try:
            for sd in self.listBoxApps.curselection():
                self.lista.append(w.get(sd))

        except IndexError:
            print("Exception new")
            return


    def getListBoxProjetos(self, evt):
        w = evt.widget
        # aqui
        try:
            index = int(self.listBoxProjetos.curselection()[0])
            if index == 0:
                value = self.caminhoTodosApps
                self.botaoAtualizarApps["text"] = "------------"
                self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.ANDROID)
            elif index == 1:
                value = self.caminhoNovosApps
                self.botaoAtualizarApps["text"] = "------------"
                self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.ANDROID)
            elif index == 2:
                if self.sistema != 'linux' and self.sistema != 'windows':
                    value = self.caminhoTodosAppsIOS
                    self.botaoAtualizarApps["text"] = "Atualizar Núcleo IOS"
                    self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.IOS)
                else:
                    value = Caminhos.caminhoTeste
                    self.botaoAtualizarApps["text"] = "------------"
                    self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.ANDROID)

            elif index == 3:
                value = self.caminhoNovosAppsIOS
                self.botaoAtualizarApps["text"] = "Atualizar Núcleo IOS"
                self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.IOS)
            elif index == 4:
                value = Caminhos.caminhoTeste
                self.botaoAtualizarApps["text"] = "------------"
                self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.ANDROID)
            elif index == 5:
                value = Caminhos.caminhoTesteIOS
                self.botaoAtualizarApps["text"] = "Atualizar TESTE IOS"
                self.botaoAtualizarApps["command"] = lambda: self.popUp(plataforma=self.IOS)
            else:
                self.botaoAtualizarApps["text"] = "Atualizar Núcleo"

                # value = w.get(index)

        except IndexError:
            print("Exception")
            return

        self.caminhoSelecionado = value
        self.listBoxApps.delete(0, self.listBoxApps.size() - 1)
        appsExibir = sorted(os.listdir(value), reverse=True)
        qnt = 0
        for app in appsExibir:
            if (not app.__eq__(".idea") and not app.__eq__(".gradle") and not app.__eq__(".DS_Store")):
                self.listBoxApps.insert(0, app)
                qnt += 1
        self.txtQntidadeApps['text'] = "Total de Apps: " + qnt.__str__()

    def verInformacaoApps(self):

        telaPrincipal = Tk()
        telaPrincipal.title("Dados Android")

        frame = Frame(telaPrincipal)
        frame["width"] = 1300
        frame["height"] = 700
        frame.pack()

        lista = sorted(os.listdir(Caminhos.todosAppsAndroid))
        quantidade = lista.__len__()

        listaApps = Listbox(frame)

        x = 200
        y = 15
        espacos = 59
        numero = 0

        maxVersion = 0
        lastApp = ""

        for app in lista:
            if (not app.__eq__(".idea") and not app.__eq__(".gradle") and not app.__eq__(".DS_Store")):
                numero += 1

                versionCode = self.arquivo.getVersion(Caminhos.todosAppsAndroid + app)[0]
                if (versionCode > maxVersion):
                    maxVersion = versionCode
                    lastApp = app

                texto = " " + numero.__str__() + " - " + app
                caracteres = espacos - texto.__len__()

                texto += caracteres * "-" + "-" + versionCode.__str__()

                listaApps.insert(numero, texto)

                textoVersion = Label(listaApps)
                textoVersion["text"] = "Version:  ", quantidade

                if numero % 37 == 0:
                    x += 200
                    y = 15
                else:
                    y += 20

        listaApps.pack(padx=10, pady=10)
        listaApps.place(bordermode=OUTSIDE, height=660, width=600, x=10, y=30)

        numeroVersao = Label(frame)
        numeroVersao["text"] = "Last Version: " + maxVersion.__str__()
        numeroVersao.pack()
        numeroVersao.place(bordermode=OUTSIDE, height=25, x=690, y=30)

        lastAppText = Label(frame)
        lastAppText["text"] = "Last App: " + lastApp
        lastAppText.pack()
        lastAppText.place(bordermode=OUTSIDE, height=25, x=690, y=60)

        root.mainloop()
Exemple #6
0
class Arquivo:
    def __init__(self, dados=None):
        self.caminhoNovos = Caminhos.novosAppsAndroid
        self.dados = dados
        self.pacotePendente = "br.com.appsexclusivos.pendente"
        self.notification = Notification()

    def atualizarLocalProperties(self):
        caminhos = []
        caminhos.append(Caminhos.todosAppsAndroid)
        caminhos.append(Caminhos.novosAppsAndroid)

        for caminho in caminhos:
            lista = os.listdir(caminho)

            for nomeProjeto in lista:
                if (not nomeProjeto.__eq__(".idea") and not nomeProjeto.__eq__(".gradle") and not nomeProjeto.__eq__(
                        ".DS_Store")):
                    properties = caminho + nomeProjeto + "/local.properties"
                    exist = os.path.exists(properties)
                    de = Caminhos.aplicativoBase + "local.properties"
                    destino = properties
                    print(nomeProjeto)

                    if (not exist):
                        shutil.copyfile(de, destino)

            self.notification.send("Local Properties Definido", "Atualização Finalizada")


    def getVersion(self, local):
        local = local.replace("cd ", "").replace("\\", "") + Caminhos.sufixoGradle
        existe = os.path.exists(local)
        self.pacote = None

        if existe:
            arquivo = open(local, 'r')
            conteudoAtual = arquivo.readlines()

            for a in conteudoAtual:
                linha = a

                if linha.__contains__("versionCode"):
                    self.code = [int(s) for s in linha.split() if s.isdigit()]
                elif linha.__contains__("applicationId"):
                    self.pacote = linha.replace("applicationId", "").replace("\"", "").replace(" ", "").replace("\\n",
                                                                                                                "").replace("\n", "")

            arquivo.close()
            return self.code[0], self.pacote


        else:
            return None, None

    def getName(self, localManifest):
        local = localManifest.replace("cd ", "").replace("\\", "") + Caminhos.sufixoManifest
        existe = os.path.exists(local)
        self.nomeApp = None

        if existe:
            arquivo = open(local, 'r')
            conteudoAtual = arquivo.readlines()

            for a in conteudoAtual:
                linha = a

                if linha.__contains__("android:label="):
                    self.nomeApp= linha.replace("android:label=", "") \
                        .replace("\n", "")\
                        .replace("\"", "")\
                        .replace("\t","")\
                        .replace("\'", "").strip()

            arquivo.close()

            return self.nomeApp

        else:
            return None


    def getAppName(self, localMainActivity):
        local = localMainActivity.replace("cd ", "").replace("\\", "")
        print(local)
        existe = os.path.exists(local)
        self.appName = None

        if existe:
            arquivo = open(local, 'r')
            conteudoAtual = arquivo.readlines()

            for a in conteudoAtual:
                linha = a

                if linha.__contains__("private String appNome"):
                    self.appName = linha.replace("private String appNome = ", "")\
                        .replace("\"", "") \
                        .replace("\'", "") \
                        .replace("\n", "") \
                        .replace(";","")\
                        .replace("private String appNome= ", "")\
                        .replace("private String appNome=", "")\
                        .replace("private String appNome=", "").strip()

            arquivo.close()
            return self.appName


        else:
            return None

    def atualizarVersionText(self, versionCode, local, versionName=None):
        local = local + Caminhos.sufixoGradle

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("versionName"):
                if versionName is None:
                    linha = linha
                else:
                    linha = "\t\tversionName \"" + versionName + "\"\n"

            elif linha.__contains__("versionCode"):
                versionCodeAtual = linha.replace("versionCode", "") \
                    .replace(" ", "") \
                    .replace("\n", "") \
                    .replace("\t", "")


                #if (versionCode is None or versionCode.__eq__("") or versionCode.__eq__("AUTO_INCREMENT")) and versionCodeAtual.isdigit():
                if (versionCode is None and versionCodeAtual.isdigit())  or (versionCode.__str__().__eq__("") or versionCode.__str__().__eq__("AUTO_INCREMENT")) :
                    print("LAST VERSION CODE: ", versionCodeAtual)

                    versionCode = int(versionCodeAtual) + 1
                    print("UPGRADE VERSION CODE: ", versionCode)
                    linha = "\t\tversionCode " + versionCode.__str__() + "\n"
                else:
                    print("UPGRADE VERSION CODE: ", versionCode)
                    linha = "\t\tversionCode " + versionCode.__str__() + "\n"

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()



    def baixarConteudo(self, conteudo, destino, apagar=True):
        if (apagar):
            os.remove(destino)

        try:
            wget.download(conteudo, destino)
        except:
            return True

        return False


    def stringXml(self, localString):
        localString = localString + Caminhos.sufixoStringsXml

        arquivo = open(localString, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            # if linha.__contains__("http://ws.appaguafacil.com.br/ClienteFiel/rest/"):
            if linha.__contains__("http://ws.appclientefiel.com.br/rest/"):
                linha = "\t<string name=\"urlws\">http://ws.appclientefiel.com.br/rest/</string>\n";

            elif linha.__contains__("http://pre.appclientefiel.com.br"):
                linha = "\t<!--<string name=\"urlws\">http://pre.appclientefiel.com.br/ClienteFiel/rest/</string>-->";

            elif linha.__contains__("http://52.86.148"):
                linha = "\t<!--<string name=\"urlws\">http://52.86.148.125:8080/ClienteFiel/rest/</string>-->";

            novoConteudo.append(linha)

        arquivo = open(localString, 'w')
        arquivo.close()

        arquivo = open(localString, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def arquivoFirebase(self, localFirebase, packageName, segundoArquivo=False):
        local = localFirebase + Caminhos.sufixoFirebaseIDService

        if segundoArquivo:
                local = localFirebase + Caminhos.sufixoFirebaseMessagingService

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__(self.pacotePendente):
                    linha = linha.replace(self.pacotePendente, packageName)

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()
        if (not segundoArquivo):
            self.arquivoFirebase(localFirebase, packageName= packageName, segundoArquivo=True)

    def mainActivity(self, localMain, packageName,appNome):
        localMain = localMain + Caminhos.sufixoMainActivityCompleto

        arquivo = open(localMain, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__(self.pacotePendente):
                linha = linha.replace(self.pacotePendente, packageName)

            elif linha.__contains__("appNome ="):
                linha = "    " + "private String appNome = \"" + appNome + "\";";

            elif linha.__contains__("private boolean notificacaoFirebase"):
                linha = linha.replace("false", "true")

            novoConteudo.append(linha)

        arquivo = open(localMain, 'w')
        arquivo.close()

        arquivo = open(localMain, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def gradle(self, localGradle, packageName):
        localGradle = localGradle + Caminhos.sufixoGradle

        arquivo = open(localGradle, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__(self.pacotePendente):
                linha = linha.replace(self.pacotePendente, packageName)
            elif linha.__contains__("//apply plugin: 'com.google.gms.google-services'"):
                linha = linha.replace("//", "")

            novoConteudo.append(linha)

        arquivo = open(localGradle, 'w')
        arquivo.close()

        arquivo = open(localGradle, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def manifest(self, localManifest, nomeProjeto, packageName):
        localManifest = localManifest + Caminhos.sufixoManifest

        arquivo = open(localManifest, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("android:label"):
                linha = "\t" + "android:label=\"" + nomeProjeto + "\"" + "\n"

            elif linha.__contains__(self.pacotePendente):
                linha = linha.replace(self.pacotePendente, packageName)

            novoConteudo.append(linha)

        arquivo = open(localManifest, 'w')
        arquivo.close()

        arquivo = open(localManifest, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def applicationContextIOS(self, local):
        local = local + "/NovoBase/ApplicationContext.swift"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("var nomeApp = "):
                linha = "\t" + "var nomeApp = \"" + self.dados.projectName + "\"" + "\n"

            elif linha.__contains__("var appNome = "):
                linha = "\t" + "var appNome = \"" + self.dados.appNome + "\"" + "\n"

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def infoPlistIOS(self, local):
        local = local + "/NovoBase/Info.plist"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("<string>br.com"):
                linha = "\t\t\t" + "<string>" + self.dados.packageName + "</string>" + "\n"

            elif linha.__contains__("<string>Sua Marca Delivery"):
                linha = "\t" + "<string>" + self.dados.projectName + "</string>" + "\n"

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def getNameMainActivity(self, localMain):

        arquivo = open(localMain, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("private String appNome"):
                linha = linha.replace("private String appNome", "") \
                    .replace("\"", "") \
                    .replace("\n", "") \
                    .replace("\\n", "") \
                    .replace(" ", "") \
                    .replace("=", "") \
                    .replace(";", "") \
                    .replace("\t", "")
                arquivo.close()
                return linha

        arquivo.close()
        return None

    def manifestMetadados(self, localManifest):
        localManifest = localManifest + "/pendente/src/main/AndroidManifest.xml"

        arquivo = open(localManifest, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("android:label"):
                linha = "\t" + "android:label=\"" + self.dados.projectName + "\"" + "\n"

            novoConteudo.append(linha)

        arquivo = open(localManifest, 'w')
        arquivo.close()

        arquivo = open(localManifest, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def atualizarDadosAppConfig(self, local, aplicativoDados):
        local = local + "/AppConfig.txt"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("NomeApp"):
                name = linha.split("=", 1)[1]
                novoValor = aplicativoDados.projectName
                linha = linha.replace(name.__str__(), novoValor.__str__())
                linha += "\n"  # necessário
                print(linha)

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def atualizarAppConfig(self,local):
        local = local + "/AppConfig.txt"

        arquivo = open(local, 'r')
        conteudoAtual = arquivo.readlines()
        novoConteudo = []

        for a in conteudoAtual:
            linha = a

            if linha.__contains__("VersionCode"):
                code = linha.split("=", 1)[1]
                novoValor = int(code)+1
                linha = linha.replace(code.__str__(), novoValor.__str__())
                linha += "\n" #necessário
                print(linha)

            novoConteudo.append(linha)

        arquivo = open(local, 'w')
        arquivo.close()

        arquivo = open(local, 'w')
        arquivo.writelines(novoConteudo)

        arquivo.close()

    def alteradorEmergencial(self):
        caminho = Caminhos.caminhoTeste
        lista = os.listdir(caminho)

        print(caminho)

        for p in lista:
            if (not p.__eq__(".DS_Store") and not p.__eq__(".idea")):
                localString = caminho + "/" + p + "/AppConfig.txt"

                arquivo = open(localString, 'r')
                conteudoAtual = arquivo.readlines()
                novoConteudo = []

                for a in conteudoAtual:
                    linha = a

                    if linha.__contains__("VersioCode"):
                        linha = linha.replace("VersioCode", "VersionCode")

                    novoConteudo.append(linha)

                arquivo = open(localString, 'w')
                arquivo.close()

                arquivo = open(localString, 'w')
                arquivo.writelines(novoConteudo)

                arquivo.close()

    def alteracaoEmergencial(self):
        caminho = Caminhos.novosAppsAndroid
        lista = os.listdir(caminho)

        for p in lista:
            if (not p.__eq__(".DS_Store") and not p.__eq__(".idea")):
                caminhoCompleto = caminho + p
                caminhoPastaNova = caminhoCompleto

                if(not os.path.exists(caminhoPastaNova)):
                    os.mkdir(caminhoPastaNova)

                versao, pacote = self.getVersion(caminhoCompleto)

                name = self.getName(caminhoCompleto)

                caminho1 = caminhoCompleto+"/pendente/src/main/java/br/com/"
                list = os.listdir(caminho1)
                caminho2 = caminho1 + list[0] + "/"


                try:
                    list = os.listdir(caminho2)
                    caminho3 = caminho2 + list[0]
                    if(os.path.isfile(caminho3)):
                        #caminho2
                        pass
                    else:
                        caminho2 = caminho3
                except:
                    pass

                appName = self.getAppName(caminho2 + "/MainActivity.java" )

                print(versao)
                print(pacote)
                print(name)
                print(appName)
                print("-----------------------")
                print("-----------------------")

                nome_do_arquivo = caminhoPastaNova + "/AppConfig.txt"

                texto = []
                texto.append("NomeApp=" + name)
                texto.append("\n")
                texto.append("VersionName=Versão Beta 3.0 PG")
                texto.append("\n")
                texto.append("VersionCode=" + versao.__str__())
                texto.append("\n")
                texto.append("PackageName=" + pacote)
                texto.append("\n")
                texto.append("AppName=" + appName)
                texto.append("\n")

                arquivo = open(nome_do_arquivo, 'w+')
                arquivo.writelines(texto)
                arquivo.close()

                shutil.copy(caminhoCompleto + Caminhos.logo,caminhoPastaNova + "/logo.png")
                shutil.copy(caminhoCompleto + Caminhos.sufixoGoogleService, caminhoPastaNova + "/google-services.json")
Exemple #7
0
class JosephPy:
    def criarInstancias(self, tela):
        self.notify = Notification()
        self.googleSheets = GoogleSheets()
        self.relatorio = Relatorio()
        self.tela = tela

    def definirConstantes(self):

        assinatura = "./gradlew assembleRelease "
        assinatura += "-Pandroid.injected.signing.store.file=" + Caminhos.keystore + " "
        assinatura += "-Pandroid.injected.signing.store.password=gtlgtlgtl "
        assinatura += "-Pandroid.injected.signing.key.alias=guilherme.vasconcelos "
        assinatura += "-Pandroid.injected.signing.key.password=gtlgtlgtl"  # a.sort()  # ordem alfabética

        build = "./gradlew build"
        task = "./gradlew task"
        clean = "./gradlew clean"
        publicar = "./gradlew publishApkRelease"

        self.tarefas = [task, build, assinatura, clean, publicar]
        self.dataInicio = datetime.datetime.now()

    def definirCaminhoCD(self):
        self.aplicativoBase = "cd " + Caminhos.aplicativoBaseNucleo
        self.prefixoAntigos = "cd " + Caminhos.todosAppsAndroidModificado
        self.prefixoNovos = "cd " + Caminhos.novosAppsAndroidModificado

    def __init__(self, tela=None):

        self.criarInstancias(tela)
        self.definirConstantes()
        self.definirCaminhoCD()

        self.situacaoAppsOk = []
        self.situacaoAppsFalha = []

        self.todosApps = sorted(os.listdir(Caminhos.todosAppsAndroid))
        self.novosApps = sorted(os.listdir(Caminhos.novosAppsAndroid))

    def makeApp(self, listaSelecionados, gerarSelecionados, publicar, caminho):
        self.situacaoAppsOk.clear()
        self.situacaoAppsFalha.clear()

        if caminho.__eq__(Caminhos.todosAppsAndroid):
            prefixo = self.prefixoAntigos
        else:
            prefixo = self.prefixoNovos

        listaAtual = []
        listaAtual = listaSelecionados

        qnt = 0
        print("Lista:")
        print(listaAtual)

        for app in listaAtual:
            if (not app.__eq__(".idea") and not app.__eq__(".gradle") and not app.__eq__(".DS_Store")):
                nome = app.replace(" ", "\\ ")
                pacote = self.relatorio.getpacote(caminho + app)

                qnt += 1
                print(caminho + nome + Caminhos.logo)
                self.notify.send(app, "App iniciado: " + nome,
                                 caminho+ nome.replace(" ", "\ ") + Caminhos.logo)
                self.appIniciado(app, qnt)
                self.processos(nome, prefixo, publicar, pacote=pacote)
                self.appTerminado(app, qnt)
                self.notify.send(app, "App terminado: " + nome,
                                 caminho + nome.replace(" ", "\ ") + Caminhos.logo)

        self.mostrarRelatorio()



    def gerarApkNovos(self, listaSelecionados, gerarSelecionados, publicar):

        self.situacaoAppsOk.clear()
        self.situacaoAppsFalha.clear()

        listaAtual = []
        lista = self.novosApps
        prefixo = self.prefixoNovos

        if gerarSelecionados:
            listaAtual = listaSelecionados
        else:
            listaAtual = lista

        qnt = 0

        for app in listaAtual:
            if (not app.__eq__(".idea") and not app.__eq__(".gradle") and not app.__eq__(".DS_Store")):
                nome = app.replace(" ", "\\ ")
                qnt += 1
                self.notify.send(app, "App iniciado: " + nome,
                                 Caminhos.novosAppsAndroidModificado + nome + Caminhos.logo)
                self.appIniciado(app, qnt)
                self.processos(nome, prefixo, publicar)
                self.appTerminado(app, qnt)
                self.notify.send(app, "App terminado: " + nome,
                                 Caminhos.novosAppsAndroidModificado + nome + Caminhos.logo)

        print(self.dataInicio)
        print(datetime.datetime.now())

        self.mostrarRelatorio()

    def processos(self, nome, prefixo, isPublicarLoja, pacote=None):
        print("---------- Processo ----------")
        comando1 = prefixo + nome + " ; " + self.tarefas[0]
        comando2 = prefixo + nome + " ; " + self.tarefas[1]

        if isPublicarLoja:
            comando3 = prefixo + nome + " ; " + self.tarefas[3] + " ; " + prefixo + nome + " ; " + self.tarefas[4]
        else:
            comando3 = prefixo + nome + " ; " + self.tarefas[2]

        retorno = subprocess.call(comando1 + " ; " + comando2 + " ; " + comando3, shell=True)
        print(retorno)
        print("Retorno")

        if retorno == 0:
            self.situacaoAppsOk.append(nome)
            # Google Sheet
            if (pacote != None):
                if (self.googleSheets.existeEstabelecimento(pacote=pacote)):
                    if isPublicarLoja:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Publicação', resultado='Sucesso',
                                                      pacote=pacote, local=prefixo+nome)
                    else:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Geração', resultado='Sucesso',
                                                      pacote=pacote,local=prefixo+nome)

                else:
                    if isPublicarLoja:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Publicação", resultado='Sucesso',
                                                                 data=Util.getDataAtual())
                    else:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Geração", resultado='Sucesso',
                                                                 data=Util.getDataAtual())


        else:
            self.situacaoAppsFalha.append(nome)
            # Google Sheet
            if (pacote != None):
                if (self.googleSheets.existeEstabelecimento(pacote=pacote)):
                    if isPublicarLoja:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Publicação', resultado='Falha',
                                                      pacote=pacote)
                    else:
                        self.googleSheets.alterarSheet(data=Util.getDataAtual(), tipo='Geração', resultado='Falha',
                                                      pacote=pacote)

                else:
                    if isPublicarLoja:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Publicação", resultado='Falha',
                                                                 data=Util.getDataAtual())
                    else:
                        self.googleSheets.inserirEstabelecimento(nome, pacote, tipo="Geração", resultado='Falha',
                                                                 data=Util.getDataAtual())

    def appIniciado(self, nome, qnt=0):
        print("\n\n--------------------- " + nome + " Iniciado ---------------------", qnt, "\n\n")

    def appTerminado(self, nome, qnt=0):
        print("\n\n--------------------- " + nome + " Terminado --------------------- ", qnt, "\n\n")

    def mostrarRelatorio(self):

        for success in self.situacaoAppsOk:
            self.tela.areaSucesso.insert("end", success.replace("\\", "") + "\n")
        for failure in self.situacaoAppsFalha:
            self.tela.areaFalha.insert("end", failure.replace("\\", "") + "\n")
Exemple #8
0
class Projeto:
    def __init__(self, tela=None):
        self.tela = tela
        self.definirConstantes()
        self.notify = Notification()

    def definirConstantes(self):
        self.caminhoTodosAplicativos = Caminhos.todosAppsAndroid
        self.caminhoAplicativoBase = Caminhos.aplicativoBase
        self.caminhoNovos = Caminhos.novosAppsAndroid

        self.caminhoAplicativoBaseIOS = Caminhos.aplicativoBaseIOS
        self.caminhoNovosIOS = Caminhos.novosAppsIOS
        self.caminhoTodosAplicativosIOS = Caminhos.todosAppsIOS

        self.descompactar = Descompactar()

    def criarProjeto(self, app, multiplataforma=False, criarAndroid=True, criarAppIOS=False, tela=None):
        self.aplicativoDadosRequest = None
        self.setAplicativoDados(app)

        if (self.getAplicativoDados() == None):
            self.notify.send(app + "  - NÂO foi ENCONTRADO no servidor", "App não está cadastrado em nosso sistema")
            self.tela.areaFalha.insert("end", app + " - Inexistente\n")
            return 0

        erro = 0
        if multiplataforma:
            erro = self.criarProjetoAndroid(app)
            erro = self.criarProjetoIOS(app)

        if (criarAndroid and not multiplataforma):
            erro = self.criarProjetoAndroid(app)

        if (criarAppIOS and not multiplataforma):
            erro = self.criarProjetoIOS(app)

        if erro == True:
            self.notify.send(app, "Falha ao criar: " + app, None)
            self.tela.areaSucesso.insert("end", app + "\n")
            return 0
        else:
            self.notify.send(app, "Aplicativo Criado: " + app, None)
            self.tela.areaSucesso.insert("end", app + "\n")
            return 1

    def setAplicativoDados(self, app):
        self.request = Solicitacao()
        self.aplicativoDadosRequest = self.request.getObjeto(app)

    def getAplicativoDados(self):
        return self.aplicativoDadosRequest

    def verificarArquivos(self, appDados):
        pass

    def criarProjetoAndroid(self, app):
        aplicativoDados = self.aplicativoDadosRequest
        self.arquivo = Arquivo(aplicativoDados)

        para = self.caminhoNovos
        nomeProjeto = aplicativoDados.projectName.replace("'", "").replace("-", "")

        localProjetoNovo = self.caminhoNovos + nomeProjeto
        existe = os.path.exists(localProjetoNovo)

        if existe:
            shutil.rmtree(localProjetoNovo)

        os.mkdir(localProjetoNovo)


        if (aplicativoDados.urlLogo != None and aplicativoDados.urlLogo != "" and aplicativoDados.urlLogo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlLogo, localProjetoNovo+"/logo.png", apagar=False)  # logo

        elif (
                aplicativoDados.urlImgAindaNaoTemSelo != None and aplicativoDados.urlImgAindaNaoTemSelo != "" and aplicativoDados.urlImgAindaNaoTemSelo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlImgAindaNaoTemSelo,localProjetoNovo+"/logo.png", apagar=False)  # logo

        if aplicativoDados.urlArquivoFireBase != None and aplicativoDados.urlArquivoFireBase != "" and aplicativoDados.urlArquivoFireBase != "null":
            self.arquivo.baixarConteudo(aplicativoDados.urlArquivoFireBase,
                                        localProjetoNovo + "/google-services.json", apagar=False)  # arquivoFirebase

        #Cria o Arquivo de Configuração
        nome_do_arquivo = localProjetoNovo + "/AppConfig.txt"

        texto = []
        texto.append("NomeApp=" + aplicativoDados.projectName)
        texto.append("\n")
        texto.append("VersionName=Versão Beta 3.0 PG")
        texto.append("\n")
        texto.append("VersionCode=" + "1".__str__())
        texto.append("\n")
        texto.append("PackageName=" + aplicativoDados.packageName)
        texto.append("\n")
        texto.append("AppName=" + aplicativoDados.appNome)
        texto.append("\n")

        arquivo = open(nome_do_arquivo, 'w+')
        arquivo.writelines(texto)
        arquivo.close()




    def criarProjetoAndoridAntigo(self, app):
        aplicativoDados = self.aplicativoDadosRequest
        self.arquivo = Arquivo(aplicativoDados)

        de = self.caminhoAplicativoBase
        para = self.caminhoNovos
        destino = self.caminhoNovos + aplicativoDados.projectName.replace("'","").replace("-", "")
        existe = os.path.exists(destino)
        if existe:
            shutil.rmtree(destino)

        shutil.copytree(de, destino, ignore=shutil.ignore_patterns('build', 'pendente-release.apk'))
        erro = self.alterarArquivos(destino, aplicativoDados=aplicativoDados)
        if (erro):
            shutil.rmtree(destino)

        return erro

    def criarProjetoIOS(self, app):
        aplicativoDados = self.aplicativoDadosRequest

        self.arquivo = Arquivo(aplicativoDados)
        print(aplicativoDados)

        de = self.caminhoAplicativoBaseIOS
        destino = self.caminhoNovosIOS + aplicativoDados.projectName.replace("'","").replace("-", "")
        existe = os.path.exists(destino)

        if existe:
            shutil.rmtree(destino)

        shutil.copytree(de, destino,
                        ignore=shutil.ignore_patterns('*.xcworkspace', 'Pods', '*.entitlements', 'fastlane', 'DS_Store',
                                                      'Podfile.lock', 'AppIcon.appiconset'))
        self.alterarArquivosIOS(destino, aplicativoDados=aplicativoDados)

    def alterarArquivosIOS(self, destino, aplicativoDados):
        self.arquivo.applicationContextIOS(destino)
        self.arquivo.infoPlistIOS(destino)

        if (aplicativoDados.urlLogo != None and aplicativoDados.urlLogo != "" and aplicativoDados.urlLogo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlLogo, destino + Caminhos.logoIOS)  # logo

        elif (
                aplicativoDados.urlImgAindaNaoTemSelo != None and aplicativoDados.urlImgAindaNaoTemSelo != "" and aplicativoDados.urlImgAindaNaoTemSelo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlImgAindaNaoTemSelo, destino + Caminhos.logoIOS)  # logo

        erro = False
        if (os.path.exists(Caminhos.firebaseLocalIOS + aplicativoDados.appNome + ".plist")):
            shutil.copyfile(Caminhos.firebaseLocalIOS + aplicativoDados.appNome + ".plist",
                            destino + "/NovoBase/GoogleService-Info.plist")
        else:
            googleService = "https://raw.githubusercontent.com/gustaveco1997/imagens/master/Google Service/" + aplicativoDados.appNome + ".plist"
            erro = self.arquivo.baixarConteudo(googleService, destino + "/NovoBase/GoogleService-Info.plist")

        if (erro):
            self.notify.send(aplicativoDados.appNome + "  - Esqueceu FIREBASE IOS",
                             "Incluir Arquivo Firebase")
            self.tela.areaFalha.insert("end", aplicativoDados.appNome + " - FIREBASE IOS\n")
            return

        erro = False
        if (os.path.exists(Caminhos.imagensAppLocal + aplicativoDados.appNome + ".zip")):
            self.descompactar.descompact(origem=Caminhos.imagensAppLocal + aplicativoDados.appNome + ".zip",
                                         destinoPasta=Caminhos.imagensAppLocal,
                                         destinoProjeto=destino + "/NovoBase/Images.xcassets/",
                                         app_nome=aplicativoDados.appNome)
        else:
            erro = self.descompactar.downloadZip(aplicativoDados.appNome, destino + "/NovoBase/Images.xcassets/")

        if (erro):
            self.notify.send(aplicativoDados.appNome + ".zip  - Esqueceu Imagens em zip IOS",
                             "Incluir Imagens com o respectivo App_Name")
            self.tela.areaFalha.insert("end", aplicativoDados.appNome + ".zip Faltou")
            return

    def alterarArquivos(self, destino, aplicativoDados):
        self.arquivo.manifest(destino, nomeProjeto=aplicativoDados.projectName, packageName=aplicativoDados.packageName)
        self.arquivo.gradle(destino, packageName=aplicativoDados.packageName)
        self.arquivo.mainActivity(destino, packageName=aplicativoDados.packageName, appNome=aplicativoDados.appNome)

        if aplicativoDados.urlArquivoFireBase == None:
            self.notify.send(aplicativoDados.appNome + "  - Esqueceu FIREBASE ANDROID", "Incluir Arquivo Firebase")
            self.tela.areaFalha.insert("end", aplicativoDados.appNome + " - FIREBASE ANDROID\n")
            return True

        self.arquivo.arquivoFirebase(destino, packageName=aplicativoDados.packageName)
        self.arquivo.stringXml(destino)

        if (aplicativoDados.urlLogo != None and aplicativoDados.urlLogo != "" and aplicativoDados.urlLogo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlLogo, destino + Caminhos.logo)  # logo

        elif (
                aplicativoDados.urlImgAindaNaoTemSelo != None and aplicativoDados.urlImgAindaNaoTemSelo != "" and aplicativoDados.urlImgAindaNaoTemSelo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlImgAindaNaoTemSelo, destino + Caminhos.logo)  # logo

        if aplicativoDados.urlArquivoFireBase != None and aplicativoDados.urlArquivoFireBase != "" and aplicativoDados.urlArquivoFireBase != "null":
            self.arquivo.baixarConteudo(aplicativoDados.urlArquivoFireBase,
                                        destino + Caminhos.sufixoGoogleService)  # arquivoFirebase
        nomePasta = aplicativoDados.packageName.split(".")

        pack = nomePasta[nomePasta.__len__() - 1]

        os.rename(destino + "/pendente/src/main/java/br/com/appsexclusivos/pendente/",
                  destino + "/pendente/src/main/java/br/com/appsexclusivos/" + pack)
        return False

    def alterarArquivosMetadados(self, destino, aplicativoDados):
        self.arquivo = Arquivo(aplicativoDados)
        self.arquivo.manifestMetadados(destino)

        if (aplicativoDados.urlLogo != None and aplicativoDados.urlLogo != "" and aplicativoDados.urlLogo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlLogo, destino + Caminhos.logo)  # logo

        elif (
                aplicativoDados.urlImgAindaNaoTemSelo != None and aplicativoDados.urlImgAindaNaoTemSelo != "" and aplicativoDados.urlImgAindaNaoTemSelo != "null"):
            self.arquivo.baixarConteudo(aplicativoDados.urlImgAindaNaoTemSelo, destino + Caminhos.logo)  # logo