def GET(self):
     '''
     Method:post
     '''
     try:
         log.info("Dashboard:Get")
         render.render_template("layout.tmpl")
     except Exception, e:
         log.error(e)
         return HTTPAdaptor.format_response("error", "Request processing failed.")
def render_tracks(assembly, mode, metadata_file):
    obj = yaml.load(metadata_file)
    # Just pull out the assembly ones
    if mode == 'preferences':
      generate_track_dict = generate_preferences_track_dict
    else:
      generate_track_dict = generate_predictions_track_dict
    tracks = [generate_track_dict(x) for x in obj if x['assembly'] == assembly]
    trackdb = {'tracks': tracks}
    render_template(trackdb, 'trackDb')
Example #3
0
def get_service_list_json(
        task_definition_template_dir,
        task_definition_config,
        task_definition_config_env
) -> list:
    service_list = []

    files = os.listdir(task_definition_template_dir)
    for file in files:
        file_path = os.path.join(task_definition_template_dir, file)
        try:
            with open(file_path, 'r') as template:
                task_definitions_data = render.render_template(template.read(),
                                                               task_definition_config,
                                                               task_definition_config_env)
        except Exception as e:
            raise Exception("Template error. file: %s\n%s" % (file, e))
        try:
            task_definitions = json.loads(task_definitions_data)
        except json.decoder.JSONDecodeError as e:
            raise Exception("{e.__class__.__name__} {e}\njson:\n{json}".format(e=e, json=task_definitions_data))
        for t in task_definitions:
            service_list.append(Service(task_definition=t, stop_before_deploy=False, primary_placement=False))

    return service_list
Example #4
0
        def wrapper(request, *args, **kwargs):
            module_name = get_template_app_folder(func.__module__)

            response = func(request, *args, **kwargs)
            if isinstance(response, HttpResponse):
                return response

            template_name, context_processors, mimetype = process_response(
                response, func.__name__)

            if prefix:
                if isinstance(template_name, (list, tuple)):
                    template_name = map(correct_path, template_name)
                else:
                    template_name = correct_path(template_name, prefix)
            else:
                template_name = correct_path(template_name, module_name)

            context_processors['App'] = module_name
            context_processors['View'] = func.__name__
            context_processors['Layout'] = correct_path('base.html',
                                                        prefix or module_name)

            return render_template(template_name, context_processors,
                                   context_instance=RequestContext(request),
                                   mimetype=mimetype)
Example #5
0
def test_templates(args):
    h1("Step: Check ECS Template")
    environment = None
    files = os.listdir(args.environment_yaml_dir)
    if files is None or len(files) == 0:
        raise Exception("environment yaml file not found.")
    services_config = yaml.load(args.services_yaml)
    for f in files:
        file_path = os.path.join(args.environment_yaml_dir, f)
        if os.path.isfile(file_path):
            with open(file_path, 'r') as environment_yaml:
                environment_config = yaml.load(environment_yaml.read())

                environment = environment_config.get("environment")
                if environment is None:
                    raise VariableNotFoundException("%s requires parameter `environment`." % file_path)
                environment = render.render_template(
                    str(environment),
                    environment_config,
                    args.task_definition_config_env
                )

                ecs.service.get_service_list_yaml(
                    services_config=services_config,
                    environment_config=environment_config,
                    is_task_definition_config_env=args.task_definition_config_env,
                    environment=environment
                )
                get_scheduled_task_list(
                    services_config=services_config,
                    environment_config=environment_config,
                    is_task_definition_config_env=args.task_definition_config_env,
                    environment=environment
                )
        success("Template check environment `{environment}` done.".format(environment=environment))
    def POST(self):
        '''
        Method:post
        '''
        try:
            log.info("CI:Post")
            query = HTTPAdaptor.format_query(web.ctx.env["QUERY_STRING"])
            body = HTTPAdaptor.format_form_data(web.data())
            if not (query.has_key("action") and query.has_key("commit_id")):
                raise "Invalid query string"

            commit_id = query["commit_id"]

            sopt = SQLAdaptor()
            if query["action"] == "Revoke":
                sopt.SetCommitStatus(commit_id, 6)
            elif query["action"] == "Ignore":
                sopt.SetCommitStatus(commit_id, 5)
                
            author = "mxu"
            
            request_num = sopt.GetUnprocessedRequest(author)
            
            request_url = "/".join([config.server["cvproxy"],"myunprocessedrequests"])
                        
            author_info = {"name":author,
                           "request_url":request_url,
                           "request_num":request_num}
            
            dashboard_url = "/".join([config.server["cvproxy"], "dashboard"])
            navi = [
                    {"name":"Dashboard",
                     "url":dashboard_url,
                     "theme":"unselected"
                    },
                    {"name":"Current review request",
                     "url":"#",
                     "theme":"selected"
                    }
                    ]

            
            result = {
                      "category": body["category"],
                      "comment": body["comment"],
                      "choice": query["action"]
                      }
            
            sopt.InsertActionInfo(commit_id, author, query["action"], body["category"], body["comment"])
            
            return render.render_template('current_review_result.tmpl',
                                            author = author_info,
                                            navi = navi, 
                                            commit_id = commit_id,
                                            result = result
               )
            
        except Exception, e:
            log.error(e)
            return HTTPAdaptor.format_response("error", "Request processing failed.")
Example #7
0
def get_variables(deploy_name: str, name: str, base_service_config: dict, environment_config: dict, is_task_definition_config_env: bool):
    variables = {"item": name}
    service_config = {}
    # ベースの値を取得
    variables.update(base_service_config)
    service_config.update(base_service_config)
    # ベースのvars
    base_vars = base_service_config.get("vars")
    if base_vars:
        variables.update(base_vars)
    # 各環境の設定値を取得
    variables.update(environment_config)
    # 各環境の設定を取得
    environment_config_services = environment_config.get(deploy_name)
    if environment_config_services:
        environment_service = environment_config_services.get(name)
        if environment_service:
            variables.update(environment_service)
            service_config.update(environment_service)
            environment_vars = environment_service.get("vars")
            if environment_vars:
                variables.update(environment_vars)
    # varsをrenderする
    vars_renderd = render.render_template(yaml.dump(variables), variables, is_task_definition_config_env)
    variables.update(yaml.load(vars_renderd))
    return service_config, variables

    
Example #8
0
def get_deploy_list(
        services_yaml,
        environment_yaml,
        task_definition_template_dir,
        task_definition_config_json,
        task_definition_config_env,
        deploy_service_group,
        template_group
):
    h1("Step: Check ECS Template")
    scheduled_task_list = []
    deploy_scheduled_task_list = []
    if services_yaml:
        services_config = yaml.load(services_yaml)
        environment_config = yaml.load(environment_yaml)

        environment = environment_config.get("environment")
        if environment is None:
            raise VariableNotFoundException("environment-yaml requires parameter `environment`.")
        environment = render.render_template(str(environment), environment_config, task_definition_config_env)

        service_list = ecs.service.get_service_list_yaml(
            services_config=services_config,
            environment_config=environment_config,
            is_task_definition_config_env=task_definition_config_env,
            environment=environment
        )

        scheduled_task_list = get_scheduled_task_list(
            services_config=services_config,
            environment_config=environment_config,
            is_task_definition_config_env=task_definition_config_env,
            environment=environment
        )
        deploy_scheduled_task_list = get_deploy_scheduled_task_list(
            scheduled_task_list, deploy_service_group, template_group)

    else:
        task_definition_config = json.load(task_definition_config_json)
        environment = task_definition_config['environment']
        service_list = ecs.service.get_service_list_json(
            task_definition_template_dir=task_definition_template_dir,
            task_definition_config=task_definition_config,
            task_definition_config_env=task_definition_config_env
        )
    deploy_service_list = ecs.service.get_deploy_service_list(service_list, deploy_service_group, template_group)

    # duplicate name check
    for deploy_service in deploy_service_list:
        for deploy_scheduled_task in deploy_scheduled_task_list:
            if deploy_service.family == deploy_scheduled_task.family:
                raise Exception('Duplicate family name `{family}` found.'.format(family=deploy_service.family))

    if len(deploy_service_list) == 0 and len(deploy_scheduled_task_list) == 0:
        error("Deployment target not found.")
        sys.exit(1)

    success("Template check environment `{environment}` done.".format(environment=environment))
    return service_list, deploy_service_list, scheduled_task_list, deploy_scheduled_task_list, environment
Example #9
0
    def render_to_response(self, context, **response_kwargs):
        """
        Returns a response with a template rendered with the given context.
        """
        context['App'] = get_template_app_folder(self.__module__)
        context['View'] = self.__class__.__name__.lower()
        context['Layout'] = correct_path('base.html', context['App'])

        return render_template(
            response_kwargs.pop('template', self.get_template_names()),
            context_processors=context,
            context_instance=RequestContext(self.request),
            **response_kwargs
        )
#!/usr/bin/python

import render
import os
import sys
import xmlrpclib
import subprocess
import settings
from datetime import datetime

config=settings.load_settings()

x = xmlrpclib.ServerProxy(config['xmlrpc_endpoint'])
page = x.wp.getPage(config['blog_id'], config['participants_page_id'], config['username'], config['password'])

text = render.render_template('templates/users.tmpl',datetime.now().strftime("%Y/%m/%d"))
page['description'] = text

x.wp.editPage(config['blog_id'], config['participants_page_id'], config['username'], config['password'],page,True)
#!/usr/bin/python

import render
import xmlrpclib
import json

from config import *

with open('secret.txt', 'r') as f:
    secret = json.load(f)
    passwd = secret['wordpress']['password']

x = xmlrpclib.ServerProxy(XMLRPC_ENDPOINT)
page = x.wp.getPage(BLOG_ID, PARTICIPANTS_PAGE_ID, USER, passwd)

text = render.render_template('templates/users.tmpl')
page['description'] = text

x.wp.editPage(BLOG_ID, PARTICIPANTS_PAGE_ID, USER, passwd, page, True)
Example #12
0
def generate_email():
    dry_run = False

    args = sys.argv[1:]
    if args[0] == '-n':
        dry_run = True
        args = args[1:]

    date = args[0]

    with open('ledger', 'a') as f:
        f.write("\n")
        f.write(render.render_template('templates/ledger', date))

    if not dry_run:
        subprocess.check_call(["git", "commit", "ledger",
                               "-m", "Update for %s" % (date,)])

    debts = render.get_debts()
    punt = []

    with open('ledger', 'a') as f:
        f.write("\n")
        for (user, debt) in debts:
            if debt <= (FINE_SIZE * 6):
                continue
            punt.append(user)
            f.write(PUNT_TEXT % {'user': user, 'debt': debt, 'date': date})


    if not dry_run:
        text = render.render_template('templates/week.tmpl', date, punt=punt)

        lines = text.split("\n")
        title = lines[0]
        body  = "\n".join(lines[1:])

        page = dict(title = title, description = body)

        with open('secret.txt', 'r') as f:
            secret = json.load(f)
            passwd = secret['wordpress']['password']

        x = xmlrpclib.ServerProxy(XMLRPC_ENDPOINT)
        x.metaWeblog.newPost(BLOG_ID, USER, passwd, page, True)

    email = render.render_template('templates/email.html', date, punt=punt)

    if dry_run:
        print email
    else:
        send_email('[email protected]', email)

    with open('out/email.txt', 'w') as f:
        f.write(email)

    if punt:
        with open('bloggers.yml') as b:
            bloggers = yaml.safe_load(b)
        for p in punt:
            if bloggers.get(p) and 'end' not in bloggers[p]:
                bloggers[p]['end'] = date
        with open('bloggers.yml','w') as b:
            yaml.safe_dump(bloggers, b)

        if not dry_run:
            subprocess.check_call(["git", "commit", "ledger", "bloggers.yml",
                                   "-m", "Punts for %s" % (date,)])

    # if it's a dry run, lets set the ledger back to the beginning state
    if dry_run:
        subprocess.check_call(["git", "checkout", "ledger"])

        if punt:
            subprocess.check_call(["git", "checkout", "bloggers.yml"])
Example #13
0
def get_service_list_yaml(
        services_config: dict,
        environment_config: dict,
        is_task_definition_config_env: bool,
        environment: str
) -> list:
    try:
        services = services_config["services"]
    except KeyError:
        return []

    task_definition_template_dict = services_config["taskDefinitionTemplates"]

    service_list = []
    service_name_list = []
    for service_name in services:
        if service_name in service_name_list:
            raise Exception("'%s' is duplicate service." % service_name)
        service_name_list.append(service_name)
        # 設定値と変数を取得
        service_config, variables = get_variables(
            deploy_name = 'services',
            name=service_name,
            base_service_config=services.get(service_name),
            environment_config=environment_config,
            is_task_definition_config_env=is_task_definition_config_env
        )

        # parameter check & build docker environment
        env = [{"name": "ENVIRONMENT", "value": environment}]

        registrator = service_config.get("registrator")
        if registrator is not None:
            registrator = render.render_template(str(registrator), variables, is_task_definition_config_env)
            try:
                registrator = bool(strtobool(registrator))
            except ValueError:
                raise ParameterInvalidException(
                    "Service `{service_name}` parameter `registrator` must be bool".format(service_name=service_name)
                )
            if registrator:
                env.append({"name": "SERVICE_NAME", "value": environment})
                env.append({"name": "SERVICE_TAGS", "value": service_name})

        cluster = service_config.get("cluster")
        if cluster is None:
            raise ParameterNotFoundException("Service `{service_name}` requires parameter `cluster`"
                                             .format(service_name=service_name))
        cluster = render.render_template(str(cluster), variables, is_task_definition_config_env)
        env.append({"name": "CLUSTER_NAME", "value": cluster})

        service_group = service_config.get("serviceGroup")
        if service_group is not None:
            service_group = render.render_template(str(service_group), variables, is_task_definition_config_env)
            env.append({"name": "SERVICE_GROUP", "value": service_group})

        service_template_group = service_config.get("templateGroup")
        if service_template_group is not None:
            service_template_group = render.render_template(
                str(service_template_group), variables, is_task_definition_config_env)
            env.append({"name": "TEMPLATE_GROUP", "value": service_template_group})

        desired_count = service_config.get("desiredCount")
        if desired_count is None:
            raise ParameterNotFoundException("Service `{service_name}` requires parameter `desiredCount`"
                                             .format(service_name=service_name))
        desired_count = render.render_template(str(desired_count), variables, is_task_definition_config_env)
        try:
            int(desired_count)
        except ValueError:
            raise ParameterInvalidException("Service `{service_name}` parameter `desiredCount` is int"
                                            .format(service_name=service_name))
        env.append({"name": "DESIRED_COUNT", "value": desired_count})

        minimum_healthy_percent = service_config.get("minimumHealthyPercent")
        if minimum_healthy_percent is not None:
            minimum_healthy_percent = render.render_template(str(minimum_healthy_percent),
                                                             variables,
                                                             is_task_definition_config_env)
            try:
                int(minimum_healthy_percent)
            except ValueError:
                raise ParameterInvalidException("Service `{service_name}` parameter `minimumHealthyPercent` is int"
                                                .format(service_name=service_name))
            env.append({"name": "MINIMUM_HEALTHY_PERCENT", "value": minimum_healthy_percent})

        maximum_percent = service_config.get("maximumPercent")
        if maximum_percent is not None:
            maximum_percent = render.render_template(str(maximum_percent), variables, is_task_definition_config_env)
            try:
                int(maximum_percent)
            except ValueError:
                raise ParameterInvalidException(
                    "Service `{service_name}` parameter `maximumPercent` is int".format(service_name=service_name)
                )
            env.append({"name": "MAXIMUM_PERCENT", "value": str(maximum_percent)})

        distinct_instance = service_config.get("distinctInstance")
        if distinct_instance is not None:
            distinct_instance = render.render_template(str(distinct_instance), variables, is_task_definition_config_env)
            try:
                distinct_instance = bool(strtobool(distinct_instance))
            except ValueError:
                raise ParameterInvalidException("Service `{service_name}` parameter `distinctInstance` must be bool"
                                                .format(service_name=service_name))
            if distinct_instance:
                env.append({"name": "DISTINCT_INSTANCE", "value": "true"})

        placement_strategy = service_config.get("placementStrategy")
        placement_strategy_list = None
        if placement_strategy is not None:
            placement_strategy_list = []
            for strategy in placement_strategy:
                strategy = render.render_template(json.dumps(strategy), variables, is_task_definition_config_env)
                strategy = json.loads(strategy)
                placement_strategy_list.append(strategy)
            env.append({"name": "PLACEMENT_STRATEGY", "value": str(placement_strategy)})

        primary_placement = service_config.get("primaryPlacement")
        if primary_placement is not None:
            primary_placement = render.render_template(str(primary_placement), variables, is_task_definition_config_env)
            try:
                primary_placement = bool(strtobool(primary_placement))
            except ValueError:
                raise ParameterInvalidException("Service `{service_name}` parameter `primaryPlacement` must be bool"
                                                .format(service_name=service_name))
            if primary_placement:
                env.append({"name": "PRIMARY_PLACEMENT", "value": "true"})

        task_definition_template = service_config.get("taskDefinitionTemplate")
        if task_definition_template is None:
            raise ParameterNotFoundException("Service `{service_name}` requires parameter `taskDefinitionTemplate`"
                                             .format(service_name=service_name))
        service_task_definition_template = task_definition_template_dict.get(task_definition_template)
        if service_task_definition_template is None or len(service_task_definition_template) == 0:
            raise Exception("'%s' taskDefinitionTemplate not found. " % service_name)
        if not isinstance(service_task_definition_template, str):
            raise Exception("'%s' taskDefinitionTemplate specified template value must be str. " % service_name)

        try:
            task_definition_data = render.render_template(service_task_definition_template,
                                                          variables,
                                                          is_task_definition_config_env)
        except jinja2.exceptions.UndefinedError:
            logger.error("Service `%s` jinja2 varibles Undefined Error." % service_name)
            raise
        try:
            task_definition = json.loads(task_definition_data)
        except json.decoder.JSONDecodeError as e:
            raise Exception(
                "Service `{service}`: {e.__class__.__name__} {e}\njson:\n{json}".format(service=service_name, e=e,
                                                                                        json=task_definition_data))
        load_balancers = service_config.get("loadBalancers")
        rendered_balancers = None
        if load_balancers is not None:
            rendered_balancers = []
            for balancer in load_balancers:
                d = {}
                target_group_arn = balancer.get('targetGroupArn')
                load_balancer_name = balancer.get('loadBalancerName')
                if target_group_arn is None and load_balancer_name is None:
                    raise ParameterInvalidException("Service `{service_name}` parameter `loadBalancers`"
                                                    " required `targetGroupArn` or `loadBalancerName`"
                                                    .format(service_name=service_name))
                if target_group_arn is not None and load_balancer_name is not None:
                    raise ParameterInvalidException("Service `{service_name}` parameter `loadBalancers`"
                                                    " do not set `targetGroupArn` and `loadBalancerName`"
                                                    .format(service_name=service_name))
                if target_group_arn is not None:
                    target_group_arn = render.render_template(str(target_group_arn), variables,
                                                              is_task_definition_config_env)
                    d.update({"targetGroupArn": target_group_arn})
                if load_balancer_name is not None:
                    load_balancer_name = render.render_template(str(load_balancer_name), variables,
                                                                is_task_definition_config_env)
                    d.update({"loadBalancerName": load_balancer_name})
                container_name = balancer.get('containerName')
                if container_name is None:
                    raise ParameterInvalidException("Service `{service_name}` parameter `loadBalancers`"
                                                    " required `containerName`"
                                                    .format(service_name=service_name))
                container_name = render.render_template(str(container_name), variables, is_task_definition_config_env)
                d.update({"containerName": container_name})
                container_port = balancer.get('containerPort')
                if container_port is None:
                    raise ParameterInvalidException("Service `{service_name}` parameter `loadBalancers`"
                                                    " required `containerPort`"
                                                    .format(service_name=service_name))
                container_port = render.render_template(str(container_port), variables, is_task_definition_config_env)
                try:
                    container_port = int(container_port)
                except ValueError:
                    raise ParameterInvalidException("Service `{service_name}`"
                                                    " parameter `containerPort` in `loadBlancers` must be int"
                                                    .format(service_name=service_name))
                d.update({"containerPort": container_port})

                rendered_balancers.append(d)
                env.append({"name": "LOAD_BALANCER", "value": "true"})

        # set parameters to docker environment
        for container_definitions in task_definition.get("containerDefinitions"):
            task_environment = container_definitions.get("environment")
            container_env = copy.copy(env)
            if task_environment is not None:
                if not isinstance(task_environment, list):
                    raise Exception("'%s' taskDefinitionTemplate environment value must be list. " % service_name)
                container_env.extend(task_environment)
            container_definitions["environment"] = container_env

        # disabledになったらリストから外す
        disabled = service_config.get("disabled")
        if disabled is not None:
            disabled = render.render_template(str(disabled), variables, is_task_definition_config_env)
            try:
                disabled = bool(strtobool(disabled))
            except ValueError:
                raise ParameterInvalidException("Service `{service_name}` parameter `disabled` must be bool"
                                                .format(service_name=service_name))
            if disabled:
                continue

        # stop before deploy
        stop_before_deploy = service_config.get("stopBeforeDeploy")
        if stop_before_deploy is not None:
            stop_before_deploy = render.render_template(str(stop_before_deploy), variables, is_task_definition_config_env)
            try:
                stop_before_deploy = bool(strtobool(stop_before_deploy))
            except ValueError:
                raise ParameterInvalidException("Service `{service_name}` parameter `stop_before_deploy` must be bool"
                                                .format(service_name=service_name))
        else:
            stop_before_deploy = False

        service_list.append(
            Service(
                task_definition=task_definition,
                stop_before_deploy=stop_before_deploy,
                primary_placement=primary_placement,
                placement_strategy=placement_strategy_list,
                load_balancers=rendered_balancers
            )
        )
    return service_list
    def GET(self):
        '''
        Method:get
        '''
        try:
            log.info("CI:Get")
            query = HTTPAdaptor.format_query(web.ctx.env["QUERY_STRING"])
            if not (query.has_key("author") and query.has_key("commit_id") and query.has_key("token")):
                raise InvalidQueryStringError
            author = query.get("author")
            commit_id = query.get("commit_id")
            token = query.get("token")
#            if not utils.validate_token( author = author, commit_id = commit_id, url = config.server["cvproxy"],token = token):
#                raise AuthenticationError
            
            sopt = SQLAdaptor()
            request_num = sopt.GetUnprocessedRequest(author)
            request_url = "/".join([config.server["cvproxy"],"myunprocessedrequests"])
                        
            author_info = {"name":author,
                           "request_url":request_url,
                           "request_num":request_num}
            
            dashboard_url = "/".join([config.server["cvproxy"], "dashboard"])
            navi = [
#                    {"name":"Dashboard",
#                     "url":dashboard_url,
#                     "theme":"unselected"
#                    },
                    {"name":"Current review request",
                     "url":"#",
                     "theme":"selected"
                    }
                    ]
            

            
            url = {"ignore":
                    {"absolute": "/".join([config.server["cvproxy"],"submitaction?action=ignore&commit_id=%s" % commit_id]),
                     "relative": "submitaction?action=Ignore&commit_id=%s" % commit_id},
                   "revoke":
                    {"absolute": "/".join([config.server["cvproxy"],"submitaction?action=revoke&commit_id=%s" % commit_id]),
                     "relative": "submitaction?action=Revoke&commit_id=%s" % commit_id}
                   }
            
            cijob = sopt.GetJobNameByCommit(commit_id)
            files_committed = sopt.GetCommitedFilesNum(commit_id)
            
            
            downstreamjobs = sopt.GetDownstreamJobs(cijob)
            if downstreamjobs:                
                project_info = sopt.GetProjectInfo(downstreamjobs[0])
                test_info = sopt.GetTestSummary(downstreamjobs)
                results, failed_jobs = sopt.GetTestResult(downstreamjobs)
                            
            else:
                project_info = sopt.GetProjectInfo(cijob) 
                test_info = sopt.GetTestSummary([cijob])
                results, failed_jobs = sopt.GetTestResult([cijob])
                    
            log.debug("downstream jobs: %s" % downstreamjobs)
            log.debug("project_info: %s" % project_info) 
            log.debug("test_info: %s" % test_info)
            
            
            info = {"product": project_info["product"],
                    "platform":project_info["platform"],
                    "version":project_info["version"],
                    "files_committed": files_committed,
                    "tests_executed": test_info["tests"],
                    "failures":test_info["failures"]}             

            ci_url = config.ciserver["urlprefix"]
            jobs = []

            jobs.append(
                       {"jobpage":"/".join([ci_url,cijob[0]]),
                        "name":cijob[0],
                        "overview": "/".join([ci_url,cijob[0],cijob[1]]),
                        "console": "/".join([ci_url,cijob[0],cijob[1],"console"]),
                        "workspace": "/".join([ci_url,cijob[0],"ws"]),
                        "testresult": "/".join([ci_url,cijob[0],cijob[1],"TestReport/?"]),
                        "logs": "/".join([ci_url,cijob[0],cijob[1],"artifact/logs"]),
                        "results": results,
                        "failed_jobs": opts.FormatFailedJobs(failed_jobs)
                        }                               
                        )    
                           
                  
                               
            categories = sopt.GetCategory()
            
            diff_list = sopt.GetDiffSetByCommit(commit_id)
            codes = opts.FormatDiffs(diff_list)
        
            return render.render_template('current_review_request.tmpl',
                           author = author_info,
                           navi = navi, 
                           url = url, 
                           commit_id = commit_id,
                           info = info,
                           categories = categories,
                           jobs = jobs,
                           codes = codes)
        except Exception, e:
            log.error(e)
            return HTTPAdaptor.format_response("error", "Request processing failed.")
Example #15
0
USER            = '[email protected]'
BLOG_ID         = 1

dry_run = False

args = sys.argv[1:]
if args[0] == '-n':
    dry_run = True
    args = args[1:]

date = args[0]
today = str(datetime.date.today())

with open('ledger', 'a') as f:
    f.write("\n")
    f.write(render.render_template('templates/ledger', date))

subprocess.check_call(["git", "commit", "ledger",
                       "-m", "Update for %s" % (date,)])

debts = render.get_debts()
punt = []

with open('ledger', 'a') as f:
    f.write("\n")
    for (user, debt) in debts:
        if debt < 30: continue
        punt.append(user)
        f.write("""\
%(today)s Punt
  Pool:Owed:%(user)s  $-%(debt)s
Example #16
0
# encoding: utf-8

import render
import os
import sys
import xmlrpclib
import subprocess
import datetime
import yaml
import settings

config = settings.load_settings()

dry_run = False

args = sys.argv[1:]
if args[0] == "-n":
    dry_run = True
    args = args[1:]

date = args[0]

debts = render.get_debts()

email = render.render_template("templates/email.txt", date, mail=config["mail"])
if dry_run:
    print email
if not dry_run:
    p = subprocess.Popen(["mutt", "-H", "-"], stdin=subprocess.PIPE)
    p.communicate(email)
Example #17
0
import settings

config = settings.load_settings()

dry_run = False

args = sys.argv[1:]
if args[0] == '-n':
    dry_run = True
    args = args[1:]

date = args[0]

debts = render.get_debts()

text = render.render_template('templates/week.tmpl', date)
if dry_run:
    print >>sys.stderr, "Dry run only, not posting:"
    print text
else:
    lines = text.split("\n")
    title = lines[0]
    body  = "\n".join(lines[1:])

    page = dict(title = title, description = body)

    passwd = config['password']

    x = xmlrpclib.ServerProxy(config['xmlrpc_endpoint'])
    x.metaWeblog.newPost(config['blog_id'], config['username'], passwd, page, config['publish'])
    if config['publish']:
    if args[0] == '-r':
        dry_run = True
        reminder = True
        args = args[1:]

    if args[0] == '-n':
        dry_run = True
	send_mail = False
        args = args[1:]

date = args[0]

with open('ledger', 'a') as f:
    f.write("\n")
    f.write(render.render_template('templates/ledger', date))

if not dry_run:
    subprocess.check_call(["git", "commit", "ledger",
                           "-m", "Update for %s" % (date,)])

debts = render.get_debts()
punt = []

with open('ledger', 'a') as f:
    f.write("\n")
    for (user, debt) in debts:
        if debt < 30: continue
        punt.append(user)
        f.write("""\
%(date)s Punt
Example #19
0
args = sys.argv[1:]
if args[0] == '-q':
    dry_run = True
    quick_view = True
    args = args[1:]

if args[0] == '-n':
    dry_run = True
    args = args[1:]

date = args[0]

with open('ledger', 'a') as f:
    f.write("\n")
    f.write(render.render_template('templates/ledger', date))

if not dry_run:
    subprocess.check_call(["git", "commit", "ledger", "-m", "Update for %s" % (date,)])

debts = render.get_debts()
punt = []

with open('ledger', 'a') as f:
    f.write("\n")
    for (user, debt) in debts:
        if debt < 30: continue
        punt.append(user)
        f.write("""\
%(date)s Punt
  Pool:Owed:%(user)s  $-%(debt)s