Beispiel #1
0
 def cmd_checkout(branch):
     b = Branch()
     b.switch_branch(branch)
     repo = Repository()
     pre_entries = dict(repo.index.entries)
     repo.rebuild_index_from_commit(repo.branch.head_commit)
     repo.rebuild_working_tree(pre_entries)
Beispiel #2
0
    def __init__(self, line):
        Definition.__init__(
            self, line,
            '([a-zA-Z_][a-zA-Z0-9_]*)(|\\[.+\\])/([^ ]+)Ref(?:|/([!m]+))$')
        self.refname = self.matches.group(1)
        arrdef = self.matches.group(2)
        self.objname = self.matches.group(3)
        try:
            objdef = PhysicsObject.get(self.objname)
        except KeyError:
            raise Definition.NoMatch()

        if objdef.is_singlet():
            raise RuntimeError('Cannot create reference to single object ' +
                               objdef.name)

        modifier = self.matches.group(4)
        if modifier is None:
            mod = ''
        else:
            mod = '/' + modifier

        # create a branch for the index with name {name}_
        Branch.__init__(
            self, '{name}_{arrdef}/S{mod} = -1'.format(name=self.refname,
                                                       arrdef=arrdef,
                                                       mod=mod))
Beispiel #3
0
 def cmd_checkout(branch):
     b = Branch()
     b.switch_branch(branch)
     repo = Repository()
     pre_entries = dict(repo.index.entries)  
     repo.rebuild_index_from_commit(repo.branch.head_commit)
     repo.rebuild_working_tree(pre_entries)
Beispiel #4
0
def run(args):
    """
    run the corresponding action
    """
    my_config = Config()
    if args['action'] == 'config':
        args['list_repositories'] and my_config.print_repositories()
    else:
        module_obj = Module(
            args['module_name'], args['module_developers'],
            args['module_planners'],
            args['module_auditors'], folder=args['destination_folder'],
            init_data=args['add_init_data'], company_name=args['company_name'])
        if args['action'] == 'branch':
            branch_obj = Branch(
                module_obj, args['branch_suffix'], args['parent_repo'],
                args['oerp_version'], args['destination_folder'])
            branch_obj.create_branch()
            module_obj.create(branch_obj)
        elif args['action'] == 'create':
            module_obj.create()
        elif args['action'] == 'append':
            module_obj.append(args['append_file'], args['file_name'])

        #~ module_obj.branch_changes_apply()
    return True
Beispiel #5
0
 def __init__(self, points, links):
     for p in points:
         p[0] = p[0]*scale
         p[1] = p[1]*scale
         p[2] = p[2]*scale
     for l in links:
         l[2] = l[2]*scale
     self.points = points
     self.root = Branch(int(links[0][0]),int(links[0][1]), links[0][2])
     heap = [self.root]
     self.points.append(points[self.root.initialPoint])
     while not (len(heap) == 0):
         atual = heap.pop()
         self.points.append(points[atual.finalPoint])
         for l in links:
             ip = int(l[0])
             if ip == atual.finalPoint:
                 son = Branch(int(l[0]),int(l[1]), l[2])
                 son.root = atual
                 if atual.son1 == None:
                     atual.son1 = son
                     heap.append(son)
                 else:
                     atual.son2 = son
                     heap.append(son)
     self.sort()
     self.vol = None
     self.surfVols = []
Beispiel #6
0
    def write_decl(self, out, context):
        if context == 'datastore':
            out.writeline('ContainerBase const* {name}Container_{{0}};'.format(
                name=self.refname))
            Branch.write_decl(self, out, context)
        else:
            if context == 'Singlet':
                out.indent -= 1
                out.writeline('protected:')
                out.indent += 1
                out.writeline(
                    'ContainerBase const* {name}Container_{{0}};'.format(
                        name=self.refname))
                Branch.write_decl(self, out, context)
                out.indent -= 1
                out.writeline('public:')
                out.indent += 1

            if self.is_array():
                out.writeline('Ref<{type}> {name}{arrdef}{{}};'.format(
                    type=self.objname,
                    name=self.refname,
                    arrdef=self.arrdef_text()))
            else:
                out.writeline('Ref<{type}> {name};'.format(type=self.objname,
                                                           name=self.refname))
def lambda_handler(event, context):
    if 'body' in event:
        item = json.loads(event.pop('body', event))
    else:
        item = event
    dto = Branch(item)
    ret_val = dto.create()
    response = {'statusCode': 200, 'body': json.dumps({'result': ret_val})}
    return response
Beispiel #8
0
    def run(self):
        try:
            self.load()
            self.halted = False
        except FileNotFoundError:
            sys.exit()

        branch_table = Branch()
        branch_table.run(self.ram, self.pc, self.register)
        print(self.register)
Beispiel #9
0
    def write_set_address(self, out, context):
        if '!' in self.modifier:
            return

        if context == 'Element':
            out.writeline(
                'utils::setAddress(_tree, _name, "{name}", gStore.getData(this).{name}, _branches, true);'
                .format(name=self.name))
        else:
            Branch.write_set_address(self, out, context)
Beispiel #10
0
 def third_choice(self):
     print(
         "You could try to convince the kids to help you. Or maybe you can buy yourself time to escape if you"
         " get the old man talking.")
     print("1. Appeal to the children")
     print("2. Distract the old man.")
     player_choice = input()
     if player_choice == '1':
         Ending3.ending(Ending3)
     if player_choice == '2':
         Branch.branching(Branch)
def lambda_handler(event, context):
    if 'queryStringParameters' in event:
        item = event.pop('queryStringParameters')
        if isinstance(item, str):
            item = literal_eval(item)
    else:
        item = event
    dto = Branch(item)
    ret_val = dto.delete()
    response = {'statusCode': 200, 'body': json.dumps({'result': ret_val})}
    return response
Beispiel #12
0
def test_find_endpoint():
    p = Point(0, 0)
    b = Branch(p)
    assert b.find_endpoint() == (0, -100)
    b = Branch(p, dst=50)
    assert b.find_endpoint() == (0, -50)
    b = Branch(p, dst=50, angle=180)
    assert b.find_endpoint() == (0, 50)
Beispiel #13
0
def add_branch():
    data = request.get_json()
    # data = json.loads(data2)

    city = data["city"]
    state = data['state']
    branch_id = data['branch_id']
    address = data['address']
    new_branch = Branch(branch_id, address, city, state)
    new_branch.save()

    return "success"
Beispiel #14
0
def build_tree():
    root = Branch()
    branches = [root]
    for _ in range(500):
        new_branch = Branch()
        branches.append(new_branch)
        clear_branch = find_clear_branch(root)
        clear_branch.attach(new_branch)

    secret_branch = choice(branches)
    secret_branch.has_kitten = True
    root.show()
    return root
Beispiel #15
0
    def init_copy(self, lines, context):
        if self.is_array():
            return

        if context == 'Singlet' or context == 'TreeEntry':
            lines.append('{name}Container_(_src.{name}Container_)')
            Branch.init_copy(lines, context)
            lines.append(
                '{name}({name}Container_, {name}_)'.format(name=self.refname))
        elif context == 'Element':
            lines.append(
                '{name}(gStore.getData(this).{name}Container_, gStore.getData(this).{name}_[0])'
                .format(name=self.refname))
Beispiel #16
0
    def write_book(self, out, context):
        if '!' in self.modifier:
            return

        if context == 'Element':
            out.writeline(
                'utils::book(_tree, _name, "{name}", "{arrdef}", \'{type}\', gStore.getData(this).{name}, _branches);'
                .format(name=self.name,
                        arrdef=self.arrdef_text(),
                        type=self.type,
                        refname=self.refname))
        else:
            Branch.write_book(self, out, context)
Beispiel #17
0
	def __init__(self, memoryFile):
		self.nCycles = 0 # Used to hold number of clock cycles spent executing instructions

		# Fetch
		self.PCMux	  = Mux()
		self.ProgramC   = PC(long(0xbfc00200))
		self.InstMem	= InstructionMemory(memoryFile)
		self.IFadder	= Add()
		self.JMux	   = Mux()
		self.IFaddconst = Constant(4)
		self.IF_ID_Wall = Wall()
		self.fetchgroup = {}

		# Decode
		self.register   = RegisterFile()
		self.signext	= SignExtender()
		self.control	= ControlElement()
		self.jmpCalc	= JumpCalc()
		self.ID_EX_Wall = Wall()

		# Execute
		self.EXadder	= Add()
		self.shiftL	 = LeftShifter()
		self.ALogicUnit = ALU()
		self.ALUSrcMux  = Mux()
		self.RegDstMux  = Mux()
		self.ALUctrl	= AluControl()
		self.EX_MEM_Wall= Wall()

		# Memory
		self.storage	= DataMemory(memoryFile)
		self.brnch	  = Branch()
		self.MEM_WB_Wall= Wall()

		# Write Back
		self.WBmux = Mux()

		self.ProgramC
		self.elements1 = [self.InstMem, self.IFaddconst, self.IFadder, self.PCMux, self.JMux]
		self.elements2 = [self.control, self.register, self.signext, self.jmpCalc]
		self.elements3 = [self.shiftL, self.ALUSrcMux, self.RegDstMux, self.ALUctrl, self.ALogicUnit, self.EXadder]
		self.elements4 = [self.brnch, self.storage]
		self.elementsboot = [self.IFaddconst, self.IFadder, self.InstMem,
							 self.IF_ID_Wall, self.register, self.signext, self.control, self.jmpCalc,
							 self.ID_EX_Wall, self.RegDstMux, self.shiftL, self.EXadder, self.ALUSrcMux, self.ALUctrl, self.ALogicUnit,
							 self.EX_MEM_Wall, self.brnch, self.storage,
							 self.MEM_WB_Wall, self.WBmux, self.PCMux, self.JMux]
		self.walls = [self.MEM_WB_Wall, self.EX_MEM_Wall, self.ID_EX_Wall, self.IF_ID_Wall]


		self._connectCPUElements()
Beispiel #18
0
 def splitBranch(self,branch, point):
     self.points.append(point)
     radius = branch.radius
     new = Branch(len(self.points)-1, branch.finalPoint, radius)
     new.root = branch
     new.son1 = branch.son1
     new.son2 = branch.son2
     if branch.son1 is not None:
         new.son1.root = new
     if branch.son2 is not None:
         new.son2.root = new
         branch.son2 = None 
     branch.finalPoint = new.initialPoint
     branch.son1 = new
Beispiel #19
0
    def span_trees(self):
        """
        Span a tree for each battery with its houses.
        For all nodes in the tree, determine all paths to
        remaining houses and choose the cheapest path. 
        Add the new house to the tree and all nodes of 
        its path. Continue until all houses are in the tree.
        """

        for battery in self.batteries:
            mst = {}
            tree = {battery: {}}
            houses = copy.deepcopy(battery.houses)

            for house in houses:
                distance = get_distance(house, battery)
                tree[battery][house] = distance

            least_distance = {}
            while houses:
                for vertice in tree.keys():
                    distance_to_targets = tree[vertice]
                    house, distance = min(
                        distance_to_targets.items(), key=lambda x: x[1])
                    least_distance[vertice] = (house, distance)

                link = min(least_distance.items(), key=lambda x: x[1][1])

                from_vertice, new_vertice, distance = link[0], link[1][0], link[1][1]
                new_nodes = pathfinder(from_vertice, new_vertice)[1:-1]
                branch = Branch(from_vertice, new_vertice)
                branch.load_path(new_nodes)
                mst[branch] = distance

                houses.remove(new_vertice)
                for vertice in tree.keys():
                    del tree[vertice][new_vertice]

                for node in new_nodes:
                    tree[node] = {}
                    for house in houses:
                        distance = get_distance(node, house)
                        tree[node][house] = distance

                tree[new_vertice] = {}
                for house in houses:
                    distance = get_distance(new_vertice, house)
                    tree[new_vertice][house] = distance

            self.mst_container.append(mst)
Beispiel #20
0
    def iteration(self, rule = [( + 85/180*np.pi, 1.5), (-85/180*np.pi, 1.5)], noise = True):
        """
        This method is what differentiate an L-system form another. The necessary rules for the costruction are:
            -1) number of child branch (n = 2,3)
            -2) angle deviation of each child branch (+ alpha, - alpha)
            -3) increasing/decreasing length ratio (l1 = l0 * R).
            -4) Presence of noise on the angle in the ramification.
                [It's greater and greater going on with the iterations (proportional to iter_lev)]

        The current branch is used to create the new branch(es). The first three rules could be all condesed
        in a list, like this one:    [(+alpha, R), (-alpha, R)].
        This rule create 2 new branches (list lenght) with the reported angular deviation al lenght ratio.
        The origin and generation relationship shuold be update after every application of the rules.
        """
        if self.branches != []:
            for br in self.branches:
                if br.iter_lev == self.n_iter:
                    l0, theta0 =cmath.polar(br.head - br.tail)
                    for gen in rule:
                        #The first iterations are made completely
                        if self.n_iter < 3:
                            ang_noise = noise*br.iter_lev*gen[0]/20
                            l1 = l0/gen[1]
                            theta1 = theta0 + gen[0]
                            theta1 = theta1 + random.uniform(-ang_noise, ang_noise)  #Adding noise
                            travel = cmath.rect(l1, theta1)
                            new_branch = Branch(tail = br.head,
                                                head = br.head + travel,
                                                iter_lev = self.n_iter + 1,
                                                origin = br)
                            br.generate.append(new_branch)
                            self.branches.append(new_branch)
                        #Further iterations are subjected to variations
                        elif np.random.uniform()> 0.1:
                            ang_noise = noise*br.iter_lev*gen[0]/20
                            l1 = l0/gen[1]
                            theta1 = theta0 + gen[0]
                            theta1 = theta1 + random.uniform(-ang_noise, ang_noise)  #Adding noise
                            travel = cmath.rect(l1, theta1)
                            new_branch = Branch(tail = br.head,
                                                head = br.head + travel,
                                                iter_lev = self.n_iter + 1,
                                                origin = br)
                            br.generate.append(new_branch)
                            self.branches.append(new_branch)

            self.n_iter += 1 #updating n_iter
        else:
            raise Exception('Start your L_system before iteration.')
Beispiel #21
0
def lambda_handler(event, context):
    if 'queryStringParameters' in event:
        item = event.pop('queryStringParameters')
        if isinstance(item, str):
            item = literal_eval(item)
    else:
        item = event
    dto = Branch(item)
    return_item = dto.read()

    response = {
        'statusCode': 200,
        "body": json.dumps(return_item),
    }
    return response
def process_branch(branch_dict, repo):
    """ Takes a dictionary that has branch names as keys. This method sets
    branches for repo"""
    for branch_name in branch_dict:
        branch = branch_dict[branch_name]
        repo.get_branches()[branch_name] = Branch(branch[BRANCH_HEAD],
                                                  branch_name)
Beispiel #23
0
 def start(self, branch = Branch()):
     """
     Method that initialize/overwrite the previous drawing.
     The default starting branch is the tail = (0,0), head = (0,1), iter_lev = 0, origin = None]
     """
     self.n_iter = 0
     self.branches = [branch]
Beispiel #24
0
    def __getBranchMapFromRefList(self, aRefList):
        """
    Retrieve the branch map for this manager for all local branches. The branch
    map is a list of Branch objects, each mapping a ref path to a
    healthy/aged/old status.

    :param aRefList: A list of Reference objects that should be processed and
                     mapped to healthy statuses.

    :return: A list of Branch objects, each of which maps one Reference in aRefList
             to a health status.
    """
        log = self.__mConfig.getLog()
        branchMap = []

        for branch in aRefList:
            branchPath = branch.path
            branchName = branchPath.split('/')[-1]

            # Don't include branches that should be ignored.
            shouldIgnore = False
            for ignoredBranch in self.__getConfig().getIgnoredBranches():
                if branchName == ignoredBranch:
                    shouldIgnore = True
                    break
            if shouldIgnore:
                continue

            newBranch = Branch(branchPath, self.__getConfig())
            branchMap.append(newBranch)
        return branchMap
Beispiel #25
0
 def test_commit_once(self):
     Command.cmd_commit('first ci')
     commit = Commit(sha1=Branch().head_commit)
     self.assertIsNone(commit.parent_sha1)
     tree = Tree(sha1=commit.tree)
     objects = tree.parse_objects()
     self.assertEqual(objects[self.path]['sha1'], Blob(self.content).sha1)
Beispiel #26
0
  def __init__(self, memoryFile):
    self.nCycles = 0 # Used to hold number of clock cycles spent executing instructions
    
    self.adder              = Add()
    self.branchAdder        = Add()
    self.alu                = Alu()
    self.aluControl         = AluControl()
    self.branchNE           = BranchNotEqual()
    self.branch             = Branch()
    self.constant           = Constant(4)
    self.control            = Control()
    self.dataMemory         = DataMemory(memoryFile)
    self.instructionMemory  = InstructionMemory(memoryFile)
    self.regMux             = Mux()
    self.aluMux             = Mux()
    self.dmMux              = Mux()
    self.branchMux          = Mux()
    self.jmpMux             = Mux()
    self.registerFile       = RegisterFile()
    self.shiftLeft2         = ShiftLeft2()
    self.signExtend         = SignExtend()
    self.jump               = Jump()
    self.leftShift2         = ShiftLeft2()
    self.leftShift2Jump     = ShiftLeft2Jump()

    self.IFID = IFID()
    self.IDEX = IDEX()
    self.EXMEM = EXMEM()
    self.MEMWB = MEMWB()

    self.pc = PC(0xbfc00200) # hard coded "boot" address
    
    self.IFIDelements = [ self.constant, self.branchMux, self.jmpMux, self.instructionMemory, self.adder ]

    self.IDEXelements = [ self.control, self.registerFile, self.signExtend, self.leftShift2Jump, self.jump ]

    self.EXMEMelements = [ self.regMux, self.aluControl, self.aluMux, self.alu, self.shiftLeft2, self.branchAdder, self.branchNE, self.branch ]
    
    self.MEMWBelements = [ self.dataMemory ]

    self.WBelements = [ self.dmMux ] 

    self.elements = [ self.IFIDelements, self.IDEXelements, self.EXMEMelements, self.WBelements]

    self.pipes = [ self.IFID, self.IDEX, self.EXMEM, self.MEMWB]
    
    self._connectCPUElements()
Beispiel #27
0
def test_get_colour():
    c = Colours((0, 0, 0), (255, 255, 255))
    p = Point(0, 0)
    b = Branch(p)
    c.assign_colour(b, 0)
    assert c.palette[c.get_colour(b)] == (0, 0, 0)
    c.assign_colour(b, 1023)
    assert c.palette[c.get_colour(b)] == (0, 0, 0)
Beispiel #28
0
 def test_reset_default(self):
     Command.cmd_reset(self.first_commit, is_soft=False, is_hard=False)
     self.assertEqual(Branch().head_commit, self.first_commit)
     repo = Repository()
     uncommitted_files = repo.get_uncommitted_files()
     unstaged_files = repo.get_unstaged_files()
     self.assertFalse(uncommitted_files['modified'])
     self.assertIn(self.path, unstaged_files['modified'])
Beispiel #29
0
def create_branch():
    branch_name = input('Branch Name: ')
    branch_code = input('Branch Code: ')
    address = Address('', '', '', '', '', '', '', '')
    address.input_address()
    b = Branch(branch_code, branch_name, address)
    global_branches[b.branch_code] = b
    print('Branch created successfully!')
def get_tactic_by_waves_forward(waves_forward):
    branch = Branch()
    for waves_forward in range(waves_forward, 0, -1):
        best_basket = compute_best_basket(branch.player, waves_forward)
        branch.buy_basket(best_basket)
        yield branch.copy()
        branch.next_wave()
def get_max_income_tactic():
    branch = Branch()
    while True:
        best_basket = compute_best_basket(branch.player)
        branch.buy_basket(best_basket)
        yield branch.copy()
        branch.next_wave()
Beispiel #32
0
def main():

    # Main loop
    while True:
        events = pygame.event.get()
        for event in events:
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        # Draw on screen
        screen.blit(bg, (0, 0))
        draw_ground()

        tam_br = 8
        if main_br.get_len() > 5:
            length = main_br.get_len()
            # if length
            branch = Branch(main_br.get_rect(length - 1).x,
                            main_br.get_rect(length - 1).y,
                            color=GREEN,
                            tam=8)
            branch.set_direction(Branch.RIGHT)
            tree.append(branch)

        if main_br.get_len() > 5:
            length = main_br.get_len()
            branch = Branch(main_br.get_rect(length - 1).x,
                            main_br.get_rect(length - 1).y,
                            color=GREEN,
                            tam=8)
            branch.set_direction(Branch.LEFT)
            tree.append(branch)

        # # Drawing branches and main
        # if main_br.get_len() in [5, 15, 25, 35, 45]:
        # 	length = main_br.get_len()
        # 	branch = Branch(main_br.get_rect(length-1).x, main_br.get_rect(length-1).y, color=GREEN, tam=8)
        # 	branch.set_direction(Branch.RIGHT)
        # 	tree.append(branch)

        # if main_br.get_len() in [10, 20, 30, 40, 50]:
        # 	length = main_br.get_len()
        # 	branch = Branch(main_br.get_rect(length-1).x, main_br.get_rect(length-1).y, color=GREEN, tam=8)
        # 	branch.set_direction(Branch.LEFT)
        # 	tree.append(branch)

        for br in tree:
            br.draw_branch(screen)

        pygame.display.update()
        sleep(0.1)
        clock.tick(30)
Beispiel #33
0
    def create_branch(self, cid, branch_cells, end_point_ids):
        '''Create a branch from the centerlines.
        '''
        points = self.geometry.GetPoints()
        num_lines = self.geometry.GetNumberOfLines()

        ## Find ends of line.
        #
        branch_end_point_ids = []
        branch_end_cell_ids = []

        for cell_id in branch_cells[cid]:
            cell = self.geometry.GetCell(cell_id)
            cell_pids = cell.GetPointIds()
            num_ids = cell_pids.GetNumberOfIds()
            pid1 = cell_pids.GetId(0)
            pid2 = cell_pids.GetId(1)
            if pid1 in end_point_ids:
                start_cell = cell_id
                branch_end_point_ids.append(pid1)
                branch_end_cell_ids.append(cell_id)
            elif pid2 in end_point_ids:
                branch_end_point_ids.append(pid2)
                branch_end_cell_ids.append(cell_id)

        ## Create branch geometry.
        #
        branch_geom = vtk.vtkPolyData()
        branch_geom.SetPoints(points)
        branch_lines = vtk.vtkCellArray()
        #
        for cell_id in branch_cells[cid]:
            cell = self.geometry.GetCell(cell_id)
            cell_pids = cell.GetPointIds()
            num_ids = cell_pids.GetNumberOfIds()
            pid1 = cell_pids.GetId(0)
            pid2 = cell_pids.GetId(1)
            line = vtk.vtkLine()
            line.GetPointIds().SetId(0, pid1)
            line.GetPointIds().SetId(1, pid2)
            branch_lines.InsertNextCell(line)
        #
        branch_geom.SetLines(branch_lines)

        branch_end_normals = []
        for pid in branch_end_point_ids:
            pt = points.GetPoint(pid)
            normal = self.surface.get_point_normal(pt)
            branch_end_normals.append(normal)

        #print("[centerlines] branch cid: {0:d}".format(cid))
        #print("[centerlines]   branch_end_point_ids: {0:s}".format(str(branch_end_point_ids)))
        #print("[centerlines]   branch_end_cell_ids: {0:s}".format(str(branch_end_cell_ids)))
        return Branch(cid, branch_geom, branch_end_point_ids, branch_end_cell_ids, branch_end_normals, 
                      self.clip_distance, self.clip_width_scale)
Beispiel #34
0
    def test_commit_twice(self):
        Command.cmd_commit('first ci')
        parent_sha1 = Branch().head_commit

        second_content = '11\n'
        write_to_file(self.path, second_content)

        new_path = '2.txt'
        new_content = '2\n'
        write_to_file(new_path, new_content)

        Command.cmd_add('.')
        Command.cmd_commit('second ci')

        commit = Commit(sha1=Branch().head_commit)
        self.assertEqual(parent_sha1, commit.parent_sha1)
        tree = Tree(sha1=commit.tree)
        objects = tree.parse_objects()
        self.assertEqual(objects[self.path]['sha1'], Blob(second_content).sha1)
        self.assertEqual(objects[new_path]['sha1'], Blob(new_content).sha1)
Beispiel #35
0
 def cmd_branch(name, is_deleted=False):
     b = Branch()
     if not name:
         for branch in b.get_all_branches():
             print '* %s' % colored(branch, 'green') if branch == b.head_name else '  %s' % branch
     elif is_deleted:
         b.delete_branch(name)
     else :
         b.add_branch(name)
Beispiel #36
0
	def collect(project):
		#1.Server
		server_list=Server.get_server_list()
		#2.Project_Insert new projects
		new_project_list=Project.get_new_project_list(server_list)
		if len(new_project_list) >0:
			Project.insert_new_project_list(new_project_list)
		#2.Project_Get all projects
		serial_number=0
		#Collect data by server_name
		server_name=""
		if len(sys.argv)>1:
			server_name=sys.argv[1]
		if server_name=="":
			project_list=Project.get_project_list()
		else:
			project_list=Project.get_project_list(server_name)	   
		for project in project_list:
			serial_number=serial_number+1
			print (">>>>>>No%s.Git project url: %s " %(len(project_list)-serial_number, project.project_repository_url))
			print (">>>>>>0_Collecting push records")
			is_have_new_push=Push.collect_push_list(project)
			if is_have_new_push==0:
				print (">>>>>>There is nothing new in repository \n")
				continue
			# clean workspace
			git_home=os.getcwd()
			git_path=git_home+"/"+project.project_name
			if os.path.isdir(git_path):
				Util.getpipeoutput(["rm -rf %s " % git_path ])   
			print (">>>>>>1_Git path: %s" % git_path)
			print (">>>>>>2_Clone git repository")
			Util.getpipeoutput(["git clone %s " % project.project_repository_url+project.project_name ])
			print (">>>>>>3_Collecting git data")
			if os.path.isdir(git_path):
				os.chdir(git_path)
				#########Begin to collect
				#Collect new branchs 
				Branch.collect_branch_list(project.project_id)		
				#Query all branchs from database
				all_branch_list=Branch.get_branch_list(project.project_id)
				branch_list=[]
				for branch in all_branch_list:
					revision_list=[]
					print("   >>>>>>>>Branch Name:"+branch.branch_name)
					current_branch=Util.getpipeoutput(["git rev-parse --abbrev-ref HEAD"])
					if current_branch!=branch.branch_name:
						Util.getpipeoutput(["git checkout %s" % branch.branch_name])
					# if last_commit_id is empty ,it means that it's a new branch
					latest_commit_id=Util.getpipeoutput(["git rev-parse HEAD"])
					if branch.branch_last_commit_id!=latest_commit_id:
						#Collect all the Revisions(all commits)
						branch_total_line=Revision.collect_revision_list(branch,latest_commit_id)
						#Collect all the files
						local_file_change_list=File.collect_file_list(branch,latest_commit_id)
						#Collect all the link
						Revision_File_Link.collect_link_list(local_file_change_list,branch,latest_commit_id)
						#Update branch info
						branch.branch_type="update"
						branch.branch_total_line=branch_total_line
						branch.branch_last_commit_id=latest_commit_id
						branch.branch_contributor_counts = int(Util.getpipeoutput(["git shortlog -s %s" % Util.getlogrange(), "wc -l"]))
						branch.branch_file_counts=int(Util.getpipeoutput(["git ls-files | wc -l"]))
						branch_list.append(branch)
				Branch.update_branch_list(branch_list)
				Tag.collect_tag_list(project.project_id)
				# Merge Request
				# Project LOC
				#########End
				os.chdir(git_home)
			print (">>>>>>4.Delete the git repository diretory\n")
			if os.path.isdir(git_path):
				Util.getpipeoutput(["rm -rf %s " % git_path ])
Beispiel #37
0
    def bif(self, branch):
        pi = self.points[branch.initialPoint]
        pf = self.points[branch.finalPoint]
        pi1 = self.points[branch.son1.initialPoint]
        pf1 = self.points[branch.son1.finalPoint]
        pi2 = self.points[branch.son2.initialPoint]
        pf2 = self.points[branch.son2.finalPoint]
        lenght = geo.distance(pi, pf)
            
        t=(lenght-1.1*branch.radius)/lenght
        newPf = [(1-t)*pi[0]+t*pf[0],((1-t)*pi[1]+t*pf[1]),((1-t)*pi[2]+t*pf[2])]
        self.points[branch.finalPoint] = newPf
        #geo.createVertex(newPf[0],newPf[1],newPf[2])
        t=(lenght+0*branch.radius)/lenght
        newPoint1 = [(1-t)*pi[0]+t*pf[0],((1-t)*pi[1]+t*pf[1]),((1-t)*pi[2]+t*pf[2])]
#         u0 = [newPf[0]-newPoint1[0],newPf[1]-newPoint1[1],newPf[2]-newPoint1[2]]
#         u1 = [newPoint1[0]-pf1[0],newPoint1[1]-pf1[1],newPoint1[2]-pf1[2]]
#         u0 = [newPoint1[0]-newPf[0],newPoint1[1]-newPf[1],newPoint1[2]-newPf[2]]
#         u1 = [pf1[0]-newPf[0],pf1[1]-newPf[1],pf1[2]-newPf[2]]
        u0 = [pf1[0]-newPf[0],pf1[1]-newPf[1],pf1[2]-newPf[2]]
        u1 = [pf2[0]-newPf[0],pf2[1]-newPf[1],pf2[2]-newPf[2]]
        u = geo2.crossProduct(u0, u1)
        u = geo2.getVector4_3(u)
        geo2.normalizeVector(u)
        newPoint1 = geo2.rotateByAxis(geo2.getVector4_3(newPoint1), geo2.getVector4_3(newPf), u, 40)
        vecR = geo2.getVector(pi, newPf)
        vecF1 = geo2.getVector(newPf, newPoint1)
        #geo.createVertex(newPoint1[0],newPoint1[1],newPoint1[2])
        t=(lenght+0*branch.radius)/lenght
        newPoint2 = [(1-t)*pi[0]+t*pf[0],((1-t)*pi[1]+t*pf[1]),((1-t)*pi[2]+t*pf[2])]
#         u0 = [newPoint2[0]-newPf[0],newPoint2[1]-newPf[1],newPoint2[2]-newPf[2]]
#         u1 = [pf2[0]-newPf[0],pf2[1]-newPf[1],pf2[2]-newPf[2]]
#         u = geo2.crossProduct(u0, u1)
#         u = geo2.getVector4_3(u)
#         geo2.normalizeVector(u)
        newPoint2 = geo2.rotateByAxis(geo2.getVector4_3(newPoint2), geo2.getVector4_3(newPf), u, -40)
        vecF2 = geo2.getVector(newPf, newPoint2)
        ang3 = geo2.getAngle(vecF1, vecF2)
        if ang3 < 60:
            newPoint1 = geo2.rotateByAxis(geo2.getVector4_3(newPoint1), geo2.getVector4_3(newPf), u, 20)
            newPoint2 = geo2.rotateByAxis(geo2.getVector4_3(newPoint2), geo2.getVector4_3(newPf), u, -20)
        #geo.createVertex(newPoint2[0],newPoint2[1],newPoint2[2])
        d1 = geo.distance(pf1, newPoint1)+geo.distance(pf2, newPoint2)
        d2 = geo.distance(pf1, newPoint2)+geo.distance(pf2, newPoint1)
        if d1>d2:
            aux = newPoint1
            newPoint1 = newPoint2
            newPoint2 = aux
        self.points.append(newPoint1)
        radius1 = branch.radius
        radius2 = branch.radius
#         radius1 = branch.son1.radius
#         radius2 = branch.son2.radius
#         sumRadius = radius1 + radius2
#         while sumRadius > 1.2:
#             radius1 = radius1*0.95
#             radius2 = radius2*0.95
#             sumRadius = radius1 + radius2
        new1 = Branch(branch.finalPoint, len(self.points)-1,radius1)
        new1.root = branch
        new1.son1 = branch.son1
        new1.son1.initialPoint = len(self.points)-1
        new1.son1.root = new1
        branch.son1 = new1
           
        self.points.append(newPoint2)
        new2 = Branch(branch.finalPoint, len(self.points)-1, radius2)
        new2.root = branch
        new2.son1 = branch.son2
        new2.son1.initialPoint = len(self.points)-1
        new2.son1.root = new2
        branch.son2 = new2