コード例 #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
コード例 #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
コード例 #3
0
ファイル: onomix.py プロジェクト: idimitrakopoulos/onomix
 def run_name(dn):
     try:
         whois.query(dn)
         log.debug("[TAKEN] " + dn)
     except Exception:
         log.info("[FREE] " + dn)
コード例 #4
0
ファイル: onomix.py プロジェクト: idimitrakopoulos/onomix
            whois.query(dn)
            log.debug("[TAKEN] " + dn)
        except Exception:
            log.info("[FREE] " + dn)


    log.info("Permutations are " + str(calculate_permutations(ascii_lowercase, int(parser.options.length))))

    # Setup pool
    p = Pool(int(parser.options.workers))

    for e in PermutationIterator(ascii_lowercase, int(parser.options.length)):
        domain_name = str("".join(e) + parser.options.tld)
        result = None

        log.debug("Trying: " + domain_name)

        try:
            # Give it to an available worker
            p.apply(run_name, args=(domain_name,))

        except KeyboardInterrupt:
            p.terminate()


    # End the busy indicator
    stop_busy_indicator(bi)

    # Salute!
    log.info("Bye bye! :-)")
コード例 #5
0
if parser.options.path == os.getcwd() and (parser.options.install
                                           or parser.options.skip
                                           or parser.options.profile):
    die("You tried to run espedite from within its own folder. Please cd to your code folder instead and run it from there."
        )

# Remove any compiled files
remove_files_by_ext_recursively(parser.options.path,
                                properties.binaryCodeExtension)

# Read timestamp
if check_file_exists(timestamp_file):
    with open(timestamp_file, 'r') as f:
        timestamp = f.readline().strip()
        log.debug("Last execution was on {} (UNIX Timestamp: {}) ".format(
            timestamp_to_human_readable(timestamp), str(timestamp)))

log.info("Running script in path '{}'".format(parser.options.path))

check_executable_exists("ampy", True)
if parser.options.connect:
    check_executable_exists("picocom", True)

modified_relative_files = get_modified_files(parser.options.path, timestamp,
                                             True)

if parser.options.skip:
    # READ SKIPFILE
    log.info("Reading skip file '{}' ....".format(parser.options.skip))
    skip_files = read_file_to_list(parser.options.path +
                                   properties.osDirSeparator +
コード例 #6
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
コード例 #7
0
ファイル: pyji.py プロジェクト: idimitrakopoulos/PyJi
#! /usr/bin/env python
import sys

import util.opt_parser as parser
from util.toolkit import log, generate_guid, ab_path_to_class, ab_subclass_path_from_action, start_busy_indicator, \
    stop_busy_indicator

bi = None

try:

    # Begin the Busy indicator
    bi = start_busy_indicator("")

    # Print execution command
    log.debug("Executed command '" + " ".join(sys.argv) + "'")

    # Generate a unique execution id
    guid = generate_guid()
    log.info("Unique PyJi execution ID generated: '" + guid + "'")

    # Instantiate specified ActionBundle class (from string)
    ab = ab_path_to_class(ab_subclass_path_from_action(parser.action), parser)

except (Exception, KeyboardInterrupt):
    # Show error
    log.error(str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
    raise

finally:
    # End the busy indicator