示例#1
0
 def handle(self, *args, **options):
     try:
         code_command(options['script'])
     except:
         log_exception()
         self.stdout.write('** code Exception (%s) **' % ' '.join(options['script']))
         self.stdout.write(format_exc())
示例#2
0
def render_doc_html(path):
    '''Render the HTML for the doc content'''
    try:
        log('render_doc_html', path)
        return pandoc_html(path)
    except:
        log_exception()
示例#3
0
 def handle(self, *args, **options):
     try:
         system_command(self, options['script'])
     except:
         log_exception()
         self.stdout.write('** tst Exception (%s) **' %
                           ' '.join(options['script']))
         self.stdout.write(traceback.format_exc())
示例#4
0
 def handle(self, *args, **options):
     try:
         # print('OPTIONS %s' % options['command'])
         tst_command(self, options['command'])
     except:
         log_exception()
         self.stdout.write('** tst Exception (%s) **' %
                           ' '.join(options['command']))
         self.stdout.write(traceback.format_exc())
示例#5
0
def resize_image(path, newpath, size):
    if path != newpath:
        try:
            im = Image.open(path)
            im.thumbnail((size, size), Image.ANTIALIAS)
            im.save(newpath, "JPEG")
        except IOError:
            log_exception('Error while resizing image')
            return "Cannot resize '%s'" % path
    return '%s --> %s (%s pixels)' % (path, newpath, size)
示例#6
0
 def handle(self, *args, **options):
     try:
         if options['command'] and options['command'][0] == 'idea':
             f = 'Documents/info/Index.md'
             with open(f, 'a') as x:
                 x.write('* ' + ' '.join(options['command'][1:]) + '\n\n')
         elif options['command'] and options['command'][0] == 'days':
             print_recent_dates()
         system('e Documents/info/Index.md Documents/info/Week.md')
         for d in recent_dates():
             edit_task_file(d)
     except:
         log_exception()
         self.stdout.write('** tst Exception (%s) **' %
                           ' '.join(options['command']))
         self.stdout.write(format_exc())
示例#7
0
 def handle(self, *args, **options):
     try:
         cmd = options['script'][0]
         args = options['script'][1:]
         log('SCRIPTOR: %s %s' % (cmd, args))
         if cmd=='app':
             webapp_command(self,args)
         elif cmd=='help':
             self.help()
         elif cmd=='page':
             page_command(self, args)
         elif cmd=='project':
             project_command(self,args)
         elif cmd=='tst':
             tst_command(self, args)
         else:
             self.stdout.write('**Scriptor Error**: unknown command %s' % options['script'])
             self.help()
     except:
         log_exception()
         self.stdout.write(banner('**Scriptor Exception**'))
         self.stdout.write('Scriptor Exception (%s %s)' % (cmd,args))
         self.stdout.write(traceback.format_exc())
示例#8
0
def get_student(request):
    try:
        if not request.user.is_anonymous:
            return Student.objects.get(user=request.user)
    except:
        log_exception('Cannot find student record, %s' % str(request.user))
示例#9
0
 def throw_exception():
     try:
         assert False
     except:
         log_exception("This assertion should fail")