Ejemplo n.º 1
0
    def __init__(self, parser):
        '''
        Constructor
        '''
        self.parser = parser

        log.info(self.__class__.__name__ + " initialized")

        try:
            k = parser.options.key

            jira = jira_authenticate(parser.options.jiraURL, parser.options.jiraUsername, parser.options.jiraPassword)

            # Get an issue.
            issue = jira.issue(k)

            # Get its valid transitions
            transitions = jira.transitions(issue)

            log.info("Issue Key       : " + k)
            log.info("Current Status  : " + str(issue.fields.status))

            if str(issue.fields.status) in 'Resolved' and get_string_from_list(transitions, 'name', 'Deploy'):
                jira.transition_issue(issue, u'Deploy')
                log.info("New Status      : " + 'Ready To Test')

            elif str(issue.fields.status) in 'Resolved' and get_string_from_list(transitions, 'name', 'Deploy Issue'):
                jira.transition_issue(issue, u'Deploy Issue')
                log.info("New Status      : " + 'Ready To Test')

            elif str(issue.fields.status) in 'Ready for Release':
                jira.transition_issue(issue, u'Deploy on UAT')
                log.info("New Status      : " + 'Deploy on UAT')

            else:
                log.debug("Ticket can only do the following transitions:")
                for t in transitions:
                    log.debug(t['name'])
                log.warn("Exiting without transition")

        except:
            raise
Ejemplo n.º 2
0
    def __init__(self, parser):
        '''
        Constructor
        '''
        self.parser = parser

        log.info(self.__class__.__name__ + " initialized")

        try:
            k = parser.options.key
            s = parser.options.status

            jira = jira_authenticate(parser.options.jiraURL, parser.options.jiraUsername, parser.options.jiraPassword)

            # Get an issue.
            issue = jira.issue(k)

            # Get its valid transitions
            transitions = jira.transitions(issue)

            log.info("Issue Key       : " + k)
            log.info("Current Status  : " + str(issue.fields.status))
            log.info("Requested Status: " + str(s))

            if get_string_from_list(transitions, 'name', s):
                jira.transition_issue(issue, s)
                log.info("New Status      : " + s)

            else:
                log.debug("Ticket can only do the following transitions:")
                for t in transitions:
                    log.debug(t['name'])
                log.warn("Exiting without transition")

        except:
            raise
Ejemplo n.º 3
0
            execute_shell_command(
                "sudo ampy --port /dev/ttyUSB0 put {} {}".format(
                    "{}/profile/{}/{}".format(parser.options.path,
                                              parser.options.profile,
                                              "main.py"), "main.py"))
            execute_shell_command(
                "sudo ampy --port /dev/ttyUSB0 put {} {}".format(
                    "{}/profile/{}/conf/{}".format(parser.options.path,
                                                   parser.options.profile,
                                                   "profile.properties"),
                    "conf/profile.properties"))

        # Write installation timestamp
        with open(timestamp_file, "w") as text_file:
            text_file.write("{}\n".format(time.time()))

elif parser.options.install and not modified_relative_files:
    log.warn(
        "No modified files detected since last execution on {}. Installation skipped."
        .format(timestamp_to_human_readable(timestamp)))

log.info("Execution time '{} sec'".format(time.time() - start_time))

if parser.options.connect:
    # CONNECT
    log.info("Connecting to '{}' ....".format(parser.options.device))
    execute_shell_command("sudo picocom --baud 115200 /dev/ttyUSB0")

# Salute!
log.info("Bye bye! :-)")
Ejemplo n.º 4
0
    def __init__(self, parser):
        '''
        Constructor
        '''
        self.parser = parser

        log.info(self.__class__.__name__ + " initialized")

        try:
            # Input File
            self.input_file = parser.options.input_file

            # Estimate To Complete
            self.estimate_to_complete = parser.options.estimate_to_complete


            # Time spent
            _effort_actual_md = 0.0

            # Check if input file exists
            if check_file_exists(self.input_file) == 1:
                die("File '" + self.input_file + "' doesn't exist. Fatal.")
            self.euro_sign_encoded = u" \u20AC"
            self.euro = " eur"
            self.project_name = read_property_from_file("project_name", "project", self.input_file)
            self.baseline_md = read_property_from_file("baseline_md", "project", self.input_file)
            self.date_format = read_property_from_file("date_format", "project", self.input_file)

            # Datelimit
            self.date_limit = None
            if parser.options.date_limit is not None:
                self.date_limit = datetime.strptime(parser.options.date_limit, self.date_format) + timedelta(hours=23,
                                                                                                             minutes=59,
                                                                                                             seconds=59)

            # Project related values
            self.kick_off_date = datetime.strptime(
                read_property_from_file("kick_off_date", "project", self.input_file), self.date_format).date()
            self.uat_start_baseline = datetime.strptime(
                read_property_from_file("uat_start_baseline", "project", self.input_file), self.date_format).date()
            self.uat_start_actual = datetime.strptime(
                read_property_from_file("uat_start_actual", "project", self.input_file), self.date_format).date()
            self.go_live_baseline = datetime.strptime(
                read_property_from_file("go_live_baseline", "project", self.input_file), self.date_format).date()
            self.go_live_actual = datetime.strptime(
                read_property_from_file("go_live_actual", "project", self.input_file), self.date_format).date()
            self.issue_jql = list(ast.literal_eval(read_property_from_file("issue_jql", "project", self.input_file)))
            self.output_path = read_property_from_file("output_path", "project", self.input_file)
            self.output_filename = read_property_from_file("output_filename", "project", self.input_file)

            # Add the date limit in the filename
            if self.date_limit is not None:
                self.output_location_datelimit = str(self.output_path
                                                     + "latest_DL"
                                                     + self.date_limit.strftime("%Y%m%d")
                                                     + "_"
                                                     + self.output_filename)
            else:
                # Add "latest" in the filename
                self.output_location_latest = str(self.output_path
                                                  + "latest_"
                                                  + self.output_filename)

            self.revenue_offer = read_property_from_file("revenue_offer", "project", self.input_file)
            self.md_rate_offer = read_property_from_file("md_rate_offer", "project", self.input_file)
            self.md_rate_internal = read_property_from_file("md_rate_internal", "project", self.input_file)
            self.other_costs_baseline = read_property_from_file("other_costs_baseline", "project", self.input_file)
            self.other_costs_actual = read_property_from_file("other_costs_actual", "project", self.input_file)

            jira = jira_authenticate(parser.options.jiraURL, parser.options.jiraUsername, parser.options.jiraPassword)

            log.info("--------------------------------------------------------")
            log.info("| " + self.project_name)
            log.info("--------------------------------------------------------")

            log.info("Kick-off                      : " + str(self.kick_off_date))
            log.info("UAT Start (Baseline)          : " + str(self.uat_start_baseline))
            log.info("UAT Start (Actual)            : " + str(self.uat_start_actual))
            log.info("GoLive (Baseline)             : " + str(self.go_live_baseline))
            log.info("GoLive (Actual)               : " + str(self.go_live_actual))
            log.info("Effort (Baseline)             : " + str(self.baseline_md) + " md")
            #############################################
            # TIME SPENT
            #############################################
            _effort_spent_in_future_sec = 0.0
            # Iterate JQL Filters
            for f in self.issue_jql:
                log.debug("Processing JQL: " + f)
                r = jira.search_issues(f, 0, False)
                # Iterate Issues in each JQL
                for k in r:
                    # Get each issue from filter
                    issue = jira.issue(k)
                    # log.debug("Working on issue: " + issue.key)

                    # Iterate Workogs in each Issue
                    for worklog in jira.worklogs(issue.key):
                        # log.debug(issue.key + ": " + str(worklog.id))
                        # pprint (vars(worklog))

                        # Get datetime that the worklog is about
                        _started = datetime.strptime(worklog.started[:10], "%Y-%m-%d")


                        # Check entries against date limit from the command line
                        if self.date_limit is not None and _started <= self.date_limit:
                            log.debug(
                                "Issue [" + str(issue.key) + "] Worklog [" + str(worklog.id) + "] with date " + str(
                                    _started) + " will be counted because date limit is " + str(self.date_limit))
                            _effort_actual_md = _effort_actual_md + worklog.timeSpentSeconds
                        elif self.date_limit is not None and _started > self.date_limit:
                            log.warn(
                                "Issue [" + str(issue.key) + "] Worklog [" + str(worklog.id) + "] with date " + str(
                                    _started) + " will be added to EFFORT REMAINING because date limit is " + str(
                                    self.date_limit))
                            _effort_spent_in_future_sec = _effort_spent_in_future_sec + worklog.timeSpentSeconds
                        elif self.date_limit is None:
                            log.debug(
                                "Issue [" + str(issue.key) + "] Worklog [" + str(worklog.id) + "] with date " + str(
                                    _started) + " will be counted because date limit hasn't been provided")
                            _effort_actual_md = _effort_actual_md + worklog.timeSpentSeconds

                    # Get issue's timespent in seconds and add it to the overall sum
                            # if issue.fields.timespent is not None:
                            #     _effort_actual_md = _effort_actual_md + issue.fields.timespent

                log.debug("Time spent so far is     : " + str(("%.2f" % ((_effort_actual_md / 3600) / 8))))

            # Switch timespent to md and round it off to 2 digits
            _effort_actual_md = "%.2f" % ((_effort_actual_md / 3600) / 8)

            log.info("Effort (Actual)               : " + str(_effort_actual_md) + " md")

            #############################################
            # ESTIMATE TO COMPLETE
            #############################################


            _effort_remaining_md = 0.0  #
            if float(_effort_actual_md) > float(self.baseline_md) and self.estimate_to_complete is None:
                die("Time spent " + str(
                    _effort_actual_md) + " md is higher than the baseline " + self.baseline_md + " md so an estimate to complete calculation cannot take place, please use -e switch to provide a manual E.t.C.")
            elif self.estimate_to_complete is None:
                _effort_remaining_md = _effort_remaining_md + (float(self.baseline_md) - float(_effort_actual_md))
            else:
                _effort_remaining_md = ((_effort_spent_in_future_sec / 3600) / 8) + float(self.estimate_to_complete)

            log.info("Effort (Remaining)            : " + str("%.2f" % _effort_remaining_md) + " md")

            if _effort_spent_in_future_sec > 0.0:
                log.warn("(Effort remaining contains time spent in the future: " + "%.2f" % (
                (_effort_spent_in_future_sec / 3600) / 8) + " md)")

            #############################################
            # EFFORT AT COMPLETION
            #############################################

            # Calculate Estimate At Completion
            _effort_at_completion_md = float(_effort_actual_md) + float(_effort_remaining_md)

            log.info("Effort (At Completion)        : " + str(_effort_at_completion_md) + " md")

            #############################################
            # ON TIME
            #############################################
            _a = self.go_live_actual - self.kick_off_date
            _b = self.go_live_baseline - self.kick_off_date

            # On Time
            _on_time = (_a.total_seconds() / _b.total_seconds())



            #############################################
            # IN EFFORT
            #############################################

            # In Effort
            _in_effort = _effort_at_completion_md / float(self.baseline_md)




            #############################################
            # BUDGET
            #############################################
            log.info("Revenue                       : " + str(self.revenue_offer) + self.euro_sign_encoded)
            log.info("md Rate (Offer)               : " + str(self.md_rate_offer) + self.euro_sign_encoded)
            log.info("md Rate (Internal)            : " + str(self.md_rate_internal) + self.euro_sign_encoded)

            _md_cost_baseline = float(self.md_rate_internal) * float(self.baseline_md)
            log.info("md Cost (Baseline)            : " + str(_md_cost_baseline) + self.euro_sign_encoded)

            _md_cost_eac = float(self.md_rate_internal) * float(_effort_at_completion_md)
            log.info("md Cost (At Completion)       : " + str(_md_cost_eac) + self.euro_sign_encoded)
            log.info("Other Costs (Baseline)        : " + str(self.other_costs_baseline) + self.euro_sign_encoded)
            log.info("Other Costs (Actual)          : " + str(self.other_costs_actual) + self.euro_sign_encoded)

            _pnl_baseline = ((float(self.revenue_offer) - float(_md_cost_baseline) - float(
                self.other_costs_baseline)) / float(self.revenue_offer)) * 100
            log.info("PnL (Baseline)                : " + str("%.2f" % _pnl_baseline) + "%")

            _pnl_eac = ((float(self.revenue_offer) - float(_md_cost_eac) - float(self.other_costs_actual)) / float(
                self.revenue_offer)) * 100
            log.info("PnL (At Completion)           : " + str("%.2f" % _pnl_eac) + "%")



            #############################################
            # IN BUDGET
            #############################################
            _in_budget = 1 + (float(_pnl_baseline / 100) - float(_pnl_eac / 100))

            log.info("--------------------------------------------------------")
            log.info("On Time                       : " + str("%.2f" % _on_time))
            log.info("In Effort                     : " + str("%.2f" % _in_effort))
            log.info("In Budget                     : " + str("%.2f" % _in_budget))
            log.info("--------------------------------------------------------")


            html_code = self.export_to_html(self.project_name,
                                            self.kick_off_date.strftime(self.date_format),
                                            self.uat_start_baseline.strftime(self.date_format),
                                            self.uat_start_actual.strftime(self.date_format),
                                            self.go_live_baseline.strftime(self.date_format),
                                            self.go_live_actual.strftime(self.date_format),
                                            "%.2f" % _on_time,
                                            self.baseline_md,
                                            _effort_actual_md,
                                            _effort_remaining_md,
                                            _effort_at_completion_md,
                                            "%.2f" % _in_effort,
                                            str(self.revenue_offer) + self.euro,
                                            str(self.md_rate_offer) + self.euro,
                                            str(self.md_rate_internal) + self.euro,
                                            str(_md_cost_baseline) + self.euro,
                                            str(_md_cost_eac) + self.euro,
                                            str(self.other_costs_baseline) + self.euro,
                                            str(self.other_costs_actual) + self.euro,
                                            str("%.2f" % _pnl_baseline) + "%",
                                            str("%.2f" % _pnl_eac) + "%",
                                            str("%.2f" % _in_budget),
                                            str(" ".join(sys.argv)))


            # Output in either location
            if self.date_limit is not None:
                with open(self.output_location_datelimit, "w") as text_file:
                    text_file.write(html_code)
                    log.debug("Output added to " + self.output_location_datelimit)
            else:
                with open(self.output_location_latest, "w") as text_file:
                    text_file.write(html_code)
                    log.debug("Output added to " + self.output_location_latest)


        except:
            raise