Project

General

Profile

0001-cron-display-connectors-errors-as-it-runs-in-very-ve.patch

Frédéric Péters, 28 Oct 2019 10:55 AM

Download (2.44 KB)

View differences:

Subject: [PATCH] cron: display connectors/errors as it runs in very verbose
 mode (#37256)

 passerelle/base/management/commands/cron.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
passerelle/base/management/commands/cron.py
14 14
# You should have received a copy of the GNU Affero General Public License
15 15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16

  
17
import datetime
17 18
import traceback
18 19

  
19 20
from django.core.management.base import BaseCommand, CommandError
......
44 45
                    continue
45 46
                if options.get('slug') and connector.slug != options.get('slug'):
46 47
                    continue
48
                if options['verbosity'] >= 2:
49
                    print datetime.datetime.now(), connector
47 50
                try:
48 51
                    getattr(connector, frequency)()
49 52
                except Exception as e:
50
                    connector.logger.error('error running %s job (%r)' % (frequency, e))
51
                    errors.append({'connector': connector, 'exception': e, 'traceback': traceback.format_exc()})
53
                    if options['verbosity'] >= 2:
54
                        print '  traceback:'
55
                        print error['traceback']
56
                        print
57
                    else:
58
                        connector.logger.error('error running %s job (%r)' % (frequency, e))
59
                        errors.append({'connector': connector, 'exception': e, 'traceback': traceback.format_exc()})
52 60
        if errors:
53 61
            for error in errors:
54 62
                if options['verbosity'] >= 1:
55 63
                    print repr(error['connector']),
56 64
                    print '  url:', getattr(settings, 'SITE_BASE_URL', '') + error['connector'].get_absolute_url()
57 65
                    print '  error:', error['exception']
58
                if options['verbosity'] >= 2:
59
                    print '  traceback:'
60
                    print error['traceback']
61
                    print
62 66
            raise CommandError('error running jobs')
63
-