Ejemplo n.º 1
0
def readIssues(nrIssues, projectID):
    global nrNodes
    #bugID/\version/\creation_ts/\delta_ts/\status/\resolution
    issueFile = open("Data\\BugDetails.txt")
    while True:
        crtL = issueFile.readline()
        if not crtL:
            break
        lst = crtL.split('/Data\\')
        a = lst[2].split(' ', 1)
        a[1] = a[1].replace(' ', '')
        if len(a) != 2:
            exit()
        lst[2] = getTime(a[0], a[1])
        a = lst[3].split(' ', 1)
        a[1] = a[1].replace(' ', '')
        lst[3] = getTime(a[0], a[1])
        if len(a) != 2:
            exit()
        if len(lst) != 6:
            print('Error\n')
            exit()
        lst[5] = lst[5][:-1] #ignore '\n'
        issue = Issue(lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], project[projectID])

        if issue.getType() == issueType:
            if not (issue.name in issueDict):
                nrIssues = addIssue(issue, nrIssues, projectID)
                issue.setIndex(nrIssues)
                i_R[nrNodes] = {}


    issueFile.close()
    nrIssues = readIssueEdges(nrIssues)
    return nrIssues
Ejemplo n.º 2
0
 def create_issue(self,
                  title,
                  body=GithubObject.NotSet,
                  assignee=GithubObject.NotSet,
                  milestone=GithubObject.NotSet,
                  labels=GithubObject.NotSet):
     assert isinstance(title, (str, unicode)), title
     assert body is GithubObject.NotSet or isinstance(body,
                                                      (str, unicode)), body
     assert assignee is GithubObject.NotSet or isinstance(
         assignee, NamedUser.NamedUser), assignee
     assert milestone is GithubObject.NotSet or isinstance(
         milestone, Milestone.Milestone), milestone
     assert labels is GithubObject.NotSet or all(
         isinstance(element, Label.Label) for element in labels), labels
     post_parameters = {
         "title": title,
     }
     if body is not GithubObject.NotSet:
         post_parameters["body"] = body
     if assignee is not GithubObject.NotSet:
         post_parameters["assignee"] = assignee._identity
     if milestone is not GithubObject.NotSet:
         post_parameters["milestone"] = milestone._identity
     if labels is not GithubObject.NotSet:
         post_parameters["labels"] = [element.name for element in labels]
     headers, data = self._requester.requestAndCheck(
         "POST", self.url + "/issues", None, post_parameters)
     return Issue.Issue(self._requester, data, completed=True)
Ejemplo n.º 3
0
    def readIssues(self):
        # Each line of file contains issue data in format:
        # bugID/\version/\creation_ts/\delta_ts/\status/\resolution.
        issueFile = open("Data\\BugDetails.txt")
        while True:
            crtLine = issueFile.readline()
            if not crtLine:
                break
            lst = crtLine.split('/\\')
            assert (len(lst) == 6)
            dateTime = lst[2].split(' ', 1)
            dateTime[1] = dateTime[1].replace(' ', '')
            assert len(dateTime) == 2
            lst[2] = Ownership.getTime(dateTime[0], dateTime[1])
            dateTime = lst[3].split(' ', 1)
            dateTime[1] = dateTime[1].replace(' ', '')
            lst[3] = Ownership.getTime(dateTime[0], dateTime[1])
            assert len(dateTime) == 2

            lst[5] = lst[5][:-1]  # ignore '\n'
            issue = Issue.Issue(lst[0], lst[1], lst[2], lst[3], lst[4], lst[5],
                                self.projectList[self.projectID])

            if issue.getType() == self.issueType and (lst[5] == 'FIXED' or
                                                      lst[5] == 'WORKSFORME'):
                if not (issue.name in self.issueDict):
                    self.addIssue(issue)
                    issue.setIndex(self.nrIssues)
                    self.i_R[self.nrNodes] = {}
                # only fixed issues must be added =>
            # if ("CLOSED" in status_i) or ("RESOLVED" in status_i) or ("VERIFIED" in status_i) or ("FIXED" in status_i):

        issueFile.close()
Ejemplo n.º 4
0
 def _useAttributes(self, attributes):
     if "actor" in attributes:  # pragma no branch
         assert attributes["actor"] is None or isinstance(
             attributes["actor"], dict), attributes["actor"]
         self._actor = None if attributes[
             "actor"] is None else NamedUser.NamedUser(
                 self._requester, attributes["actor"], completed=False)
     if "commit_id" in attributes:  # pragma no branch
         assert attributes["commit_id"] is None or isinstance(
             attributes["commit_id"],
             (str, unicode)), attributes["commit_id"]
         self._commit_id = attributes["commit_id"]
     if "created_at" in attributes:  # pragma no branch
         assert attributes["created_at"] is None or isinstance(
             attributes["created_at"],
             (str, unicode)), attributes["created_at"]
         self._created_at = self._parseDatetime(attributes["created_at"])
     if "event" in attributes:  # pragma no branch
         assert attributes["event"] is None or isinstance(
             attributes["event"], (str, unicode)), attributes["event"]
         self._event = attributes["event"]
     if "id" in attributes:  # pragma no branch
         assert attributes["id"] is None or isinstance(
             attributes["id"], int), attributes["id"]
         self._id = attributes["id"]
     if "issue" in attributes:  # pragma no branch
         assert attributes["issue"] is None or isinstance(
             attributes["issue"], dict), attributes["issue"]
         self._issue = None if attributes["issue"] is None else Issue.Issue(
             self._requester, attributes["issue"], completed=False)
     if "url" in attributes:  # pragma no branch
         assert attributes["url"] is None or isinstance(
             attributes["url"], (str, unicode)), attributes["url"]
         self._url = attributes["url"]
Ejemplo n.º 5
0
 def legacy_search_issues(self, state, keyword):
     assert state in ["open", "closed"], state
     assert isinstance(keyword, (str, unicode)), keyword
     headers, data = self._requester.requestAndCheck(
         "GET", "/legacy/issues/search/" + self.owner.login + "/" +
         self.name + "/" + state + "/" + urllib.quote(keyword), None, None)
     return [
         Issue.Issue(self._requester,
                     Legacy.convertIssue(element),
                     completed=False) for element in data["issues"]
     ]
Ejemplo n.º 6
0
 def __init__(self, memory: Memory, params=dict()):
     self.num_threads = int(params["NUM_THREAD"]) if "NUM_THREAD" in params.keys() else NUM_THREADS
     self.num_stages = int(params["NUM_STAGES"]) if "NUM_STAGES" in params.keys() else NUM_STAGES
     self.thread_unit = [Thread(tid,params) for tid in range(0, self.num_threads)]
     self.fetch_unit = [Fetch(tid, memory, params, self.thread_unit[tid]) for tid in range(0, self.num_threads)]  # Create fetch unit
     self.issue_unit = Issue(params)
     self.execute_unit = Execute(params)
     self.connect()
     self.timer = DEFAULT_TIMEOUT
     # Prefetch
     self.prefetch_policy = params["PREFETCH_POLICY"] if "PREFETCH_POLICY" in params.keys() else PREFETCH_POLICY
     self.tid_prefetch_vld = False
     self.tid_prefetch_ptr = 0
     # Verbosity
     self.timer = DEFAULT_TIMEOUT
     # Statistics
     self.last_tick = 0
     self.count_flushed_inst = 0
     self.ipc = 0
     self.total_num_of_mem_access = 0
Ejemplo n.º 7
0
def robo():
	try:
		lang = 'en'
		txx =''
		wel = ConversationEngine.ai("wel")
		SpeakingEngine.tts(wel,lang)
		while True:
			try:
				text = ListeningEngine.listener()
				if text=='learning mode':
					LearningEngine.LNow()
				elif text=='create issue':
					Issue.Create()
				elif text=='issue summary':
					Issue.Summary()
				else:
					txx = text
					SpeakingEngine.nerves(text, lang)

			except Exception as e:
				sye = ConversationEngine.ai("sye")
				SpeakingEngine.tts(sye,lang)
				raise
			else:
				pass
			finally:
				pass

			if txx =='bye':
				tqn = ConversationEngine.ai("tqn")
				SpeakingEngine.tts(tqn,lang)
				break 				
	except Exception as e:
		print("Opps! Sorry.......!")
		pass
	else:
		pass
	finally:
		pass
Ejemplo n.º 8
0
    def print_task_issue(self, issue, usr, scope, list_issue):

        Issue_print = Issue.TaskRedmine(issue, usr, scope)
        list_issue.append(Issue_print)

        print('Scope:  ' + scope)
        print("Redmine user id:  " + str(usr.redmine_id))
        print('Canonical name:  ' + usr.canonical_name)
        print("Email:  " + usr.mail)
        print('Firstname:  ' + usr.firstname)
        print('Lastname:  ' + usr.lastname)
        print('Office:  ' + usr.office)
        try:
            print("Assigned to:  " + str(issue.assigned_to))
        except:
            print("Print Assigned_to error")
        print("Status:  " + str(issue.status))
        print("Subject:  " + issue.subject)
        print("Description:  " + issue.description)
        print("Name of project:  " + str(issue.project))

        return list_issue
Ejemplo n.º 9
0
 def get_issue(self, number):
     assert isinstance(number, (int, long)), number
     headers, data = self._requester.requestAndCheck(
         "GET", self.url + "/issues/" + str(number), None, None)
     return Issue.Issue(self._requester, data, completed=True)
Ejemplo n.º 10
0
class Pipeline:
    # arg
    def __init__(self, memory: Memory, params=dict()):
        self.num_threads = int(params["NUM_THREAD"]) if "NUM_THREAD" in params.keys() else NUM_THREADS
        self.num_stages = int(params["NUM_STAGES"]) if "NUM_STAGES" in params.keys() else NUM_STAGES
        self.thread_unit = [Thread(tid,params) for tid in range(0, self.num_threads)]
        self.fetch_unit = [Fetch(tid, memory, params, self.thread_unit[tid]) for tid in range(0, self.num_threads)]  # Create fetch unit
        self.issue_unit = Issue(params)
        self.execute_unit = Execute(params)
        self.connect()
        self.timer = DEFAULT_TIMEOUT
        # Prefetch
        self.prefetch_policy = params["PREFETCH_POLICY"] if "PREFETCH_POLICY" in params.keys() else PREFETCH_POLICY
        self.tid_prefetch_vld = False
        self.tid_prefetch_ptr = 0
        # Verbosity
        self.timer = DEFAULT_TIMEOUT
        # Statistics
        self.last_tick = 0
        self.count_flushed_inst = 0
        self.ipc = 0
        self.total_num_of_mem_access = 0

    # Connect between the class's
    def connect(self):

        # Fetch Unit
        for tid in range(0, self.num_threads):
            self.fetch_unit[tid].thread_unit = self.thread_unit[tid]

        # Issue Unit
        # - thread_unit - Checks thread info and dependency
        # - fetch_unit - check the instruction inside the fetch
        # - Execute - pass the instruction to execute unit
        self.issue_unit.thread_unit = self.thread_unit
        self.issue_unit.fetch_unit = self.fetch_unit
        self.issue_unit.execute_unit = self.execute_unit

        # Execute
        # - thread_unit - TBD
        # - issue_unit - update in case of flush
        # - fetch_unit - update in case of flush
        self.execute_unit.thread_unit = self.thread_unit
        self.execute_unit.issue_unit = self.issue_unit
        self.execute_unit.fetch_unit = self.fetch_unit

    # The main function that happens every cycle and responsible on the progress of the pipeline.
    def tick(self, cur_tick):
        # Checking if all threads and units are finished there execution
        if self.check_done():
            return False

        # Update Execute
        self.execute_unit.tick(cur_tick)

        # Update Issue
        self.issue_unit.tick(cur_tick)

        # Select which thread will prefetch
        self.set_prefetch(cur_tick)

        # Progress Fetch
        for idx in range(0, self.num_threads):
            self.fetch_unit[idx].tick(cur_tick)

        # Update simulation statistics
        self.update_statistics(cur_tick)

        self.trace_tick(cur_tick)
        return True

    # Used as trace of simulator
    def trace_tick(self, cur_tick):
        prefetch_id = self.tid_prefetch_ptr if self.tid_prefetch_vld else "x"
        fetch_sts = [str(self.fetch_unit[i].fetchQueue.len()) for i in range(0, self.num_threads)]
        issue_sts = self.issue_unit.get_status()
        execute_sts = self.execute_unit.get_status()
        thread_sts = [" t"+str(i)+": "+str(self.thread_unit[i].ready)+",af-"+str(int(self.fetch_unit[i].branch_taken_in_queue)) for i in range(0, self.num_threads)]
        msg = "{0:<5},{1:^5},{2},{3:^15}, {4:^35} \t, {5}".format(
            cur_tick, prefetch_id, ",".join(fetch_sts), issue_sts, execute_sts, ",".join(thread_sts))
        pprint(msg, "NORM")

    # Check Between all thread, who is legit for fetching
    def set_prefetch(self, cur_tick):
        self.tid_prefetch_vld = False
        req_list = [self.fetch_unit[tid].check_prefetch() for tid in range(self.num_threads)]
        # update based on the policy of prefetch - changes tid_prefetch_ptr if it is needed
        self.update_prefetch_policy()
        self.tid_prefetch_ptr = round_robin(self.tid_prefetch_ptr, req_list, self.num_threads)
        if req_list[self.tid_prefetch_ptr]:
            self.fetch_unit[self.tid_prefetch_ptr].set_prefetch(cur_tick)
            self.tid_prefetch_vld = True

    # --------------- Policies ---------------#
    def update_prefetch_policy(self):
        if self.prefetch_policy == "RR":
            pass

    # Check if all units are done
    def check_done(self):
        # Check all fetch units are done = last inst + no pending inst + queue is empty
        fetch_done = all([self.fetch_unit[i].fetch_done() for i in range(0, self.num_threads)])
        issue_done = self.issue_unit.issue_empty
        execute_done = self.execute_unit.done()
        timeout_done = self.timer == 0
        return (fetch_done and issue_done and execute_done) or timeout_done

    # ---------------  Statistics ---------------#

    def update_statistics(self, cur_tick):
        # count how many valid instruction committed
        self.timer -= 1
        self.last_tick = cur_tick
        if not self.execute_unit.committed_inst.empty_inst:
            self.timer = DEFAULT_TIMEOUT
        else:
            self.timer -= 1

        if self.last_tick:  # Avoid division by zero
            self.ipc = float(self.execute_unit.count_committed_inst / self.last_tick)

        self.count_flushed_inst = self.issue_unit.count_flushed_inst + self.execute_unit.count_flushed_inst +\
            sum([self.fetch_unit[idx].flushed_inst_count for idx in range(0, self.num_threads)])

        self.total_num_of_mem_access =  sum([self.fetch_unit[idx].num_of_mem_access for idx in range(0, self.num_threads)])

    def report_model(self):
        for tid_idx in range(0, self.num_threads):
            self.fetch_unit[tid_idx].report_statistics()
        self.issue_unit.report_model()
        self.execute_unit.report_model()
        print("Num Thread={0}, stage={1}".format(
            self.num_threads, self.execute_unit.num_stages))

    def report_statistics(self):
        msg = "Inst Committed {0} ipc {1:.3f} flushed {2} mem accesses {3}".format(
            self.execute_unit.count_committed_inst, self.ipc, self.count_flushed_inst, self.total_num_of_mem_access)
        pprint(msg, "NONE")