From 133641f27ddcab35fd3591c014a41116ee30e9cb Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Fri, 20 Apr 2018 17:36:35 -0300 Subject: [PATCH] =?UTF-8?q?Checa=20q=20exporta=C3=A7=C3=A3o=20do=20zope=20?= =?UTF-8?q?foi=20feita=20antes=20de=20migrar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/legacy/migracao.py | 8 ++++++++ sapl/legacy/migracao_dados.py | 6 ++++-- sapl/legacy/scripts/exporta_zope/exporta_zope.py | 10 ++++------ sapl/legacy/scripts/exporta_zope/variaveis_comuns.py | 4 ++++ 4 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 sapl/legacy/scripts/exporta_zope/variaveis_comuns.py diff --git a/sapl/legacy/migracao.py b/sapl/legacy/migracao.py index a72bd9aaa..3840b1106 100644 --- a/sapl/legacy/migracao.py +++ b/sapl/legacy/migracao.py @@ -6,9 +6,17 @@ from django.conf import settings from sapl.legacy.migracao_dados import REPO, gravar_marco, migrar_dados from sapl.legacy.migracao_documentos import migrar_documentos from sapl.legacy.migracao_usuarios import migrar_usuarios +from sapl.legacy.scripts.exporta_zope.variaveis_comuns import TAG_ZOPE + + +def adornar_msg(msg): + return '\n{1}\n{0}\n{1}'.format(msg, '#' * len(msg)) def migrar(interativo=False): + assert TAG_ZOPE in {t.name for t in REPO.tags}, adornar_msg( + 'Antes de migrar ' + 'é necessário fazer a exportação de documentos do zope') migrar_dados(interativo=interativo) migrar_usuarios(REPO.working_dir) migrar_documentos(REPO) diff --git a/sapl/legacy/migracao_dados.py b/sapl/legacy/migracao_dados.py index b7ce154a5..922cc99a6 100644 --- a/sapl/legacy/migracao_dados.py +++ b/sapl/legacy/migracao_dados.py @@ -31,6 +31,8 @@ from sapl.comissoes.models import Comissao, Composicao, Participacao from sapl.legacy import scripts from sapl.legacy.models import NormaJuridica as OldNormaJuridica from sapl.legacy.models import TipoNumeracaoProtocolo +from sapl.legacy.scripts.exporta_zope.variaveis_comuns import \ + DIR_DADOS_MIGRACAO from sapl.materia.models import (AcompanhamentoMateria, MateriaLegislativa, Proposicao, StatusTramitacao, TipoDocumento, TipoMateriaLegislativa, TipoProposicao, @@ -731,9 +733,9 @@ def reinicia_sequence(model, id): sequence_name, id)) -DIR_DADOS_MIGRACAO = Path('~/migracao_sapl/').expand() NOME_BANCO_LEGADO = DATABASES['legacy']['NAME'] -REPO = git.Repo.init(Path(DIR_DADOS_MIGRACAO, 'repos', NOME_BANCO_LEGADO)) +DIR_REPO = Path(DIR_DADOS_MIGRACAO, 'repos', NOME_BANCO_LEGADO) +REPO = git.Repo.init(DIR_REPO) def dict_representer(dumper, data): diff --git a/sapl/legacy/scripts/exporta_zope/exporta_zope.py b/sapl/legacy/scripts/exporta_zope/exporta_zope.py index c115c7a09..b2a3cfe83 100755 --- a/sapl/legacy/scripts/exporta_zope/exporta_zope.py +++ b/sapl/legacy/scripts/exporta_zope/exporta_zope.py @@ -16,11 +16,12 @@ from functools import partial import git import magic -import pyaml import yaml +from unipath import Path + import ZODB.DB import ZODB.FileStorage -from unipath import Path +from variaveis_comuns import DIR_DADOS_MIGRACAO, TAG_ZOPE from ZODB.broken import Broken EXTENSOES = { @@ -298,9 +299,6 @@ def _dump_sapl(data_fs_path, destino, salvar): close_db() -DIR_DADOS_MIGRACAO = Path('~/migracao_sapl/').expand() - - def repo_execute(repo, cmd, *args): return repo.git.execute(cmd.split() + list(args)) @@ -365,7 +363,7 @@ def dump_sapl(sigla): status = 'completa' if finalizado else 'parcial' repo.index.commit(u'Exportação do zope {}'.format(status)) if finalizado: - repo.git.execute('git tag -f zope'.split()) + repo.git.execute('git tag -f'.split() + [TAG_ZOPE]) if __name__ == "__main__": diff --git a/sapl/legacy/scripts/exporta_zope/variaveis_comuns.py b/sapl/legacy/scripts/exporta_zope/variaveis_comuns.py new file mode 100644 index 000000000..e773f0717 --- /dev/null +++ b/sapl/legacy/scripts/exporta_zope/variaveis_comuns.py @@ -0,0 +1,4 @@ +from unipath import Path + +DIR_DADOS_MIGRACAO = Path('~/migracao_sapl/').expand() +TAG_ZOPE = 'zope'