mirror of https://github.com/interlegis/sigi.git
Browse Source
Scripts isolados ficam separados da aplicação e precisam preparar o ambiente django, que pode variar em cada ambiente. Comandos admin podem ser executados dentro do contexto da aplicação invocando ./manage.py <command>stable/1.0
Sesostris Vieira
12 years ago
10 changed files with 85 additions and 59 deletions
@ -1,30 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Atualiza a data de último uso dos serviços SEIT realizados pelas Casas Legislativas |
|||
# Colocar no CRON - basta executar uma vez por dia |
|||
# |
|||
|
|||
import sys |
|||
from django.core.management import setup_environ |
|||
|
|||
# Produção |
|||
sys.path.insert(0, '/var/interlegis/sigi') |
|||
sys.path.insert(0, '/var/interlegis/sigi/sigi') |
|||
|
|||
# Dev |
|||
import os |
|||
BASE_DIR = os.path.abspath(os.path.dirname(__file__) + '../..') |
|||
PROJECT_DIR = BASE_DIR + '/sigi' |
|||
print BASE_DIR, PROJECT_DIR |
|||
sys.path.insert(0, BASE_DIR) |
|||
sys.path.insert(0, PROJECT_DIR) |
|||
|
|||
# Faça! |
|||
from sigi import settings |
|||
setup_environ(settings) |
|||
|
|||
from sigi.apps.servicos.models import Servico |
|||
|
|||
queryset = Servico.objects.exclude(url="").exclude(tipo_servico__string_pesquisa="") |
|||
for obj in queryset: |
|||
obj.atualiza_data_uso() |
|||
print obj.url, obj.data_ultimo_uso, obj.erro_atualizacao |
@ -1,21 +0,0 @@ |
|||
# -*- coding: utf-8 -*- |
|||
import sys |
|||
from django.core.management import setup_environ |
|||
|
|||
# Produção |
|||
sys.path.insert(0, '/var/interlegis/sigi') |
|||
sys.path.insert(0, '/var/interlegis/sigi/sigi') |
|||
|
|||
# Dev |
|||
import os |
|||
BASE_DIR = os.path.abspath(os.path.dirname(__file__) + '../../..') |
|||
PROJECT_DIR = BASE_DIR + '/sigi' |
|||
sys.path.insert(0, BASE_DIR) |
|||
sys.path.insert(0, PROJECT_DIR) |
|||
|
|||
# Faça! |
|||
from sigi import settings |
|||
setup_environ(settings) |
|||
|
|||
from sigi.apps.metas.views import gera_map_data_file |
|||
print gera_map_data_file(cronjob=True) |
@ -0,0 +1,31 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# |
|||
# sigi.apps.servicos.management.commands.atualiza_uso_servico |
|||
# |
|||
# Copyright (c) 2012 by Interlegis |
|||
# |
|||
# GNU General Public License (GPL) |
|||
# |
|||
# This program is free software; you can redistribute it and/or |
|||
# modify it under the terms of the GNU General Public License |
|||
# as published by the Free Software Foundation; either version 2 |
|||
# of the License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|||
# 02110-1301, USA. |
|||
# |
|||
from django.core.management.base import BaseCommand |
|||
from sigi.apps.metas.views import gera_map_data_file |
|||
|
|||
class Command(BaseCommand): |
|||
help = u'Gera arquivo de dados de plotagem do mapa de atuação do Interlegis.' |
|||
def handle(self, *args, **options): |
|||
result = gera_map_data_file(cronjob=True) |
|||
self.stdout.write(result+"\n") |
@ -0,0 +1,35 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# |
|||
# sigi.apps.servicos.management.commands.atualiza_uso_servico |
|||
# |
|||
# Copyright (c) 2012 by Interlegis |
|||
# |
|||
# GNU General Public License (GPL) |
|||
# |
|||
# This program is free software; you can redistribute it and/or |
|||
# modify it under the terms of the GNU General Public License |
|||
# as published by the Free Software Foundation; either version 2 |
|||
# of the License, or (at your option) any later version. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU General Public License for more details. |
|||
# |
|||
# You should have received a copy of the GNU General Public License |
|||
# along with this program; if not, write to the Free Software |
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|||
# 02110-1301, USA. |
|||
# |
|||
from django.core.management.base import BaseCommand |
|||
from sigi.apps.servicos.models import Servico |
|||
|
|||
class Command(BaseCommand): |
|||
help = u'Atualiza a informação de data de último serviço dos serviços SEIT hospedados no Interlegis.' |
|||
def handle(self, *args, **options): |
|||
verbosity = int(options['verbosity']) |
|||
queryset = Servico.objects.exclude(url="").exclude(tipo_servico__string_pesquisa="") |
|||
for obj in queryset: |
|||
obj.atualiza_data_uso() |
|||
if ((verbosity == 1) and (obj.data_ultimo_uso is None)) or (verbosity > 1): |
|||
self.stdout.write(u"%s \t %s \t %s\n" % (obj.url, obj.data_ultimo_uso, obj.erro_atualizacao)) |
Loading…
Reference in new issue