Python pdb.set_trace() Examples

The following are 30 code examples of pdb.set_trace(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pdb , or try the search function .
Example #1
Source File: spider.py    From google-scholar-crawler with Apache License 2.0 7 votes vote down vote up
def parse_1(self, response):
        info('Parse '+response.url)
        #sel = Selector(response)
        #v = sel.css('.gs_ggs a::attr(href)').extract()
        #import pdb; pdb.set_trace()
        x = self.parse_with_rules(response, self.list_css_rules, dict)
        items = []
        if len(x) > 0:
            items = x[0]['.gs_r']
            pp.pprint(items)
        import pdb; pdb.set_trace()
        # return self.parse_with_rules(response, self.css_rules, googlescholarItem)

        for item in items:
            if item['related-url'] == '' or item['related-type'] != '[PDF]':
                continue
            url = item['related-url']
            info('pdf-url: ' + url)
            yield Request(url, callback=self.save_pdf) 
Example #2
Source File: nlp_template.py    From tamil-lm2 with GNU General Public License v2.0 6 votes vote down vote up
def waccuracy(output, batch, *args, **kwargs):
    indices, (sentence, ), (label, ) = batch
    output, attn = output
    index = label
    src = Var(torch.ones(label.size()))
    
    acc_nomin = Var(torch.zeros(output.size(1)))
    acc_denom = Var(torch.ones(output.size(1)))

    acc_denom.scatter_add_(0, index, (label == label).float() )
    acc_nomin.scatter_add_(0, index, (label == output.max(1)[1]).float())

    accuracy = acc_nomin / acc_denom

    #pdb.set_trace()
    return accuracy.mean() 
Example #3
Source File: preprocessing_visitor.py    From rekall with GNU General Public License v2.0 6 votes vote down vote up
def visit_if(self, if_):
        # Select which of the conditional_blocks are valid. Choose the first one
        # which evaluates to non zero.
        for block in if_.conditional_blocks:
            # First expand all the macros in the condition.
            conditional_expression = self._macro_expander.expand(
                block.conditional_expression, eval_mode=True)

            expression = self._expression_parser.parse(conditional_expression)

            try:
                # Choose the block if the evaluator returns truth.
                if self._expression_evaluator.evaluate(expression):
                    return block.accept(self)
            except c_ast.IrreducibleFunction as e:
                print("Unable to evaluate conditional_expression: %s"
                      % block.conditional_expression)
                print("Expanded to: %s"
                      % conditional_expression)
                print("Error: %s" % e)
                import pdb
                pdb.set_trace() 
Example #4
Source File: pyparsing.py    From jbox with MIT License 6 votes vote down vote up
def setBreak(self,breakFlag = True):
        """Method to invoke the Python pdb debugger when this element is
           about to be parsed. Set C{breakFlag} to True to enable, False to
           disable.
        """
        if breakFlag:
            _parseMethod = self._parse
            def breaker(instring, loc, doActions=True, callPreParse=True):
                import pdb
                pdb.set_trace()
                return _parseMethod( instring, loc, doActions, callPreParse )
            breaker._originalParseMethod = _parseMethod
            self._parse = breaker
        else:
            if hasattr(self._parse,"_originalParseMethod"):
                self._parse = self._parse._originalParseMethod
        return self 
Example #5
Source File: metrics.py    From dogTorch with MIT License 6 votes vote down vote up
def get_angle_diff(self, target, result):
        size = target.size()
        sequence_length = size[1]
        all_averages = np.zeros((sequence_length)).astype(np.float)
        for seq_id in range(sequence_length):
            average = AverageMeter()
            for batch_id in range(size[0]):
                for imu_id in range(size[2]):
                    goal = Quaternion(target[batch_id, seq_id, imu_id])
                    out = Quaternion(result[batch_id, seq_id, imu_id])
                    acos = (2 * (np.dot(out.normalised.q, goal.normalised.q)**2)
                            - 1)
                    acos = round(acos, 6)
                    if acos > 1 or acos < -1:
                        pdb.set_trace()
                    radian = math.acos(acos)
                    average.update(radian)

            all_averages[seq_id] = (average.avg)

        return all_averages 
Example #6
Source File: mondrian.py    From Mondrian with MIT License 6 votes vote down vote up
def choose_dimension(partition):
    """
    choose dim with largest norm_width from all attributes.
    This function can be upgraded with other distance function.
    """
    max_width = -1
    max_dim = -1
    for dim in range(QI_LEN):
        if partition.allow[dim] == 0:
            continue
        norm_width = get_normalized_width(partition, dim)
        if norm_width > max_width:
            max_width = norm_width
            max_dim = dim
    if max_width > 1:
        pdb.set_trace()
    return max_dim 
Example #7
Source File: pyparsing.py    From jbox with MIT License 6 votes vote down vote up
def setBreak(self,breakFlag = True):
        """Method to invoke the Python pdb debugger when this element is
           about to be parsed. Set C{breakFlag} to True to enable, False to
           disable.
        """
        if breakFlag:
            _parseMethod = self._parse
            def breaker(instring, loc, doActions=True, callPreParse=True):
                import pdb
                pdb.set_trace()
                return _parseMethod( instring, loc, doActions, callPreParse )
            breaker._originalParseMethod = _parseMethod
            self._parse = breaker
        else:
            if hasattr(self._parse,"_originalParseMethod"):
                self._parse = self._parse._originalParseMethod
        return self 
Example #8
Source File: olmar.py    From fin with MIT License 6 votes vote down vote up
def rebalance_portfolio(context, data, weights):    
    
    desired_amount = np.zeros(np.shape(weights))
    current_amount = np.zeros(np.shape(weights))        
    prices = np.zeros(np.shape(weights))

    if context.init:
        positions_value = context.portfolio.starting_cash
    else:
        #total cash
        positions_value = context.portfolio.positions_value + context.portfolio.cash
    
    for i, stock in enumerate(context.stocks):
        current_amount[i] = context.portfolio.positions[stock].amount  #shares
        prices[i] = data[stock]['price'] #share price            

    context.prev_weights = weights
    desired_amount = np.round(weights * positions_value / prices)    #shares    
    diff_amount = desired_amount - current_amount

    #pdb.set_trace()        
    for i, sid in enumerate(context.sids):
        order(sid, +diff_amount[i]) 
Example #9
Source File: pyparsing.py    From vulscan with MIT License 6 votes vote down vote up
def setBreak(self,breakFlag = True):
        """Method to invoke the Python pdb debugger when this element is
           about to be parsed. Set C{breakFlag} to True to enable, False to
           disable.
        """
        if breakFlag:
            _parseMethod = self._parse
            def breaker(instring, loc, doActions=True, callPreParse=True):
                import pdb
                pdb.set_trace()
                return _parseMethod( instring, loc, doActions, callPreParse )
            breaker._originalParseMethod = _parseMethod
            self._parse = breaker
        else:
            if hasattr(self._parse,"_originalParseMethod"):
                self._parse = self._parse._originalParseMethod
        return self 
Example #10
Source File: tools.py    From OpenTrader with GNU Lesser General Public License v3.0 6 votes vote down vote up
def set_trace():
    """Call pdb.set_trace in the caller's frame.

    First restore sys.stdout and sys.stderr.  Note that the streams are
    NOT reset to whatever they were before the call once pdb is done!
    """
    import pdb
    for stream in 'stdout', 'stderr':
        output = getattr(sys, stream)
        orig_output = getattr(sys, '__%s__' % stream)
        if output != orig_output:
            # Flush the output before entering pdb
            if hasattr(output, 'getvalue'):
                orig_output.write(output.getvalue())
                orig_output.flush()
            setattr(sys, stream, orig_output)
    exc, tb = sys.exc_info()[1:]
    if tb:
        if isinstance(exc, AssertionError) and exc.args:
            # The traceback is not printed yet
            print_exc()
        pdb.post_mortem(tb)
    else:
        pdb.Pdb().set_trace(sys._getframe().f_back) 
Example #11
Source File: transforms_rbbox.py    From AerialDetection with Apache License 2.0 6 votes vote down vote up
def xy2wh_c(boxes):
    """

    :param boxes: (xmin, ymin, xmax, ymax) (n, 4 * #C)
    :return: out_boxes: (x_ctr, y_ctr, w, h) (n, 4 * #C)
    """
    num_boxes = boxes.size(0)
    out_boxes = boxes.clone()
    ex_widths = boxes[..., 2::4] - boxes[..., 0::4] + 1.0
    ex_heights = boxes[..., 3::4] - boxes[..., 1::4] + 1.0
    ex_ctr_x = boxes[..., 0::4] + 0.5 * (ex_widths - 1.0)
    ex_ctr_y = boxes[..., 1::4] + 0.5 * (ex_heights - 1.0)
    # import pdb; pdb.set_trace()
    out_boxes[..., 2::4] = ex_widths
    out_boxes[..., 3::4] = ex_heights
    out_boxes[..., 0::4] = ex_ctr_x
    out_boxes[..., 1::4] = ex_ctr_y

    return out_boxes 
Example #12
Source File: transforms_rbbox.py    From AerialDetection with Apache License 2.0 6 votes vote down vote up
def get_best_begin_point(coordinate_list):
    best_coordinate_list = map(get_best_begin_point_warp_single, coordinate_list)
    # import pdb
    # pdb.set_trace()
    best_coordinate_list = np.stack(list(best_coordinate_list))

    return best_coordinate_list

# def polygonToRotRectangle(polys):
#     """
#     pytorch version, batch operation
#     :param polys: The polygon stored in format [x1, y1, x2, y2, x3, y3, x4, y4]
#             shape [num_boxes, 8]
#     :return: Rotated Rectangle in format [cx, cy, w, h, theta]
#             shape [num_rot_recs, 5]
#     """
#     polys = polys.view(-1, 4, 2) 
Example #13
Source File: test_kitti.py    From DenseMatchingBenchmark with MIT License 6 votes vote down vote up
def setUp(self):
        config = dict(
            data=dict(
                test=dict(
                    type='KITTI-2015',
                    data_root='datasets/KITTI-2015/',
                    annfile='datasets/KITTI-2015/annotations/full_eval.json',
                    input_shape=[384, 1248],
                    mean=[0.485, 0.456, 0.406],
                    std=[0.229, 0.224, 0.225],
                    toRAM=False,
                )
            )
        )
        cfg = Config(config)
        self.dataset = build_dataset(cfg, 'test')

        import pdb
        pdb.set_trace() 
Example #14
Source File: transforms_rbbox.py    From AerialDetection with Apache License 2.0 6 votes vote down vote up
def best_match_dbbox2delta(Rrois, gt, means = [0, 0, 0, 0, 0], stds=[1, 1, 1, 1, 1]):
    """
    :param Rrois: (x_ctr, y_ctr, w, h, angle)
            shape (n, 5)
    :param gt: (x_ctr, y_ctr, w, h, angle)
    :param means:
    :param stds:
    :return: encoded targets: shape (n, 5)
    """
    # TODO: for comparision, dot not change the regression range for angle in 2 stage currently
    #  This is a simplified version
    # TODO: preprocess angle of gt_boxes according to the catogeries
    # Here, use a choose beste match angle, similar to choose best point instead
    gt_boxes_new = choose_best_match_batch(Rrois, gt)
    try:
        assert np.all(Rrois.cpu().numpy()[:, 4] <= (np.pi + 0.001))
    except:
        import pdb
        pdb.set_trace()
    bbox_targets = dbbox2delta_v2(Rrois, gt_boxes_new, means, stds)

    return bbox_targets

# TODO: check the negative situation of flip 
Example #15
Source File: pydebug.py    From kano-toolset with GNU General Public License v2.0 6 votes vote down vote up
def start_x(a, b):
    from pdb import Pdb
    import os
    from pty import openpty

    (master, slave) = openpty()
    cmd = "rxvt -pty-fd {} &".format(master)
    os.system(cmd)
    io = os.fdopen(slave, "r+b")
    Pdb(stdin=io, stdout=io).set_trace()


# set a handler on SIGUSR1. NB although all the above shoudln't really
# work as signal handlers, because they call system calls which you are
# not supposed to use in a handler, these are okay because in fact
# python is handling the signal in C then interpreting these 'handlers'
# outside the handler.

# To use: pydebug.patch_handler(pydebug.start_x) 
Example #16
Source File: nms.py    From AerialDetection with Apache License 2.0 6 votes vote down vote up
def obb_hybrid_NMS(thresh_obb, dets, thresh_hbb=0.5):
    """
    do nms on obbs by 1. corresponding hbbs on relative high thresh 2. then nms by obbs on obbs
    :param dets:
    :param thresh:
    :return:
    """
    # pdb.set_trace()
    h_dets = bbox_poly2hbb(dets)
    h_keep = py_cpu_nms(h_dets, thresh_hbb)

    h_keep = np.array(h_keep)

    keeped_o_dets = dets[h_keep, :]
    o_keep = py_cpu_nms_poly_fast(keeped_o_dets, thresh_obb)

    final_keep = h_keep[o_keep]

    return final_keep 
Example #17
Source File: rnms_wrapper.py    From AerialDetection with Apache License 2.0 6 votes vote down vote up
def bbox_poly2hbb(boxes):
    """
    with label
    :param boxes: (x1, y1, ... x4, y4, score) [n, 9]
    :return: hbb: (xmin, ymin, xmax, ymax, score) [n, 5]
    """
    n = boxes.shape[0]
    hbbs = np.zeros((n, 4))

    xs = np.reshape(boxes[:, : -1], (n, 4, 2))[:, :, 0]
    ys = np.reshape(boxes[:, : -1], (n, 4, 2))[:, :, 1]
    # pdb.set_trace()
    hbbs[:, 0] = np.min(xs, axis=1)
    hbbs[:, 1] = np.min(ys, axis=1)
    hbbs[:, 2] = np.max(xs, axis=1)
    hbbs[:, 3] = np.max(ys, axis=1)
    hbbs = np.hstack((hbbs, boxes[:, -1, np.newaxis]))
    return hbbs 
Example #18
Source File: evalcontext.py    From mishkal with GNU General Public License v3.0 6 votes vote down vote up
def exec_expr(self, s):
        out = StringIO()
        exec_lock.acquire()
        save_stdout = sys.stdout
        try:
            debugger = _OutputRedirectingPdb(save_stdout)
            debugger.reset()
            pdb.set_trace = debugger.set_trace
            sys.stdout = out
            try:
                code = compile(s, '<web>', "single", 0, 1)
                exec code in self.namespace, self.globs
                debugger.set_continue()
            except KeyboardInterrupt:
                raise
            except:
                traceback.print_exc(file=out)
                debugger.set_continue()
        finally:
            sys.stdout = save_stdout
            exec_lock.release()
        return out.getvalue()

# From doctest 
Example #19
Source File: mapillary_loader.py    From PLARD with MIT License 5 votes vote down vote up
def __getitem__(self, index):
        """__getitem__

        :param index:
        """

        #import pdb
        #pdb.set_trace()
        img_path = self.im_files[index].rstrip()
        lbl_path = os.path.join(self.annotations_base,
                                img_path.split(os.sep)[-1].split('.')[0] + '.png')

        img = cv2.imread(img_path)
        img = np.array(img, dtype=np.uint8)

        if self.phase == 'train':
            lbl = cv2.imread(lbl_path, cv2.IMREAD_UNCHANGED)
            lbl = np.array(lbl, dtype=np.uint8)
            #lbl = self.encode_segmap(np.array(lbl, dtype=np.uint8))
            
            #if self.augmentations is not None:
            #    img, lbl = self.augmentations(img, lbl)
            
            img, lbl = augmentation(img, lbl)

            #if self.is_transform:
            img, lbl = self.transform(img, lbl)

            if type(lbl) is list:
                for i in range(len(lbl)):
                    lbl[i][lbl[i] >= self.n_classes] = 255
            else:
                lbl[lbl >= self.n_classes] = 255

            #print('(%d,%d)-(%d,%d)'%(img.shape[1], img.shape[2], lbl.shape[0], lbl.shape[1]))
            return img, lbl
        else:
            img = cv2.resize(img, (1056,800))
            tr_img, _ = self.transform(img.copy(), lbl=None)
            return img, tr_img 
Example #20
Source File: geometry.py    From AerialDetection with Apache License 2.0 5 votes vote down vote up
def rbbox_overlaps_cy_warp(rbboxes, query_boxes):
    # TODO: first calculate the hbb overlaps, for overlaps > 0, calculate the obb overlaps
    # import pdb
    # pdb.set_trace()
    box_device = query_boxes.device
    query_boxes_np = query_boxes.cpu().numpy().astype(np.float)

    # polys_np = RotBox2Polys(boxes_np)
    # TODO: change it to only use pos gt_masks
    # polys_np = mask2poly(gt_masks)
    # polys_np = np.array(Tuplelist2Polylist(polys_np)).astype(np.float)

    polys_np = RotBox2Polys(rbboxes).astype(np.float)
    query_polys_np = RotBox2Polys(query_boxes_np)

    h_bboxes_np = poly2bbox(polys_np)
    h_query_bboxes_np = poly2bbox(query_polys_np)

    # hious
    ious = bbox_overlaps_cython(h_bboxes_np, h_query_bboxes_np)
    import pdb
    # pdb.set_trace()
    inds = np.where(ious > 0)
    for index in range(len(inds[0])):
        box_index = inds[0][index]
        query_box_index = inds[1][index]

        box = polys_np[box_index]
        query_box = query_polys_np[query_box_index]

        # calculate obb iou
        # import pdb
        # pdb.set_trace()
        overlap = polyiou.iou_poly(polyiou.VectorDouble(box), polyiou.VectorDouble(query_box))
        ious[box_index][query_box_index] = overlap

    return torch.from_numpy(ious).to(box_device) 
Example #21
Source File: convert.py    From PoseWarper with Apache License 2.0 5 votes vote down vote up
def from_old(cls, json_data):
        """Parse a dictionary representation from the PoseTrack17 format."""
        posetrack_filename = json_data["image"][0]["name"]
        assert len(json_data["image"]) == 1, "Invalid format!"
        old_seq_fp = path.basename(path.dirname(posetrack_filename))
        fp_wo_ending = path.basename(posetrack_filename).split(".")[0]
        if "_" in fp_wo_ending:
            fp_wo_ending = fp_wo_ending.split("_")[0]
        old_frame_id = int(fp_wo_ending)
        try:
            frame_id = posetrack18_fname2id(old_seq_fp, old_frame_id)
        except:  # pylint: disable=bare-except
            print("I stumbled over a strange sequence. Maybe you can have a look?")
            import pdb

            pdb.set_trace()  # pylint: disable=no-member
        image = Image(posetrack_filename, frame_id)
        for person_info in json_data["annorect"]:
            image.people.append(Person.from_old(person_info))
        if "ignore_regions" in json_data.keys():
            ignore_regions_x = []
            ignore_regions_y = []
            for ignore_region in json_data["ignore_regions"]:
                x_values = []
                y_values = []
                for point in ignore_region["point"]:
                    x_values.append(point["x"][0])
                    y_values.append(point["y"][0])
                ignore_regions_x.append(x_values)
                ignore_regions_y.append(y_values)
            image.ignore_regions = (ignore_regions_x, ignore_regions_y)
        return image 
Example #22
Source File: geometry.py    From AerialDetection with Apache License 2.0 5 votes vote down vote up
def rbbox_overlaps_cy(boxes_np, query_boxes_np):
    # TODO: first calculate the hbb overlaps, for overlaps > 0, calculate the obb overlaps

    polys_np = RotBox2Polys(boxes_np).astype(np.float)
    query_polys_np = RotBox2Polys(query_boxes_np).astype(np.float)

    h_bboxes_np = poly2bbox(polys_np).astype(np.float)
    h_query_bboxes_np = poly2bbox(query_polys_np).astype(np.float)

    # hious
    ious = bbox_overlaps_cython(h_bboxes_np, h_query_bboxes_np)
    import pdb
    # pdb.set_trace()
    inds = np.where(ious > 0)
    for index in range(len(inds[0])):
        box_index = inds[0][index]
        query_box_index = inds[1][index]

        box = polys_np[box_index]
        query_box = query_polys_np[query_box_index]

        # calculate obb iou
        # import pdb
        # pdb.set_trace()
        overlap = polyiou.iou_poly(polyiou.VectorDouble(box), polyiou.VectorDouble(query_box))
        ious[box_index][query_box_index] = overlap

    return ious 
Example #23
Source File: pydebug.py    From kano-toolset with GNU General Public License v2.0 5 votes vote down vote up
def start_term(a, b):
    import pdb
    pdb.set_trace()


# start the python debugger for remote connection on port 444
# needs pip install remote_pdb 
Example #24
Source File: wrapper_main.py    From workload-collocation-agent with Apache License 2.0 5 votes vote down vote up
def debug():
    """Debug hook to allow entering debug mode in compiled pex.
    Run it as PEX_MODULE=wrapper.wrapper_main:debug
    """
    import warnings
    try:
        import ipdb as pdb
    except ImportError:
        warnings.warn('ipdb not available, using pdb')
        import pdb
    pdb.set_trace()
    main() 
Example #25
Source File: pydebug.py    From kano-toolset with GNU General Public License v2.0 5 votes vote down vote up
def start_tty(a, b, tty="/dev/tty8"):
    from pdb import Pdb
    io = open(tty, "r+b")
    Pdb(stdin=io, stdout=io).set_trace()


# Start pdb in an rxvt on X 
Example #26
Source File: main.py    From workload-collocation-agent with Apache License 2.0 5 votes vote down vote up
def debug():
    """Debug hook to allow entering debug mode in compiled pex.
    Run it as PEX_MODULE=wca.main:debug
    """
    import warnings
    try:
        import ipdb as pdb
    except ImportError:
        warnings.warn('ipdb not available, using pdb')
        import pdb
    pdb.set_trace()
    main() 
Example #27
Source File: transforms_rbbox.py    From AerialDetection with Apache License 2.0 5 votes vote down vote up
def dbbox2delta_v3(proposals, gt, means = [0, 0, 0, 0, 0], stds=[1, 1, 1, 1, 1]):
    """
    This version removes the module operation
    :param proposals: (x_ctr, y_ctr, w, h, angle)
            shape (n, 5)
    :param gt: (x_ctr, y_ctr, w, h, angle)
    :param means:
    :param stds:
    :return: encoded targets: shape (n, 5)
    """
    proposals = proposals.float()
    gt = gt.float()
    gt_widths = gt[..., 2]
    gt_heights = gt[..., 3]
    gt_angle = gt[..., 4]

    proposals_widths = proposals[..., 2]
    proposals_heights = proposals[..., 3]
    proposals_angle = proposals[..., 4]

    coord = gt[..., 0:2] - proposals[..., 0:2]
    dx = (torch.cos(proposals[..., 4]) * coord[..., 0] +
          torch.sin(proposals[..., 4]) * coord[..., 1]) / proposals_widths
    dy = (-torch.sin(proposals[..., 4]) * coord[..., 0] +
          torch.cos(proposals[..., 4]) * coord[..., 1]) / proposals_heights
    dw = torch.log(gt_widths / proposals_widths)
    dh = torch.log(gt_heights / proposals_heights)
    # import pdb
    # print('in dbbox2delta v3')
    # pdb.set_trace()
    # dangle = (gt_angle - proposals_angle) % (2 * math.pi) / (2 * math.pi)
    # TODO: debug for it, proposals_angle are -1.5708, gt_angle should close to -1.57, actully they close to 5.0153
    dangle = gt_angle - proposals_angle
    deltas = torch.stack((dx, dy, dw, dh, dangle), -1)

    means = deltas.new_tensor(means).unsqueeze(0)
    stds = deltas.new_tensor(stds).unsqueeze(0)
    deltas = deltas.sub_(means).div_(stds)

    return deltas 
Example #28
Source File: edit_shapekey.py    From coa_tools with GNU General Public License v3.0 5 votes vote down vote up
def modal(self, context, event):
        obj = None
        obj_name = context.active_object.name if context.active_object != None else None
        obj = context.scene.objects[obj_name] if obj_name != None else None
        self.sprite_object = bpy.data.objects[self.sprite_object_name]
        self.armature = bpy.data.objects[self.armature_name]

        try:
            # used for debugging
            # if event.ctrl and event.type == "Z" and len(context.selected_objects) == 2:
            #     pdb.set_trace()

            if obj != None:
                if obj_name != self.last_obj_name:
                    if obj.type == "MESH":
                        self.set_most_driven_shapekey(obj)
                
                if obj.name not in self.objs and obj.type == "MESH":
                    self.objs.append(obj.name)
                if obj.type == "MESH" and obj.mode in ["OBJECT","WEIGHT_PAINT"]:
                    bpy.ops.object.mode_set(mode="SCULPT")
                
                if obj.type == "MESH" and obj.data.shape_keys != None:
                    if obj.coa_selected_shapekey != obj.active_shape_key.name:
                        obj.coa_selected_shapekey = str(obj.active_shape_key_index) #obj.active_shape_key.name
            
            if self.sprite_object.coa_edit_shapekey == False and obj != None:
                return self.exit_edit_mode(context,event,obj)
            
        except Exception as e:
            traceback.print_exc()
            self.report({"ERROR"},"An Error occured, please check console for more Information.")
            self.exit_edit_mode(context,event,obj)
        
        if obj_name != self.last_obj_name:
            self.last_obj_name = str(obj_name)
             
        return {"PASS_THROUGH"} 
Example #29
Source File: dev_appserver.py    From browserscope with Apache License 2.0 5 votes vote down vote up
def MonkeyPatchPdb(pdb):
  """Given a reference to the pdb module, fix its set_trace function.

  This will allow the standard trick of setting a breakpoint in your
  code by inserting a call to pdb.set_trace() to work properly, as
  long as the original stdin and stdout of dev_appserver.py are
  connected to a console or shell window.
  """

  def NewSetTrace():
    """Replacement for set_trace() that uses the original i/o streams.

    This is necessary because by the time the user code that might
    invoke pdb.set_trace() runs, the default sys.stdin and sys.stdout
    are redirected to the HTTP request and response streams instead,
    so that pdb will encounter garbage (or EOF) in its input, and its
    output will garble the HTTP response.  Fortunately, sys.__stdin__
    and sys.__stderr__ retain references to the original streams --
    this is a standard Python feature.  Also, fortunately, as of
    Python 2.5, the Pdb class lets you easily override stdin and
    stdout.  The original set_trace() function does essentially the
    same thing as the code here except it instantiates Pdb() without
    arguments.
    """
    p = pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__)
    p.set_trace(sys._getframe().f_back)

  pdb.set_trace = NewSetTrace 
Example #30
Source File: ResultMerge_multi_process.py    From AerialDetection with Apache License 2.0 5 votes vote down vote up
def mergebase_parallel(srcpath, dstpath, nms, nms_thresh):
    pool = Pool(16)
    filelist = util.GetFileFromThisRootDir(srcpath)

    mergesingle_fn = partial(mergesingle, dstpath, nms, nms_thresh)
    # pdb.set_trace()
    pool.map(mergesingle_fn, filelist)