Пример #1
0
def send(config, mailing_list):
    connection = conn.postgres_connect(config)
    report_rows = conn.get_rows_count(connection,
                                      'vw_sprint_userstories_report')
    if report_rows > 0:
        # release headers for email subject
        release_headers = conn.get_rows(connection,
                                        "select * from vw_release_headers")[0]
        # release summary fields and data
        tot_report_data = conn.postgres_rows_select(
            connection, "select * from vw_release_summary_report")
        tot_report_headers = conn.get_table_culomns(
            connection, 'vw_release_summary_report')
        # release userstories fields and data
        sub_tot_report_data = conn.postgres_rows_select(
            connection, "select * from vw_release_userstories_report")
        sub_tot_report_headers = conn.get_table_culomns(
            connection, 'vw_release_userstories_report')
        html = report_to_html_doc(tot_report_headers, tot_report_data,
                                  sub_tot_report_headers, sub_tot_report_data)
        subject = "Release '{0}' report - day {1} out of {2} days".format(
            release_headers['release_title'], release_headers['day_number'],
            release_headers['total_days'])
        to_list = None
        cc_list = None
        if mailing_list:
            to_list = config['mailing_list']['release']['to']
            cc_list = config['mailing_list']['release']['cc']
        fnx.send_email(subject, html, to_list, cc_list)
Пример #2
0
def send(config):
    connection = conn.postgres_connect(config)
    tasks_headers = conn.get_table_culomns(connection, 'vw_inventory_tot')
    tasks_data = conn.postgres_rows_select(connection,
                                           'select * from vw_inventory_tot')
    html = report_to_html_table(tasks_headers, tasks_data)
    subject = "Yodiz Data Validation Report"
    to_list = None
    cc_list = None
    fnx.send_email(subject, html, to_list=to_list, cc_list=cc_list)
Пример #3
0
def extract(config,url_headers,transact_guid):
    connection = conn.postgres_connect(config)
    releases_list = get_releases_list(config,url_headers,transact_guid)
    insert_releases_table(connection,releases_list,transact_guid)
    rows_inserted = releases_feedback(connection)
    table_name = 'releases'
    action = 'insert'
    database = config['postgres']['dbname']
    conn.update_db_log(connection,transact_guid,table_name,action,rows_inserted)
    print "{0} rows were inserted to 'releases' table in {1} database".format(rows_inserted,database)
Пример #4
0
def send(config, mailing_list, output_file):
    connection = conn.postgres_connect(config)
    report_rows = conn.get_rows_count(connection,
                                      'vw_sprint_userstories_report')
    if report_rows > 0:
        statement = 'select * from vw_sprints_headers'
        sprints_headers = conn.get_rows(connection, statement)
        i = 1
        for sprint_header in sprints_headers:
            sprint_id = sprint_header['sprint_id']
            sprint_title = sprint_header['sprint_title']
            html = ""  # build_HTML(tot_report_headers,tot_report_data,userstories_report_headers,userstories_report_data,issues_report_headers,issues_report_data,image_title)
            tot_report_html = tot_report_to_HTML(sprint_title, connection)
            userstories_report_html = userstories_report_to_HTML(
                sprint_title, connection)
            issues_report_html = issues_report_to_HTML(sprint_title,
                                                       connection)
            if output_file:
                project_path = config['project']['path']
                html_lib = os.path.join(project_path, '.yodiz/debug/html/')
                html_file_name = os.path.join(
                    html_lib, 'sprints_{0}.html'.format(str(i)))
                html_file = open(html_file_name, "wb")
                html_file.writelines(html)
                html_file.close()
            else:
                create_sprint_chart(config, sprint_id)
                subject = "Sprint '{0}' report - day {1} out of {2} days".format(
                    sprint_header['sprint_title'], sprint_header['day_number'],
                    sprint_header['total_days'])
                to_list = None
                cc_list = None
                if mailing_list:
                    if 'blue' in sprint_header['sprint_title'].lower():
                        to_list = config['mailing_list']['sprints']['blue'][
                            'to']
                        cc_list = config['mailing_list']['sprints']['blue'][
                            'cc']
                    if 'query engine' in sprint_header['sprint_title'].lower():
                        to_list = config['mailing_list']['sprints']['green'][
                            'to']
                        cc_list = config['mailing_list']['sprints']['green'][
                            'cc']
                send_email_image(config,
                                 sprint_id,
                                 sprint_title,
                                 tot_report_html,
                                 userstories_report_html,
                                 issues_report_html,
                                 to_list=to_list,
                                 cc_list=cc_list)
            i += 1
Пример #5
0
def create_sprint_chart(config, sprint_id):
    connection = conn.postgres_connect(config)
    statement = "select * from vw_sprint_burndown_chart where sprint_id ={0} order by sprint_day".format(
        sprint_id)
    #print statement
    sprint_chart_data = conn.get_rows(connection, statement)
    remaining_days = []
    trend_line = []
    remaining_effort = []
    for item in sprint_chart_data:
        remaining_days.append(item['remaining_days'])
        trend_line.append(item['trend_line'])
        remaining_effort.append(item['remaining_effort'])
    #print trend_line
    chart.build_sprint_chart(config, sprint_id, remaining_days, trend_line,
                             remaining_effort)
Пример #6
0
def get_api_response(config=None,
                     url_headers=None,
                     url=None,
                     transact_guid=None):
    response = requests.get(url, headers=url_headers)
    lst = response.json()
    response_code = response.status_code
    if response_code == 200:
        response_text = 'Data pull succeeded'
    else:
        response_text = response.text
        # write to log

    if config is not None:
        db_conn = conn.postgres_connect(config)
        conn.update_api_log(db_conn, transact_guid, url, response_code,
                            response_text)
    return lst
Пример #7
0
def send(config, mailing_list, output_file):
    connection = conn.postgres_connect(config)
    unassigned_report_data = conn.postgres_rows_select(
        connection, 'select full_name from vw_capacity_unassigned')
    capacity_report_headers = conn.get_table_culomns(connection,
                                                     'vw_capacity_report')
    capacity_report_data = conn.postgres_rows_select(
        connection,
        'select * from vw_capacity_report where "Sprint Title" is not null')
    html = build_HTML(capacity_report_headers, capacity_report_data,
                      unassigned_report_data)
    if output_file:
        print output_file
    else:
        subject = "R&D members - Sprint capacity report"
        to_list = None
        cc_list = None
        if mailing_list:
            to_list = config['mailing_list']['capacity']['to']
            cc_list = config['mailing_list']['capacity']['cc']
        fnx.send_email(subject, html, to_list=to_list, cc_list=cc_list)
Пример #8
0
def main():

    config = fnx.import_config(__file__)
    connection = conn.postgres_connect(config)
    # statement = "select * from vw_sprint_burndown_chart where sprint_id =159"
    # sprint_chart_data = conn.get_rows(connection,statement)
    # remaining_days = []
    # trend_line = []
    # remaining_effort = []
    # for item in sprint_chart_data:
    #     remaining_days.append (item['remaining_days'])
    #     trend_line.append(item['trend_line'])
    #     remaining_effort.append(item['remaining_effort'])
    # plot.build_sprint_chart(config, remaining_days,trend_line,remaining_effort)
    #sys.exit(0)
    dbname = config['postgres']['dbname']
    port = config['postgres']['port']
    host = config['postgres']['host']
    user = config['postgres']['user']
    project_path = config['project']['path']
    project_name = config['project']['name']
    project_full_path = os.path.join(project_path, project_name)
    html_lib = os.path.join(project_path, '.yodiz/debug/html/')
    python = config['prerequisites']['python']

    params = argp.params()
    if params.cmd_object == 'build':
        db_object = ""
        if params.database:
            db_object = "database"
        if params.views:
            db_object = "views"
        if params.ddl:
            print "created {0} ddl file for database {1}".format(
                db_object, dbname)
            statement = "{0}.yodiz/build/{1}_build.sh".format(
                project_path, db_object)
            os.system(statement)
        if params.execute:
            print "executed {0} ddl file on database {1}".format(
                db_object, dbname)
            statement = "psql -h {0} -p {1} -d {2} -U {3} -a -f {4}.yodiz/build/{5}_build.sql".format(
                host, port, dbname, user, project_path, db_object)
            os.system(statement)

    if params.cmd_object == 'pull':
        transact_guid = uuid.uuid4()
        url_headers = {}
        url_headers['api-key'] = config["yodiz"]["api-key"]  #params.key
        url_headers['api-token'] = config["yodiz"]["api-token"]  #params.token
        table_name = params.resource
        if params.truncate:
            conn.truncate_table(config, table_name, transact_guid)
        if params.resource == 'sprints':
            sprints_extractor.extract(config, url_headers, transact_guid)
        if params.resource == 'releases':
            releases_extractor.extract(config, url_headers, transact_guid)
        if params.resource == 'users':
            users_extractor.extract(config, url_headers, transact_guid)
        if params.resource == 'issues':
            issues_extractor.extract(config, url_headers, transact_guid)
        if params.resource == 'userstories':
            userstories_extractor.extract(config, url_headers, transact_guid)
        if params.resource == 'tasks':
            tasks_extractor.extract(config, url_headers, transact_guid)

    if params.cmd_object == 'mail':
        if params.sprints:
            sprints_mail.send(config, params.mailing_list, params.output_file)
        if params.capacity:
            capacity_mail.send(config, params.mailing_list, params.output_file)
        if params.release:
            release_mail.send(config, params.mailing_list)
        if params.inv:
            inv_mail.send(config)

    if params.cmd_object == 'query':
        if params.sprints:
            statement = 'select * from {0}'.format(params.sprints)
            rows = conn.get_rows(connection, statement)
            for row in rows:
                print 'sprint title: {0} , sprint id:{1}'.format(
                    row['sprint_title'], row['sprint_id'])