Example #1
0
    def issuesAssignedTo(self, user_email):
        """Gets all the issues for a given project"""
        issues = []

        # Set per_page to 25 issues per page
        first_page = self.api_issues_url + '?per_page=25&page=1'

        # Get page one
        json_raw = self._account.request(first_page)

        # Set the next page
        next_page = json_raw['next_page_url']

        # Set the number of pages
        number_of_pages = json_raw['total_pages']

        for current_page in range(number_of_pages):
            # Create a wrapper for each issue, add it to the list
            raw_issues = json_raw['issues']
            for raw_issue in raw_issues:
                i = issue.Issue(raw_issue, self._account)
                if (i.assignee_email == user_email) and (i.status != 'Closed'):
                    issues.append(i)

            # Make a request for the next page
            if current_page < number_of_pages - 1:
                # store the results
                json_raw = self._account.request(next_page)

            # set the next page
            next_page = json_raw['next_page_url']

        return issues
Example #2
0
    def __init__(self, instruction, opcodes, opcodeStr, dataval, address, arg1,
                 arg2, arg3, arg1Str, arg2Str, arg3Str, numInstructions,
                 destReg, src1Reg, src2Reg):
        self.instruction = instruction
        self.opcode = opcodes
        self.dataval = dataval
        self.address = address
        self.numInstructions = numInstructions
        self.arg1 = arg1
        self.arg2 = arg2
        self.arg3 = arg3
        self.arg1Str = arg1Str
        self.arg2Str = arg2Str
        self.arg3Str = arg3Str
        self.destReg = destReg
        self.src1Reg = src1Reg
        self.src2Reg = src2Reg
        self.opcodeStr = opcodeStr
        self.PC = 96
        self.cycle = 1
        self.R = [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        ]
        self.postMemBuff = [-1,
                            -1]  # first number is value, second is instr index
        self.postALUBuff = [-1,
                            -1]  # first number is value, second is instr index
        self.preMemBuff = [-1, -1]
        self.preALUBuff = [-1, -1]
        self.preIssueBuff = [-1, -1, -1, -1]

        #uncomment these lines as the classes are developed :)

        self.WB = writeBack.WriteBack(self.R, self.postMemBuff,
                                      self.postALUBuff, destReg)
        self.ALU = alu.ALU(self.R, self.postALUBuff, self.preALUBuff,
                           opcodeStr, arg1, arg2, arg3)
        self.MEM = mem.MEM(self.R, self.postMemBuff, self.preMemBuff,
                           opcodeStr, arg1, arg2, arg3, dataval, address,
                           self.numInstructions)
        self.cache = cache.Cache(self.numInstructions, self.instruction,
                                 self.dataval, self.address)
        self.issue = issue.Issue(instruction, opcodes, opcodeStr, dataval,
                                 address, arg1, arg2, arg3,
                                 self.numInstructions, destReg, src1Reg,
                                 src2Reg, self.preIssueBuff, self.preALUBuff,
                                 self.preMemBuff, self.postALUBuff,
                                 self.postMemBuff)
        self.fetch = fetch.Fetch(instruction, opcodeStr, dataval, address,
                                 arg1, arg2, arg3, self.numInstructions,
                                 destReg, src1Reg, src2Reg, self.preALUBuff,
                                 self.postALUBuff, self.PC, cache,
                                 self.preIssueBuff)

        self.outputFileName = SetUp.get_output_filename()
 def __init__(self, instructions, opcode, opcodeStr, dataval, address, arg1,
              arg2, arg3, arg1Str, arg2Str, arg3Str, numInstructions,
              destReg, src1Reg, src2Reg):
     self.instructions = instructions
     self.opcode = opcode
     self.opcodeStr = opcodeStr
     self.dataval = dataval
     self.address = address
     self.arg1 = arg1
     self.arg2 = arg2
     self.arg3 = arg3
     self.arg1Str = arg1Str
     self.arg2Str = arg2Str
     self.arg3Str = arg3Str
     self.numInstructions = numInstructions
     self.destReg = destReg
     self.src1Reg = src1Reg
     self.src2Reg = src2Reg
     self.PC = 96
     self.cycle = 1
     ### LISTS ###
     self.cycleList = [0]
     self.R = [
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0
     ]
     self.postMemBuff = [-1,
                         -1]  # first number is value, second is instr index
     self.postALUBuff = [-1, -1]
     self.preMemBuff = [-1, -1]
     self.preALUBuff = [-1, -1]
     self.preIssueBuff = [-1, -1, -1, -1]
     ### OBJECTS ###
     self.WB = writeBack.WriteBack(self.R, self.postMemBuff,
                                   self.postALUBuff, destReg)
     self.cache = cache.Cache(numInstructions, instructions, dataval,
                              address)
     self.ALU = alu.ALU(self.R, self.postALUBuff, self.preALUBuff,
                        opcodeStr, arg1, arg2, arg3)
     self.MEM = memory.Memory(self.R, self.postMemBuff, self.preMemBuff,
                              opcodeStr, arg1, arg2, arg3, dataval,
                              self.numInstructions, self.cache,
                              self.cycleList)
     self.issue = issue.Issue(instructions, opcodeStr, dataval, address,
                              arg1, arg2, arg3, self.numInstructions,
                              destReg, src1Reg, src2Reg, self.R,
                              self.preIssueBuff, self.preMemBuff,
                              self.postMemBuff, self.preALUBuff,
                              self.postALUBuff)
     self.fetch = fetch.Fetch(instructions, opcodeStr, dataval, address,
                              arg1, arg2, arg3, self.numInstructions,
                              destReg, src1Reg, src2Reg, self.R,
                              self.preIssueBuff, self.preMemBuff,
                              self.postMemBuff, self.preALUBuff,
                              self.postALUBuff, self.PC, self.cache)
     self.outputFileName = Setup.get_output_filename()
Example #4
0
    def __read_issue_from_server(self, issue_key: str):

        # ---Ensure that we don't have this issue yet-----

        if issue_key in self.__issue_cache:
            return

        # ---Read issue from Jira-----

        url = self.__url + self.__JIRA_REST_API_PREFIX + issue_key + "&" + self.__JIRA_REST_API_SUFFIX
        resp = requests.get(url, auth=(self.__username, self.__password))

        # ---Add issue to cache-----

        json = resp.json()
        json_issue_list = json["issues"]
        json_issue = json_issue_list[0]

        new_issue = issue.Issue()
        new_issue.key = json_issue["key"]
        new_issue.summary = json_issue["fields"]["summary"]
        self.__issue_cache[issue_key] = new_issue
Example #5
0

def print_solution_if_file(file_name, solution, machines_number, details_niumber):
    with open(file_name + '.sol', 'w') as out_file:
        cluster_id = 0
        machine_result_dict = dict()
        details_result_dict = dict()
        for cluster in solution.clusters:
            cluster_id += 1
            for machine in cluster.machines:
                machine_result_dict[machine] = cluster_id
            for detail in cluster.details:
                details_result_dict[detail] = cluster_id
        for i in range(1, machines_number + 1):
            out_file.write(str('m') + str(i) + '_' + str(machine_result_dict[i]) + ' ')
        out_file.write('\n')
        for i in range(1, details_number + 1):
            out_file.write(str('p') + str(i) + '_' + str(details_result_dict[i]) + ' ')


if __name__ == '__main__':
    file_name = '24x40'
    _issue = issue.Issue(file_name + '.txt')
    data_dict = _issue.data_dict
    machines_number = _issue.machines_number
    details_number = _issue.details_number
    solver = general_vns.GeneralVNS(_issue.data_matrix, _issue.machines_number, _issue.details_number)
    solution = solver.solution
    print_solution_if_file(file_name, solution, machines_number, details_number)

Example #6
0
def report_issue(check, name):
    return issue.Issue(
        severity=check.get('level', 'MEDIUM'), confidence='HIGH',
        text=check['message'].replace('{name}', name),
        ident=name, test_id=check.get("id", 'LEGACY'))
Example #7
0
#! /usr/local/bin/python3
# Online Python - IDE, Editor, Compiler, Interpreter
# https://www.online-python.com

from datetime import *
import issue

# relative dates for report
today = date.today()
thirty_last = today - timedelta(30)
thirty_next = today + timedelta(30)

# sample issues to test against
issues = []
issues = issues + [ issue.Issue(title="issue1", closed=(today-timedelta(10)), labels=[ 'Overdue' ] ) ]
issues = issues + [ issue.Issue(title="issue2", closed=(today+timedelta(10)), labels=[] ) ]
issues = issues + [ issue.Issue(title="issue3", closed=(today+timedelta(3)) , labels=[] ) ]
issues = issues + [ issue.Issue(title="issue4", closed=(today-timedelta(7)) , labels=[] ) ]

# build report collections
last = []       # closed last 30 days
next = []       # due in next 30 days
late = []       # issues that are overdue
for issue in issues:
    if issue.closed > thirty_last and issue.closed < today:
        last.append(issue)
    if issue.closed > today and issue.closed < thirty_next:
        next.append(issue)
    if 'Overdue' in issue.labels:
        late.append(issue)
Example #8
0
    def issue_editor(self, stdscr, current_book=None, current_pages=None):
        """ current_pages is a list of pages or None if the issue editor has not been opened from a specific page"""
        left_margin = 1
        right_margin = 1
        top_margin = 2
        bottom_margin = 2
        date_width = 11
        size = stdscr.getmaxyx()
        stdscr.keypad(True)
        stdscr.clear()
        curses.noecho()

        if current_book is not None and current_book.pages[
                current_pages[0]] >= 0:
            current_issue_id = current_book.pages[current_pages[0]]
            current_issue = self.environment.issues[current_issue_id]
        else:
            current_issue = issue.Issue()
            current_issue_id = len(self.environment.issues)

        current_text = ""
        current_cursor_position = 0

        c = 0

        while True:
            stdscr.erase()

            current_row = top_margin

            stdscr.addstr(
                0, 0, 'Issue #{issue} ({char})'.format(issue=current_issue_id,
                                                       char=c), curses.A_BOLD)

            if current_book is not None:
                if len(current_pages) == 1:
                    pagestring = '(@{book_id}:{current_page})'.format(
                        book_id=current_book.identifier,
                        current_page=current_pages[0] + 1)
                else:
                    pagestring = '(@{book_id}:{current_page_start}-{current_page_end})'\
                        .format(book_id=current_book.identifier,
                                current_page_start=current_pages[0]+1,
                                current_page_end=current_pages[-1]+1)
                stdscr.addnstr(
                    size[0] - 1, 0,
                    '(🠉🠋🠈🠊) Scroll/Move Cursor  (F1 F2) Select Issue'
                    '  (^L) Close and Exit  (^D) Save and Exit  (^X) Discard and Exit'
                    .ljust(size[1] - 1 - len(pagestring)) + pagestring,
                    size[1] - 1,
                    curses.color_pair(4) | curses.A_BOLD)

            # add all the previous comments if there are any for the selected issue
            for comment in current_issue.comments:
                # the creation date
                stdscr.addstr(
                    current_row, left_margin,
                    utc_to_local(comment.created).strftime("%Y-%m-%d"))
                stdscr.addstr(current_row + 1, left_margin,
                              utc_to_local(comment.created).strftime("%H:%M"))
                # the actual comment
                row = current_row
                col = left_margin + date_width
                for index, c in enumerate(comment.text):
                    stdscr.addstr(row, col, c)

                    current_row = row + 2

                    col = col + 1
                    if col >= size[1] - right_margin - 1:
                        col = left_margin + date_width
                        row = row + 1

            if current_issue.is_closed():
                curses.curs_set(False)
                stdscr.addstr(
                    current_row, left_margin,
                    utc_to_local(current_issue.closed).strftime("%Y-%m-%d"))
                stdscr.addstr(
                    current_row + 1, left_margin,
                    utc_to_local(current_issue.closed).strftime("%H:%M"))
                stdscr.addstr(current_row, left_margin + date_width,
                              "Issue closed.")
            else:
                curses.curs_set(True)
                # add the current comment element
                # first the date and time
                utcnow = datetime.datetime.utcnow()
                stdscr.addstr(current_row, left_margin,
                              utc_to_local(utcnow).strftime("%Y-%m-%d"))
                stdscr.addstr(current_row + 1, left_margin,
                              utc_to_local(utcnow).strftime("%H:%M"))
                # second the current text
                row = current_row
                col = left_margin + date_width
                cursor_row = 0
                cursor_col = 0
                for index, c in enumerate(current_text):
                    stdscr.addstr(row, col, c)

                    if index == current_cursor_position:
                        cursor_row = row
                        cursor_col = col

                    col = col + 1
                    if col >= size[1] - right_margin - 1:
                        col = left_margin + date_width
                        row = row + 1
                # set the right cursor position
                if current_cursor_position < len(current_text):
                    stdscr.move(cursor_row, cursor_col)
                else:
                    stdscr.move(row, col)

            c = stdscr.getch()
            if c == Interface.KEY_RESIZE:
                size = stdscr.getmaxyx()
            elif c == Interface.KEY_BACKSPACE:
                if current_cursor_position > 0:
                    current_text = current_text[:current_cursor_position -
                                                1] + current_text[
                                                    current_cursor_position:]
                    current_cursor_position = current_cursor_position - 1
            elif c == Interface.KEY_UP:
                pass
            elif c == Interface.KEY_DOWN:
                pass
            elif c == Interface.KEY_LEFT:
                current_cursor_position = current_cursor_position - 1
                if current_cursor_position < 0:
                    current_cursor_position = 0
            elif c == Interface.KEY_RIGHT:
                current_cursor_position = current_cursor_position + 1
                if current_cursor_position > len(current_text):
                    current_cursor_position = len(current_text)
            elif c == Interface.KEY_CTRL_X:
                stdscr.clear()
                return None
            elif c == Interface.KEY_CTRL_D:
                if len(current_text) > 10:
                    current_issue.add_comment(current_text)
                    if current_issue_id == len(self.environment.issues):
                        self.environment.issues.append(current_issue)
                    if current_book is not None:
                        for current_page in current_pages:
                            current_book.pages[current_page] = current_issue_id
                    self.save()
                    stdscr.clear()
                    return current_issue
            elif c == Interface.KEY_F2:
                current_issue_id = current_issue_id - 1
                if current_issue_id < 0:
                    current_issue_id = 0
                if current_issue_id >= len(self.environment.issues):
                    current_issue_id = len(self.environment.issues)
                    current_issue = issue.Issue()
                else:
                    current_issue = self.environment.issues[current_issue_id]
            elif c == Interface.KEY_F3:
                current_issue_id = current_issue_id + 1
                if current_issue_id >= len(self.environment.issues):
                    current_issue_id = len(self.environment.issues)
                    current_issue = issue.Issue()
                else:
                    current_issue = self.environment.issues[current_issue_id]
            elif c == Interface.KEY_ENTER:
                pass
            elif c == Interface.KEY_CTRL_L:
                if current_issue_id != len(self.environment.issues):
                    current_issue.closed = utcnow
                    for b in self.environment.books:
                        for i, p in enumerate(b.pages):
                            if p == current_issue_id:
                                b.pages[i] = book.Book.READ
                    self.save()
                    stdscr.clear()
                    return None

            else:
                current_text = current_text[:current_cursor_position] + chr(
                    c) + current_text[current_cursor_position:]
                current_cursor_position = current_cursor_position + 1