Esempio n. 1
0
    def code_to_debug():
        import debuggee
        import debugpy
        import sys
        import time
        from debuggee import backchannel, scratchpad

        debuggee.setup()
        _, host, port, wait_for_client, is_client_connected, stop_method = sys.argv
        port = int(port)
        debugpy.listen(address=(host, port))

        if wait_for_client:
            backchannel.send("wait_for_client")
            debugpy.wait_for_client()

        if is_client_connected:
            backchannel.send("is_client_connected")
            while not debugpy.is_client_connected():
                print("looping until is_client_connected()")
                time.sleep(0.1)

        if stop_method == "breakpoint":
            backchannel.send("breakpoint?")
            assert backchannel.receive() == "proceed"
            debugpy.breakpoint()
            print("break")  # @breakpoint
        else:
            scratchpad["paused"] = False
            backchannel.send("loop?")
            assert backchannel.receive() == "proceed"
            while not scratchpad["paused"]:
                print("looping until paused")
                time.sleep(0.1)
Esempio n. 2
0
 def delete(self, person_id):
     import debugpy
     debugpy.breakpoint()
     person = {}
     person["PersonId"] = person_id
     result = self.executeQueryJson("delete", person)
     return result, 203
Esempio n. 3
0
    def code_to_debug():
        import debuggee
        import debugpy

        debuggee.setup()
        debugpy.breakpoint()
        print()
Esempio n. 4
0
def run_debugger():
    import debugpy
    # 5678 is the default attach port in the VS Code debug configurations. Unless a host and port are specified, host defaults to 127.0.0.1
    debugpy.listen(5678)
    print("Waiting for debugger attach")
    debugpy.wait_for_client()
    debugpy.breakpoint()
    print('break on this line')
def waitForClientConnect():
    try:
        import debugpy
        print("[PythonDebug] Waiting for a debugger client to connect")
        debugpy.wait_for_client()
        debugpy.breakpoint()
    except Exception as error:
        print("[PythonDebug] Failed wait for debugger client %s" % error)
Esempio n. 6
0
    def code_to_debug():
        import debuggee
        import debugpy
        from debuggee import backchannel

        debuggee.setup()
        a = 1
        debugpy.breakpoint()
        backchannel.send(a)
Esempio n. 7
0
    def code_to_debug():
        import debuggee
        import debugpy

        # Since Unicode variable name is a SyntaxError at parse time in Python 2,
        # this needs to do a roundabout way of setting it to avoid parse issues.
        globals()["\u16A0"] = 123
        debuggee.setup()
        debugpy.breakpoint()
        print("break")
Esempio n. 8
0
def password_generator(length):
    chars = string.ascii_letters + string.digits + string.punctuation
    confusing_chars = ('O', '0', '1', 'l')
    password = ''
    while not len(password) == length:
        char = random.choice(chars)
        debugpy.breakpoint()
        if char in confusing_chars:
            password += char
            debugpy.breakpoint()
    return password
Esempio n. 9
0
    def code_to_debug():
        import time
        import debuggee
        import debugpy
        from debuggee import scratchpad

        debuggee.setup()
        debugpy.breakpoint()
        object()  # @first

        scratchpad["exit"] = False
        while not scratchpad["exit"]:
            time.sleep(0.1)
            debugpy.breakpoint()
            object()  # @second
Esempio n. 10
0
    def _entry_debug_server(self):

        import debugpy
        debugpy.listen(self._endpoint)
        
        while self._running:
            debugpy.wait_for_client()
            debugpy.breakpoint()

            # While we are connected to the debugger, have the debug assistant
            # thread loop
            while debugpy.is_client_connected():
                time.sleep(2)

        return
Esempio n. 11
0
    def __call__(self, request):
        # debugpy.listen(("0.0.0.0", 5678))
        debugpy.listen(5678)
        debugpy.wait_for_client()
        debugpy.breakpoint()

        # Code to be executed for each request before
        # the view (and later middleware) are called.

        response = self.get_response(
            request
        )  # pass request to next middleware or view if this is the last middleware

        # Code to be executed for each request/response after
        # the view is called.

        return response
Esempio n. 12
0
    def __init__(self):
        if __code_debug__:
            try:
                import debugpy
                debugpy.listen(5678)
                print("Waiting for debugger attach")
                debugpy.wait_for_client()
                debugpy.breakpoint()
                print('break on this line')
            except ImportError:
                import ptvsd
                # 5678 is the default attach port in the VS Code debug configurations
                print("Waiting for debugger attach")
                ptvsd.enable_attach(address=('localhost', 5678), redirect_output=True)
                ptvsd.wait_for_attach()
                breakpoint()

        ## Call parent init
        super().__init__()
Esempio n. 13
0
def debugger_wellknown_breakpoint_entry(breakpoint_name: str):

    debugger = AKIT_VARIABLES.AKIT_DEBUGGER
    breakpoints = AKIT_VARIABLES.AKIT_BREAKPOINTS

    if breakpoint_name in breakpoints:
        if debugger == DEBUGGER.PDB:
            # The debug flag was passed on the commandline so we break here.'.format(current_indent))
            import pdb
            pdb.set_trace()
        elif debugger == DEBUGGER.DEBUGPY:
            logger.info("Waiting for debugger on port={}".format(DEFAULT_DEBUG_PORT))

            invscode = in_vscode_debugger()

            # The remote debug flag was passed on the commandline so we break here.'.format(current_indent))
            import debugpy
            if invscode:
                debugpy.listen(("0.0.0.0", DEFAULT_DEBUG_PORT))
                debugpy.wait_for_client()
            debugpy.breakpoint()
    return
Esempio n. 14
0
def which_type(el):
    """ This function is needed to control which arguments are passed further. """
    debugpy.breakpoint()
    if type(el) is 'str':                      # 1st line
        debugpy.breakpoint()
        print('The string has been given.')    # 2nd line
    else:                                      # 3rd line
        debugpy.breakpoint()
        print('Another type has been given.')  # 4th line
Esempio n. 15
0
def main():
    """Step main function
    """
    # can use Python logging
    logging.basicConfig(level=logging.INFO)
    log: logging.Logger = logging.getLogger(__name__)
    log.info("Basic step")

    # Retrieve current step's AML Run object
    aml_run = Run.get_context()

    # parse step arguments
    parser = argparse.ArgumentParser()
    # FileDataset argument
    parser.add_argument("--dataset", type=str, required=True)
    # debugging argument
    parser.add_argument('--is-debug', type=str, required=True)

    args, _ = parser.parse_known_args()

    # FileDataset is passed as a directory path
    dataset_directory_path = args.dataset

    if args.is_debug.lower() == 'true':
        print("Let's start debugging")
        if start_remote_debugging_from_args():
            debugpy.breakpoint()
            print("We are debugging!")
        else:
            print("Could not connect to a debugger!")

    # print to console output log (70_driver_log.txt)
    print(f"#### Dataset directory: {dataset_directory_path}")

    # log metrics in the current run
    aml_run.log(name="my string metric", value="magic value")
    aml_run.log(name="my numeric metric", value=42)
Esempio n. 16
0
def breakpoint():
    import debugpy
    debugpy.listen(5678)
    print("Waiting for debugger attach")
    debugpy.wait_for_client()
    debugpy.breakpoint()
Esempio n. 17
0
def debug():
    debugpy.listen(('0.0.0.0' , 5678))
    print("Waiting for debugger to attach")
    debugpy.wait_for_client()
    debugpy.breakpoint()
    print('break on this line')
Esempio n. 18
0
 def breakpoint(self):
     debugpy.breakpoint()
 def has_permission(self, request, view):
     debugpy.breakpoint()
     return super().has_permission(request, view)
def cb1(pressed):
    debugpy.breakpoint()
    if pressed:
        print("callback1: " + e1.txt)
 def authenticate(self, request):
     debugpy.breakpoint()
     return super().authenticate(request)
Esempio n. 22
0
def debugpy_breakpointhook():
    debugpy.breakpoint()
Esempio n. 23
0
def interface_console(cl_args=argv[1:]):
    """
    Run without gunicorn in development mode. 
    """

    parser = argparse.ArgumentParser(
        "Interface (screen, web, web-socket server) to TMV interface.")
    parser.add_argument('--log-level',
                        '-ll',
                        default='WARNING',
                        type=lambda s: LOG_LEVELS(s).name,
                        nargs='?',
                        choices=LOG_LEVELS.choices())
    parser.add_argument('--config-file',
                        '-cf',
                        default='/etc/tmv/' + CAMERA_CONFIG_FILE)
    parser.add_argument("--debug", default=False, action='store_true')
    args = parser.parse_args(cl_args)

    global interface  # pylint: disable=global-statement

    logging.basicConfig(format=LOG_FORMAT)
    logging.getLogger("tmv").setLevel(args.log_level)
    logging.getLogger('werkzeug').setLevel(
        logging.WARNING)  # turn off excessive logs (>=WARNING is ok)

    signal.signal(signal.SIGINT, stop_server)
    signal.signal(signal.SIGTERM, stop_server)

    try:
        if args.debug:
            debug_port = 5678
            debugpy.listen(("0.0.0.0", debug_port))
            print(f"Waiting for debugger attach on {debug_port}")
            debugpy.wait_for_client()
            debugpy.breakpoint()

        ensure_config_exists(args.config_file)
        LOGGER.info(f"Using config file: {Path(args.config_file).absolute()}")
        interface.config(args.config_file)

        # reset to cli values, which override config file
        if args.log_level != 'WARNING':  # str comparison
            logging.getLogger("tmv").setLevel(args.log_level)

        # let's roll!
        LOGGER.info(f"Starting socketio threads")
        start_socketio_threads()
        LOGGER.info(f"Starting flask and socketio at 0.0.0.0:{interface.port}")
        socketio.run(app,
                     host="0.0.0.0",
                     port=interface.port,
                     debug=(args.log_level == logging.DEBUG))

    except (FileNotFoundError, TomlDecodeError) as exc:
        LOGGER.debug(exc, exc_info=exc)
        print(exc, file=stderr)
        return 1
    except KeyboardInterrupt as exc:
        LOGGER.debug(exc, exc_info=exc)
        print(exc, file=stderr)
        return 0
    except Exception as exc:  # pylint: disable=broad-except
        LOGGER.debug(exc, exc_info=exc)
        print(exc, file=stderr)
        return 1
    finally:
        LOGGER.info("Stopping server and threads")
        # use a thread event?
        global shutdown  # pylint:disable = global-statement
        shutdown = True
        sleep(1)  # allow to stop nicely
        if interface:
            interface.stop()
        sleep(2)  # allow to stop nicely
Esempio n. 24
0
from sklearn import metrics
import tempfile
import pprint
import datetime
from torch.utils.tensorboard import SummaryWriter

import torch
from torch import nn
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader

# import ipdb
import sys
import debugpy
debugpy.wait_for_client()
debugpy.breakpoint()

sys.path.append("utils_temporal_nn")
from utils_nn import (
    load_data,
    neuron_ds,
    TrojNet,
    get_members_list,
    train_model,
    get_splits,
    get_splits_random,
    get_split_data,
    initialize_wandb,
    init_data_path,
    get_data_info,
)
Esempio n. 25
0
    def OpenPlugin(self, OpenFrom):
        if 0:
            import debugpy
            debugpy.breakpoint()
        symbols = []
        for i in range(256):
            symbols.append(chr(i))
        symbols.extend([
            "Ђ", "Ѓ", "‚", "ѓ", "„", "…", "†", "‡", "€", "‰", "Љ", "‹", "Њ", "Ќ", "Ћ", "Џ", "ђ", "‘", "’", "“", "”", "•", "–", "—", "˜", "™", "љ", "›", "њ", "ќ", "ћ", "џ",
            " ", "Ў", "ў", "Ј", "¤", "Ґ", "¦", "§", "Ё", "©", "Є", "«", "¬", "­", "®", "Ї", "°", "±", "І", "і", "ґ", "µ", "¶", "·", "ё", "№", "є", "»", "ј", "Ѕ", "ѕ", "ї",
            "А", "Б", "В", "Г", "Д", "Е", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ы", "Ь", "Э", "Ю", "Я",
            "а", "б", "в", "г", "д", "е", "ж", "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я",
            "░", "▒", "▓", "│", "┤", "╡", "╢", "╖", "╕", "╣", "║", "╗", "╝", "╜", "╛", "┐", "└", "┴", "┬", "├", "─", "┼", "╞", "╟", "╚", "╔", "╩", "╦", "╠", "═", "╬", "╧",
            "╨", "╤", "╥", "╙", "╘", "╒", "╓", "╫", "╪", "┘", "┌", "█", "▄", "▌", "▐", "▀", "∙", "√", "■", "⌠", "≈", "≤", "≥", "⌡", "²", "÷", "ą", "ć", "ę", "ł", "ń", "ó",
            "ś", "ż", "ź", "Ą", "Ć", "Ę", "Ł", "Ń", "Ó", "Ś", "Ż", "Ź", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
        ])
        Items = [
            (self.ffic.DI_DOUBLEBOX,   3,  1, 38, 18, 0, {'Selected':0}, 0, 0, self.s2f("Character Map"), 0),
            (self.ffic.DI_BUTTON,      7, 17, 12, 18, 0, {'Selected':0}, 1, self.ffic.DIF_DEFAULT + self.ffic.DIF_CENTERGROUP, self.s2f("OK"), 0),
            (self.ffic.DI_BUTTON,     13, 17, 38, 18, 0, {'Selected':0}, 0, self.ffic.DIF_CENTERGROUP, self.s2f("Cancel"), 0),
            (self.ffic.DI_USERCONTROL, 3,  2, 38, 16, 0, {'Selected':0}, 0, self.ffic.DIF_FOCUS, self.ffi.NULL, 0),
        ]
        self.cur_row = 0
        self.cur_col = 0
        self.max_col = 32
        self.max_row = len(symbols) // self.max_col
        self.first_text_item = len(Items)
        self.symbols = symbols
        self.text = None

        for i in range(len(symbols)):
            row = i // self.max_col
            col = i % self.max_col
            Items.append((self.ffic.DI_TEXT, 5+col, self.first_text_item-2+row, 5+col, self.first_text_item-2+row, 0, {'Selected':0}, 0, 0, self.ffi.NULL, 0))

        @self.ffi.callback("FARWINDOWPROC")
        def DialogProc(hDlg, Msg, Param1, Param2):
            if Msg == self.ffic.DN_INITDIALOG:
                self.Rebuild(hDlg)
                return self.info.DefDlgProc(hDlg, Msg, Param1, Param2)
            elif Msg == self.ffic.DN_BTNCLICK:
                return self.info.DefDlgProc(hDlg, Msg, Param1, Param2)
            elif Msg == self.ffic.DN_KEY and Param1 == self.first_text_item-1:
                log.debug('key DialogProc({0}, {1}, {2}, {3})'.format(hDlg, 'DN_KEY', Param1, Param2))
                if Param2 == self.ffic.KEY_LEFT:
                    self.cur_col -= 1
                elif Param2 == self.ffic.KEY_UP:
                    self.cur_row -= 1
                elif Param2 == self.ffic.KEY_RIGHT:
                    self.cur_col += 1
                elif Param2 == self.ffic.KEY_DOWN:
                    self.cur_row += 1
                elif Param2 == self.ffic.KEY_ENTER:
                    offset = self.cur_row*self.max_col+self.cur_col
                    self.text = self.symbols[offset]
                    log.debug('enter:{0} row:{1} col:{2}, ch:{3}'.format(offset, self.cur_row, self.cur_col, self.text))
                    return 0
                elif Param2 == self.ffic.KEY_ESC:
                    return 0
                else:
                    return self.info.DefDlgProc(hDlg, Msg, Param1, Param2)
                if self.cur_col == self.max_col:
                    self.cur_col = 0
                elif self.cur_col == -1:
                    self.cur_col = self.max_col - 1
                if self.cur_row == self.max_row:
                    self.cur_row = 0
                elif self.cur_row == -1:
                    self.cur_row = self.max_row - 1
                self.Rebuild(hDlg)
                return 1
            elif Msg == self.ffic.DN_MOUSECLICK:
                log.debug('mou DialogProc({0}, {1}, {2}, {3})'.format(hDlg, 'DN_MOUSECLICK', Param1, Param2))
                ch = Param1 - self.first_text_item
                if ch >= 0:
                    focus = self.info.SendDlgMessage(hDlg, self.ffic.DM_GETFOCUS, 0, 0)
                    log.debug('ch:{0} focus:{1}'.format(ch, focus))
                    if focus != self.first_text_item-1:
                        self.info.SendDlgMessage(hDlg, self.ffic.DM_SETFOCUS, self.first_text_item-1, 0)
                    self.cur_row = ch // self.max_col
                    self.cur_col = ch % self.max_col
                    self.cur_col = min(max(0, self.cur_col), self.max_col-1)
                    self.cur_row = min(max(0, self.cur_row), self.max_row-1)
                    offset = self.cur_row*self.max_col+self.cur_col
                    self.text = self.symbols[offset]
                    self.Rebuild(hDlg)
                    return 0
            return self.info.DefDlgProc(hDlg, Msg, Param1, Param2)

        fdi = self.ffi.new("struct FarDialogItem []", Items)
        hDlg = self.info.DialogInit(self.info.ModuleNumber, -1, -1, 42, 20, self.s2f("Character Map"), fdi, len(fdi), 0, 0, DialogProc, 0)
        res = self.info.DialogRun(hDlg)
        if res == 1:
            self.info.FSF.CopyToClipboard(self.s2f(self.text))
        self.info.DialogFree(hDlg)