Пример #1
0
    def handle(self, *args, **options):

        #if len(args) < 4: raise CommandError('usage: <repo name> <branch> <file> <run_status>')

        br = Branch.objects.get(repo__name__exact=options['repo'], name__exact=options['branch'])
        if not br: raise CommandError("invalid repo/branch")
        if options['logtype'] == 'code':
            br.code_run_status = options['runstatus']
        else:
            br.run_status = options['runstatus']
        br.save()
        
        brlog = BranchLog()
        
        try:
            brlog = BranchLog.objects.get(branch=br, logtype=options['logtype'])
        except ObjectDoesNotExist:
            brlog.branch = br
            brlog.logtype = options['logtype']

        lastlog = 'From ' + options['file'] + '<br/>'
        
        for line in fileinput.input(options['file']):
            lastlog += line + '<br/>'
            
        if len(lastlog) > 20000:
            lastlog = lastlog[len(lastlog) - 20000:]
        brlog.lastlog = lastlog
        brlog.save()