Example #1
0
    def __init__(self):
        """
    Initializes the parameters related the Powerpoint file to be generated.
    """

        # Applications (initially set to None)
        self.excel = None
        self.ppt = None

        # Presentation file
        self.ppt_file = None

        # Index to be used when adding slides to the Powerpoint presentation
        self.index = 1

        # Index for this Powerpoint's blank page within the template
        self.blank_index = 12

        # Integer for template color (orange)
        self.colornum = self.rgb(red=230, green=118, blue=0)

        # Paths for template files
        self.template_path = create_dirpath(subdirs=[TEMPLATE_DIR])
        self.iso_logo = os.path.join(self.template_path,
                                     'iso_orange_template.png')
        self.ppt_template = os.path.join(self.template_path,
                                         'ppt_orange_template.potx')

        # Path for saved Powerpoint files
        self.save_path = create_dirpath(subdirs=[PPT_DIR])
Example #2
0
    def __init__(self, project_map):
        """
    Initializes the initial parameters for JIRA.
    
    @param project_map: Data dictionary mapping project groups to a list of tuples 
    containing associated project keys and names.
    """

        super(GTJiraPPT, self).__init__(GT_JIRA_DIR)

        # Sets project group map
        self.project_map = project_map

        # Sets issue type list
        self.issue_types = [CR, DEFECT, TASK]

        # Sets issue type definitions
        self.issue_def = {
          CR : 'A CR is a request for changes to the project solution that are' + \
              ' submitted for analysis, evaluation, assignment, and resolution.',
          DEFECT : 'A Defect is the result of a nonconformity discovered during' + \
                  ' testing. It follows an identical workflow to CRs and are' + \
                  ' linked to CRs where applicable.',
          TASK : 'A Task is an issue in JIRA, which represents a question, ' + \
                'problem, or condition that requires a decision and resolution.'
        }

        # Sets file paths for directories containing project data
        dir_link = [STATE_OF_QUALITY_DIR, GT_JIRA_DIR]
        self.project_path = create_dirpath(subdirs=dir_link + [PROJECT_DIR])
        self.project_group_path = create_dirpath(subdirs=dir_link +
                                                 [GROUP_DIR])
Example #3
0
    def __init__(self,
                 sheet_names,
                 header_lists,
                 filename='Raw Data',
                 save_path=create_dirpath()):
        """
    Initializes the Excel file containing raw data, which will be saved at
    the given path with the given file name.
    
    @param sheet_names: A list of sheet names for each sheet being created.
    @param header_lists: A list of lists of tuples, with each header list
    corresponding with a different sheet. It has  the following format: 
      [[(header, column_width)], [(header, column_width)]]
    @param filename: Name of the file (without file extension).
    @param save_path: File path where Excel sheet will be saved at.
    """

        super(RawDataWriter, self).__init__(filename, save_path)
        self.data_type = 'Raw'

        # Initializes the worksheets of the workbook
        self.sheets = OrderedDict()
        self.row = OrderedDict()
        for name in sheet_names:
            self.sheets[name] = self.wb.add_worksheet(name)
            self.row[name] = 1  # Sets starting row of writes (0-indexed)

        # Initializes tables for each sheet
        for index, sheet_name in enumerate(sheet_names):
            headers = header_lists[index]
            self._create_initial_tables(self.sheets[sheet_name], headers)
    def _produce_raw_data_file(self, project, data, *args, **kwargs):
        """
    Produces the Excel raw data files storing the given data.
    
    @param project: Name of project for which raw data files are being produced.
    @param data: Data being stored as raw data.
    @param *args: Arbitrary list arguments for the function.
    @param *kwargs: Arbitrary keyword arguments for the function.
    @return: File paths of the raw data files produced.
    """

        # Save path for raw data
        directories = self.base_dir_trail + [
            PROJECT_DIR, project, RAW_DATA_DIR
        ]
        save_path = create_dirpath(subdirs=directories)

        file_paths = []
        for metric_type, metric_data in data.iteritems():
            # Prepares data dictionary for write to the sheets within new Excel file
            raw_data = self._prepare_data_for_raw_file(metric_data)

            # Writes data to raw data files
            raw_writer = RawDataWriter(
                raw_data.keys(), self.raw_data_headers[metric_type],
                '%s %s Raw Data' % (project, metric_type), save_path)
            file_paths.append(raw_writer.produce_workbook(raw_data))
        return file_paths
    def _read_excel_project_map(self):
        """
    Reads the group to project mappings from the JIRA Projects Excel file.
    
    @return: Data dictionary mapping project group names to a list of tuples
    with project keys and associated full project names. It looks like:
      <project group> -> [(project key, full project name),]
    """

        # Initializes group map
        group_map = {TMS_DIR: []}

        # File path of JIRA projects file
        filepath = '%s\\TMS Projects.xlsx' % create_dirpath(
            subdirs=[MATRICES_DIR])

        # Workbook for file
        wb = xlrd.open_workbook(filepath)

        # Sheet with project information
        sheet = wb.sheet_by_index(0)

        # Traverses through each row for projects
        for row in range(sheet.nrows)[1:]:
            name = str(sheet.cell(row, 0).value).strip()
            in_use = str(sheet.cell(row, 2).value).strip()
            if (in_use == 'Yes'):
                group_map[TMS_DIR].append((name, name))

        # Releases resources using the file to restore used memory
        wb.release_resources()

        return group_map
Example #6
0
def create_raw_reports(project_list):
    project_data = OrderedDict()

    # Connects to JIRA
    generator = JiraGT()
    generator.connect()

    # Iterates through each project and queries for its data
    for proj in project_list:
        project_data[proj] = generator.get_roche_issue_data(
            proj, [
                'Defect', 'Defect Subtask', 'Change Request', 'CR Sub Task',
                'Task', 'Task Sub Task', 'New Development', 'Compliance',
                'Proposed Work', 'Action Item', 'Incident'
            ])

        # Save path for raw SEPTA data
        raw_save_path = create_dirpath(
            subdirs=[PROJECT_DIR, proj, RAW_DATA_DIR])

        # Sets header tuples for raw data sheet
        main_headers = [('Row Number', 3), (KEY, 12), (ISSUETYPE, 16),
                        (PRIORITY, 10), ('Current Status', 16), (CREATED, 17),
                        (RESOLVED, 17), (COMPS, 17), (LINKS, 25), (PACK, 12),
                        (FOUND, 17), (PBI, 20), (ROOT, 20), (DEV_EST, 14),
                        (DEV_ACT, 14)]
        history_headers = [(KEY, 12), (OLD, 16), (NEW, 16), (TRANS, 17)]

        # Writes data to raw data files
        raw_data = OrderedDict([(MAIN, []), (CHANGE, [])])
        for key, params in project_data[proj].iteritems():
            curr_params = [key]
            for k, v in params.iteritems():
                if (k != HIST): curr_params.append(v)
            raw_data[MAIN].append(curr_params)

            # Gets historical data if it exists
            if (HIST in params):
                for index, old in enumerate(params[HIST][OLD]):
                    raw_data[CHANGE].append([
                        key, old, params[HIST][NEW][index],
                        params[HIST][TRANS][index]
                    ])
        raw_writer = RawDataWriter(raw_data.keys(),
                                   [main_headers, history_headers],
                                   '%s Raw Data' % proj, raw_save_path)
        raw_writer.produce_workbook(raw_data)

        print "%s raw data produced" % proj

    # Disconnects from JIRA
    generator.disconnect()
Example #7
0
    def __init__(self, project_map):
        """
    Initializes the initial parameters for JIRA.
    
    @param project_map: Data dictionary mapping project groups to a list of tuples 
    containing associated project keys and names.
    """

        super(ClearQuestPPT, self).__init__(CQ_DIR)

        # Sets project group map
        self.project_map = project_map

        # Sets issue type list
        self.issue_types = OrderedDict([(DCR, [ENG_CHANGE, ENG_NOTICE]),
                                        (RR, [DEV, PROD]),
                                        (SCR, [DEFECT, ENHANCE])])

        # Sets file paths for directories containing project data
        dir_link = [STATE_OF_QUALITY_DIR, CQ_DIR]
        self.project_path = create_dirpath(subdirs=dir_link + [PROJECT_DIR])
        self.project_group_path = create_dirpath(subdirs=dir_link +
                                                 [GROUP_DIR])
 def __init__(self, filename='Export Data', save_path=create_dirpath(), series_names=[]):
   """
   Initializes the Excel file containing raw data, which will be saved at the 
   given path with the given file name.
   
   @param filename: Name of the file (without file extension).
   @param save_path: File path where Excel sheet will be saved at.
   @param series_names: List of tuples that will be used for the series on the
   charts. Each tuple contains the series name and a second string describing
   the series: (series name, series description).
   """
   
   super(ExportDataWriter, self).__init__(filename, save_path)
   self.data_type = 'Export'
   
   # Cell formats
   self.itemnameformat = self.wb.add_format({
     'bold':True, 'font_color':'black', 'font_size':10, 'font':'Arial', 'bg_color':'#BFBFBF'
   })
   self.itemrowformat = self.wb.add_format({
     'font_color':'black', 'font_size':10, 'font':'Arial', 'bg_color':'#BFBFBF'
   })
   self.weeknumformat = self.wb.add_format({
     'font_color':'black', 'font_size':10, 'font':'Arial', 'bg_color':'#E26B0A'
   })
   self.totalnameformat = self.wb.add_format({
     'bold':True, 'font_color':'black', 'font_size':10, 'font':'Arial', 'bg_color':'#92D050'
   })
   self.totalrowformat = self.wb.add_format({
     'font_color':'black', 'font_size':10, 'font':'Arial','bg_color':'#92D050'
   })
   self.dateformat = self.wb.add_format({
     'font_color':'black', 'font_size':10, 'font':'Arial', 'num_format':'m/d/yyyy', 
     'border':1, 'rotation':60
   })
   self.regformat = self.wb.add_format({
     'font_color':'black', 'font_size':11, 'font':'Arial'
   })
   
   # Initializes the series names
   self.series_names = series_names
   
   # Initializes dictionary of sheets
   self.sheets = OrderedDict()
   
   # Sets write rows
   self.date_row = 3
   self.week_row = 4
   self.top_write_row = 6
Example #9
0
 def __init__(self, filename='Data', savepath=create_dirpath()):
   """
   Initializes basic Excel parameters.
   
   @param filename: Name of the file (without file extension).
   @param savepath: File path where Excel sheet will be saved at.
   """
   
   # Initializes the workbook of the Excel file
   self.filepath = '%s\\%s %s.xlsx' % (savepath, filename, strftime("%Y-%m-%d"))
   self.wb = Workbook(self.filepath)
   
   # Data that will be written to the Excel file
   self.data = None
   
   # Type of workbook data being written
   self.data_type = '<undefined>'
Example #10
0
def export_metrics(calc, sev, status):
    """
  Takes the results of the calculated metrics and exports them to Excel
  workbooks.
  
  @param calc: Calculator responsible for determining the severity and status
  data.
  @param sev: Data dictionary containing the calculated severity data.
  @param status: Data dictionary containing the calculated status data.
  """

    # Save path for exported Compliance data
    save_path = create_dirpath(subdirs=[PROJECT_DIR, calc.project])

    # Moves all old Status and Severity files to the old folder
    move_old_files(['Severity', 'Status'],
                   [PROJECT_DIR, calc.project, PREV_DATA_DIR])
    # Performs severity and status exports
    projects = status[status.keys()[0]].keys()
    for data, series_names, sheet_names, filename in [
        (sev, [(p, p) for p in calc.priority_list], [TOTAL, OPEN, CLOSED],
         'Compliance by Severity'),
        (status, calc.get_status_desc(), projects, 'Compliance by Status')
    ]:
        # Sets sheet parameters
        sheet_data = {
            sheet: {
                'omit_last':
                False,
                'chart_params': [{
                    'chart_name': filename,
                    'issue_type': 'Compliance'
                }, {
                    'chart_name': filename,
                    'issue_type': 'Compliance',
                    'insertion_row': 39 + (2 * len(series_names)),
                    'weeks': 26
                }]
            }
            for sheet in sheet_names
        }

        # Performs export
        exporter = ExportDataWriter(filename, save_path, series_names)
        exporter.produce_workbook(data, sheet_data=sheet_data)
Example #11
0
def generate_raw_data(data):
    """
  Re-arranges the data pulled from the back end of the JIRA database and 
  generates raw data Excel workbooks containing it.
  
  @param data: Data pulled from the back end of the JIRA database. It has the
  following structure:
    <key> -> <data type> -> <data value>
          -> <HIST> -> <OLD, NEW, TRANS> -> <data value>
  """

    # Gets raw data path
    raw_save_path = create_dirpath(
        subdirs=[PROJECT_DIR, 'Compliance', RAW_DATA_DIR])

    # Sets header tuples for raw data sheet
    main_headers = [(KEY, 12), (PROJECT, 16), (ISSUETYPE, 16), (PRIORITY, 10),
                    ('Current Status', 16), (CREATED, 17), (RESOLVED, 17),
                    (COMPS, 17), (LINKS, 25), (PACK, 12), (DEV_EST, 14),
                    (DEV_ACT, 14)]
    history_headers = [(KEY, 12), (OLD, 16), (NEW, 16), (TRANS, 25)]

    # Configures data dictionary for writing to the Excel workbooks
    raw_data = OrderedDict([(MAIN, []), (CHANGE, [])])
    for key, params in data.iteritems():
        curr_params = [key]
        for k, v in params.iteritems():
            if (k != HIST): curr_params.append(v)
        raw_data[MAIN].append(curr_params)

        # Gets historical data if it exists
        if (HIST in params):
            for index, old in enumerate(params[HIST][OLD]):
                raw_data[CHANGE].append([
                    key, old, params[HIST][NEW][index],
                    params[HIST][TRANS][index]
                ])

    # Writes configured raw data to Excel workbook
    raw_writer = RawDataWriter(raw_data.keys(),
                               [main_headers, history_headers],
                               'Compliance Raw Data', raw_save_path)
    raw_writer.produce_workbook(raw_data)
Example #12
0
    def _produce_age_file(self,
                          data,
                          save_path_trail,
                          prefix='Average Issue',
                          chart_title='Average Aging (in days)',
                          side_header='Priority',
                          top_header='Status'):
        """
    Produces a single Excel file containing age data for all available issue
    types.
    
    @param data: Data being segmented for the age data file.
    @param save_path_trail: List of directories that form a trail to the save
    location, starting from the base Files folder (which does not need to be
    included in the list).
    @param prefix: Prefix to the given file name.
    @param chart_title: Title of the table within the sheets.
    @param side_header: Header for the side of the table.
    @param top_header: Header for the top of the table.
    @return: File path of the age data file produced.
    """

        # Save path for project
        save_path = create_dirpath(subdirs=save_path_trail)

        # Moves all old files of the given data type to the old folder
        move_old_files([AGE], save_path_trail + [PREV_AGE_DATA_DIR])

        # Sets file name (without data or file extension)
        file_name = '%s %s' % (prefix, AGE)

        # Saves age data
        writer = TableDataWriter(file_name,
                                 save_path,
                                 chart_title=chart_title,
                                 side_header=side_header,
                                 top_header=top_header)
        return writer.produce_workbook(data, write_func=float)
Example #13
0
    def _read_excel_project_map(self):
        """
    Reads the group to project mappings from the JIRA Projects Excel file.
    
    @return: Data dictionary mapping project group names to a list of tuples
    with project keys and associated full project names. It looks like:
      <project group> -> [(project key, full project name),]
    """

        # Initializes group map
        group_map = OrderedDict()

        # File path of JIRA projects file
        filepath = '%s\\JIRA Projects.xlsx' % create_dirpath(
            subdirs=[MATRICES_DIR])

        # Workbook for file
        wb = xlrd.open_workbook(filepath)

        # Sheet with project information
        sheet = wb.sheet_by_index(0)

        # Traverses through each row for projects.
        for row in range(sheet.nrows)[1:]:
            name = str(sheet.cell(row, 0).value).strip()
            pkey = str(sheet.cell(row, 1).value).strip()
            group = str(sheet.cell(row, 5).value).strip()
            active = str(sheet.cell(row, 6).value).strip()
            if (group not in ['', 'n/a'] and active not in ['no', 'n/a']):
                if (group not in group_map):
                    group_map[group] = []
                group_map[group].append((pkey, name))

        # Releases resources using the file to restore used memory
        wb.release_resources()

        return group_map
Example #14
0
    def _produce_chart_file(self,
                            project,
                            data,
                            issue_type,
                            data_type,
                            series_names,
                            prefix=''):
        """
    Produces a single metric Excel file containing chart data.
    
    @param project: Name of project that the file is associated with.
    @param data: Data to be inserted into the metric file.
    @param issue_type: Type of issue represented within metric file (Defect,
    Change Request, Task, etc).
    @param data_type: Type of data being produced by chart (Status, Severity, 
    etc).
    @param series_names: List of tuple containing series names paired with 
    their associated descriptions.
    @param prefix: Prefix to the given file name.
    @return: File path of the metric data file produced.
    """

        # Save path for project
        directories = self.base_dir_trail + [PROJECT_DIR, project]
        save_path = create_dirpath(subdirs=directories)

        # Moves all old files of the given data type to the old folder
        move_old_files([data_type], directories + [PREV_DATA_DIR])

        # Determines file name based on issue type and data type
        file_name = '%ss by %s' % (issue_type, data_type)
        if (prefix): file_name = '%s %s' % (prefix, file_name)

        # Determines sheet names and fill map based on data type
        fill_map = {}
        if (data_type == SEV):
            sheet_names = [TOTAL, OPEN, CLOSED]
            # Backwards because xlsxwriter series colors get reversed based on insertion
            colors = ['blue', 'green', 'yellow', 'orange', 'red']
            fill_map = {
                series: {
                    'color': color
                }
                for (series, _), color in zip(series_names, colors)
            }
        elif (data_type == STATUS):
            sheet_names = [TOTAL]
        else:
            sheet_names = []

        # Sets up sheet parameters
        sheet_data = OrderedDict([(sheet, {}) for sheet in sheet_names])
        for sheet in sheet_names:
            # Chart parameters
            chart1 = {
                'chart_name': file_name,
                'issue_type': issue_type,
                'fill_map': fill_map
            }
            chart2 = {
                'chart_name': file_name,
                'issue_type': issue_type,
                'fill_map': fill_map,
                'insertion_row': 39 + (2 * len(series_names)),
                'weeks': 26
            }

            # Sets chart parameters
            sheet_data[sheet]['chart_params'] = [chart1, chart2]

        # Performs exports
        exporter = ExportDataWriter(file_name, save_path, series_names)
        return exporter.produce_workbook(data, sheet_data=sheet_data)
Example #15
0
    def __init__(self,
                 filename,
                 save_path=create_dirpath(),
                 chart_title='<Title>',
                 side_header='<Row Header>',
                 top_header='<Column Header>'):
        """
    Initializes a workbook with the sheets from the given sheet list,
    as well as each of the items from the item list to be counted.
    
    @param filename: Name of the workbook to be saved.
    @param save_path: Location where the file will be saved.
    @param chart_title: The title of the charts within the tables.
    @param side_header: The name of the header for the side list.
    @param top_header: The name of the header for the top list.
    """

        # Initializes basic data
        super(TableDataWriter, self).__init__(filename, save_path)
        self.data_type = 'Table Data'

        # Sets the common chart title
        self.chart_title = chart_title

        # Sets the common header for the side of the tables
        self.sideheader = side_header

        # Sets the common header for the top of the tables
        self.topheader = top_header

        # Initializes the dictionary of sheets
        self.sheets = OrderedDict()

        # Initializes the various cell formats
        self.titleformat = self.wb.add_format({
            'font_color': 'white',
            'font_size': 20,
            'font': 'Arial',
            'bold': True,
            'border': True,
            'bg_color': '#E26B0A',
            'align': 'center'
        })
        self.toprightheaderformat = self.wb.add_format({
            'font_color': 'black',
            'font_size': 9,
            'font': 'Arial',
            'italic': True,
            'align': 'right',
            'top': True,
            'right': True,
            'bg_color': '#FCD5B4'
        })
        self.botleftheaderformat = self.wb.add_format({
            'font_color': 'black',
            'font_size': 9,
            'font': 'Arial',
            'italic': True,
            'align': 'left',
            'bottom': True,
            'left': True,
            'bg_color': '#FCD5B4'
        })
        self.topleftdiagformat = self.wb.add_format({
            'font': 'Arial',
            'top': True,
            'left': True,
            'diag_type': 2,
            'bg_color': '#FCD5B4'
        })
        self.botrightdiagformat = self.wb.add_format({
            'font': 'Arial',
            'bottom': True,
            'right': True,
            'diag_type': 2,
            'bg_color': '#FCD5B4'
        })
        self.topitemformat = self.wb.add_format({
            'font_color': 'black',
            'font_size': 11,
            'font': 'Arial',
            'bold': True,
            'border': True,
            'bg_color': '#FCD5B4',
            'align': 'center',
            'valign': 'top'
        })
        self.sideitemformat = self.wb.add_format({
            'font_color': 'black',
            'font_size': 11,
            'font': 'Arial',
            'bold': True,
            'border': True,
            'bg_color': '#FCD5B4',
            'align': 'left'
        })
        self.regformat = self.wb.add_format({
            'font_color': 'black',
            'font_size': 11,
            'font': 'Arial',
            'border': True
        })
        self.noteformat = self.wb.add_format({
            'font_color': 'black',
            'font_size': 10,
            'font': 'Arial'
        })
Example #16
0
MAIN = 'Main Data'
CHANGE = 'Change History'

# Constant for weekday when next date should be omitted
SUNDAY = 6

# Only runs script when it is being directly executed
if (__name__ == '__main__'):
    # Grabs SEPTA data
    generator = JiraGT()
    generator.connect()
    data = generator.get_issue_data('SEPTA')
    generator.disconnect()

    # Save path for raw SEPTA data
    raw_save_path = create_dirpath(
        subdirs=[PROJECT_DIR, 'SEPTA', RAW_DATA_DIR])

    # Sets header tuples for raw data sheet
    main_headers = [(KEY, 12), (ISSUETYPE, 16), (PRIORITY, 10),
                    ('Current Status', 16), (CREATED, 17), (RESOLVED, 17),
                    (COMPS, 17), (LINKS, 25), (PACK, 12), (FOUND, 17),
                    (ROOT, 20), (DEV_EST, 14), (DEV_ACT, 14)]
    history_headers = [(KEY, 12), (OLD, 16), (NEW, 16), (TRANS, 17)]

    # Writes data to raw data files
    raw_data = OrderedDict([(MAIN, []), (CHANGE, [])])
    for key, params in data.iteritems():
        curr_params = [key]
        for k, v in params.iteritems():
            if (k != HIST): curr_params.append(v)
        raw_data[MAIN].append(curr_params)