コード例 #1
0
ファイル: views_tests.py プロジェクト: esauro/akademic
 def tearDown(self):
     fm = FileManager()
     iq = ImportQueue()
     if os.path.isdir (fm.build_buffer_path(self.now)):
         shutil.rmtree(fm.build_buffer_path(self.now))
     if os.path.isdir (iq.build_data_path(self.now)):
         shutil.rmtree(iq.build_data_path(self.now))
コード例 #2
0
ファイル: import.py プロジェクト: esauro/akademic
    def handle(self, *app_labels, **options):
        force = options.get('force', False)
        debug = options.get('debug', False)
        dry_run = options.get('dry_run', False)
        tabular = options.get('tabular', True)
        variable = options.get('variable', True)
        excel = options.get('excel', True)
        delete = options.get('delete', True)
        notifica = options.get('notifica', False)
        verbosity = options.get('verbosity', 1) or dry_run
        if settings.DEBUG:
            print u"No se puede empezar la importación porque DEBUG esta a True, y esto es MUY DAÑINO para el servidor"
            return 
        if dry_run:
            print u"Recuerde que esta acciendo un dry-run, ninguna accion sera realizada"
        if verbosity:
            print u"Analizando información para importar desde %s a akademic." % settings.DATA_BACKEND
        iq = ImportQueue(None, dry_run, tabular, variable, excel, delete)
        try:
            todo = iq.get_todo_list()[-1]
        except IndexError:
            if verbosity:
                print u"No hay ninguna importación pendiente."
            return
        if verbosity:
            print u"Encontrada una importación pendiente: %s" % todo
        iq.import_process(todo, verbosity, debug=debug)

        # FIXME: Revisar asunto, from y to
        if notifica and settings.IMPORT_REPORT_NOTIFICATION and len(settings.IMPORT_REPORT_NOTIFICATION):
            print(u"Enviando informe a %s" % settings.IMPORT_REPORT_NOTIFICATION)
            if not dry_run:
                send_mail('Resultado de la carga de datos en akademic %s' % todo,
                        self.genera_mensaje(),
                        '*****@*****.**',
                        settings.IMPORT_REPORT_NOTIFICATION,
                        fail_silently=True
                    )
        else:
            print u'Nadie se ha podido enterar de esta notificación, no hay receptores de los informes configurados'

        if verbosity:
            print u"Finalizada la importación de %s" % todo
コード例 #3
0
ファイル: views_tests.py プロジェクト: esauro/akademic
 def test_upload_end_dst_exist(self):
     self.upload_all_files()
     iq = ImportQueue()
     os.mkdir (iq.build_data_path (self.now))
     response = self.c.post(reverse('end_upload_data'), self.post_data_end_upload)
     self.assertContains (response, 'Ya existe un directorio', status_code=400)