Beispiel #1
0
def adminMenu(request):
    if request.method == u'GET' and request.GET.__contains__('snapshot') and request.GET['snapshot'] == 'true':
        branch_id = request.GET['branch_id']
        branch = Branch.objects.get(id=branch_id)
        if branch.run_status != 'r':
            repo_name = branch.repo.name
            branch_name = branch.name
            pr = subprocess.Popen(os.path.join(settings.ROOT_PATH, 'cronjob.sh') + ' ' + repo_name + ' ' + branch_name + ' >/tmp/ssRun.out 2>&1 &', shell=True)
            logger.debug('Started With pid ' + str(pr.pid))
            pr.wait()
            if pr.returncode == 0:
                brlog = BranchLog()                
                try:
                    brlog = BranchLog.objects.get(branch=branch)
                except ObjectDoesNotExist:
                    brlog.branch = branch
                brlog.last_log = 'Started'
                brlog.save()
                branch.run_status = 'r'
                branch.save()
                return redirect("/admin/?success=true")
            return redirect("/admin/?failed=true")        

    repos = Repo.objects.all()
    branches = Branch.objects.all()
    ctab = CronTab()
    cronlist = []
    for item in [entry.render() for entry in ctab]:
        if item.find(CRON_COMMENT) != -1:
            cronlist.append(item)
    
    return render_to_response('admin_menu.html', {'repos': repos, 'branches':branches, 'crontab':cronlist}, context_instance=RequestContext(request))
Beispiel #2
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=args[0], name__exact=args[1])
        if not br: raise CommandException("invalid repo/branch")
        br.run_status = args[3]
        br.save()
        
        brlog = BranchLog()
        
        try:
            brlog = BranchLog.objects.get(branch=br)
        except ObjectDoesNotExist:
            brlog.branch = br

        lastlog = 'From ' + args[2] + '<br/>'
        
        for line in fileinput.input(args[2]):
            lastlog += line + '<br/>'
            
        if len(lastlog) > 20000:
            lastlog = lastlog[len(lastlog) - 20000:]
        brlog.lastlog = lastlog
        brlog.save()
def adminMenu(request):
    if request.method == u"GET" and request.GET.__contains__("snapshot") and request.GET["snapshot"] == "true":
        branch_id = request.GET["branch_id"]
        branch = Branch.objects.get(id=branch_id)
        if branch.run_status != "r":
            repo_name = branch.repo.name
            branch_name = branch.name
            pr = subprocess.Popen(
                os.path.join(settings.ROOT_PATH, "cronjob.sh")
                + " "
                + repo_name
                + " "
                + branch_name
                + " >/tmp/ssRun.out 2>&1 &",
                shell=True,
            )
            logger.debug("Started With pid " + str(pr.pid))
            pr.wait()
            if pr.returncode == 0:
                brlog = BranchLog()
                try:
                    brlog = BranchLog.objects.get(branch=branch)
                except ObjectDoesNotExist:
                    brlog.branch = branch
                brlog.last_log = "Started"
                brlog.save()
                branch.run_status = "r"
                branch.save()
                return redirect("/admin/?success=true")
            return redirect("/admin/?failed=true")

    repos = Repo.objects.all()
    branches = Branch.objects.all()
    ctab = CronTab()
    cronlist = []
    for item in [entry.render() for entry in ctab]:
        if item.find(CRON_COMMENT) != -1:
            cronlist.append(item)

    return render_to_response(
        "admin_menu.html",
        {"repos": repos, "branches": branches, "crontab": cronlist},
        context_instance=RequestContext(request),
    )
def adminMenu(request):
    if request.method == u'GET' and request.GET.__contains__('snapshot') and request.GET['snapshot'] == 'true':
        branch_id = request.GET['branch_id']
        branch = Branch.objects.get(id=branch_id)
        if branch.run_status != 'r':
            repo_name = branch.repo.name
            branch_name = branch.name
            pr = subprocess.Popen(os.path.join(settings.ROOT_PATH, 'cronjob.sh') + ' ' + repo_name + ' ' + branch_name + ' >/tmp/ssRun.out 2>&1 &', shell=True)
            logger.debug('Started With pid ' + str(pr.pid))
            pr.wait()
            if pr.returncode == 0:
                brlog = BranchLog()                
                try:
                    brlog = BranchLog.objects.get(branch=branch)
                except ObjectDoesNotExist:
                    brlog.branch = branch
                brlog.last_log = 'Started'
                brlog.save()
                branch.run_status = 'r'
                branch.save()
                return redirect("/admin/?success=true")
            return redirect("/admin/?failed=true")        

    repos = Repo.objects.all()
    branches = Branch.objects.all()
    ctab = CronTab()
    cronlist = []
    for item in [entry.render() for entry in ctab]:
        if item.find(CRON_COMMENT) != -1:
            cronlist.append(item)
    
    return render_to_response('admin_menu.html', {'repos': repos, 'branches':branches, 'crontab':cronlist}, context_instance=RequestContext(request))
Beispiel #5
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=args[0], name__exact=args[1])
        if not br: raise CommandException("invalid repo/branch")
        br.run_status = args[3]
        br.save()

        brlog = BranchLog()

        try:
            brlog = BranchLog.objects.get(branch=br)
        except ObjectDoesNotExist:
            brlog.branch = br

        lastlog = 'From ' + args[2] + '<br/>'

        for line in fileinput.input(args[2]):
            lastlog += line + '<br/>'

        if len(lastlog) > 20000:
            lastlog = lastlog[len(lastlog) - 20000:]
        brlog.lastlog = lastlog
        brlog.save()