コード例 #1
0
    def _set_debug_options(self, py_db, args):
        rules = args.get('rules')
        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server, lambda msg:self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        self._debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._debug_options['args'] = args

        debug_stdlib = self._debug_options.get('DEBUG_STDLIB', False)
        self.api.set_use_libraries_filter(py_db, not debug_stdlib)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)
コード例 #2
0
    def _set_debug_options(self, py_db, args):
        rules = args.get('rules')
        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server,
                lambda msg: self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        self._debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._debug_options['args'] = args

        debug_stdlib = self._debug_options.get('DEBUG_STDLIB', False)
        self.api.set_use_libraries_filter(py_db, not debug_stdlib)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)
コード例 #3
0
    def cmd_set_path_mapping_json(self, py_db, cmd_id, seq, text):
        '''
        :param text:
            Json text. Something as:

            {
                "pathMappings": [
                    {
                        "localRoot": "c:/temp",
                        "remoteRoot": "/usr/temp"
                    }
                ],
                "debug": true,
                "force": false
            }
        '''
        as_json = json.loads(text)
        force = as_json.get('force', False)

        path_mappings = []
        for pathMapping in as_json.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings) or force:
            pydevd_file_utils.setup_client_server_paths(path_mappings)

        debug = as_json.get('debug', False)
        if debug or force:
            pydevd_file_utils.DEBUG_CLIENT_SERVER_TRANSLATION = debug
コード例 #4
0
def test_source_reference(tmpdir):
    import pydevd_file_utils

    pydevd_file_utils.set_ide_os('WINDOWS')
    if IS_WINDOWS:
        # Client and server are on windows.
        pydevd_file_utils.setup_client_server_paths([('c:\\foo', 'c:\\bar')])

        assert pydevd_file_utils.map_file_to_client('c:\\bar\\my') == ('c:\\foo\\my', True)
        assert pydevd_file_utils.get_client_filename_source_reference('c:\\foo\\my') == 0

        assert pydevd_file_utils.map_file_to_client('c:\\another\\my') == ('c:\\another\\my', False)
        source_reference = pydevd_file_utils.get_client_filename_source_reference('c:\\another\\my')
        assert source_reference != 0
        assert pydevd_file_utils.get_server_filename_from_source_reference(source_reference) == 'c:\\another\\my'

    else:
        # Client on windows and server on unix
        pydevd_file_utils.set_ide_os('WINDOWS')

        pydevd_file_utils.setup_client_server_paths([('c:\\foo', '/bar')])

        assert pydevd_file_utils.map_file_to_client('/bar/my') == ('c:\\foo\\my', True)
        assert pydevd_file_utils.get_client_filename_source_reference('c:\\foo\\my') == 0

        assert pydevd_file_utils.map_file_to_client('/another/my') == ('\\another\\my', False)
        source_reference = pydevd_file_utils.get_client_filename_source_reference('\\another\\my')
        assert source_reference != 0
        assert pydevd_file_utils.get_server_filename_from_source_reference(source_reference) == '/another/my'
コード例 #5
0
def test_mapping_conflict_to_server():
    import pydevd_file_utils

    path_mappings = []
    for pathMapping in _MAPPING_CONFLICT_TO_SERVER:
        localRoot = pathMapping.get('localRoot', '')
        remoteRoot = pathMapping.get('remoteRoot', '')
        if (localRoot != '') and (remoteRoot != ''):
            path_mappings.append((localRoot, remoteRoot))

    pydevd_file_utils.setup_client_server_paths(path_mappings)

    assert pydevd_file_utils.map_file_to_server(
        '/opt/pathsomething/foo.py') == '/var/home/p2/foo.py'

    assert pydevd_file_utils.map_file_to_server(
        '/opt/v2/pathsomething/foo.py') == '/var/home/p4/foo.py'

    # This is an odd case, but the user didn't really put a slash in the end,
    # so, it's possible that this is what the user actually wants.
    assert pydevd_file_utils.map_file_to_server(
        '/opt/v2/path_r1/foo.py') == '/var/home/p3_r1/foo.py'

    # The client said both local and remote end with a slash, so, we can only
    # match it with the slash in the end.
    assert pydevd_file_utils.map_file_to_server(
        '/opt/pathsomething_foo.py') == '/opt/pathsomething_foo.py'
コード例 #6
0
    def optionalDebug(self, args):
        '''
        start the remote debugger if the arguments specify so
        
        Args:
            args(): The command line arguments
        '''
        if args.debugServer:
            import pydevd
            print(args.debugPathMapping, flush=True)
            if args.debugPathMapping:
                if len(args.debugPathMapping) == 2:
                    remotePath = args.debugPathMapping[
                        0]  # path on the remote debugger side
                    localPath = args.debugPathMapping[
                        1]  # path on the local machine where the code runs
                    MY_PATHS_FROM_ECLIPSE_TO_PYTHON = [
                        (remotePath, localPath),
                    ]
                    setup_client_server_paths(MY_PATHS_FROM_ECLIPSE_TO_PYTHON)
                    #os.environ["PATHS_FROM_ECLIPSE_TO_PYTHON"]='[["%s", "%s"]]' % (remotePath,localPath)
                    #print("trying to debug with PATHS_FROM_ECLIPSE_TO_PYTHON=%s" % os.environ["PATHS_FROM_ECLIPSE_TO_PYTHON"]);

            pydevd.settrace(args.debugServer,
                            port=args.debugPort,
                            stdoutToServer=True,
                            stderrToServer=True)
            print("command line args are: %s" % str(sys.argv))
コード例 #7
0
    def _set_debug_options(self, py_db, args, start_reason):
        rules = args.get('rules')
        stepping_resumes_all_threads = args.get('steppingResumesAllThreads',
                                                True)
        self.api.set_stepping_resumes_all_threads(
            py_db, stepping_resumes_all_threads)

        terminate_child_processes = args.get('terminateChildProcesses', True)
        self.api.set_terminate_child_processes(py_db,
                                               terminate_child_processes)

        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server,
                lambda msg: self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        self._debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._debug_options['args'] = args

        debug_stdlib = self._debug_options.get('DEBUG_STDLIB', False)
        self.api.set_use_libraries_filter(py_db, not debug_stdlib)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)

        if self._debug_options.get('REDIRECT_OUTPUT', False):
            py_db.enable_output_redirection(True, True)
        else:
            py_db.enable_output_redirection(False, False)

        self.api.set_show_return_values(
            py_db, self._debug_options.get('SHOW_RETURN_VALUE', False))

        if not self._debug_options.get('BREAK_SYSTEMEXIT_ZERO', False):
            ignore_system_exit_codes = [0]
            if self._debug_options.get('DJANGO_DEBUG', False):
                ignore_system_exit_codes += [3]

            self.api.set_ignore_system_exit_codes(py_db,
                                                  ignore_system_exit_codes)

        if self._debug_options.get('STOP_ON_ENTRY',
                                   False) and start_reason == 'launch':
            self.api.stop_on_entry()
コード例 #8
0
    def _set_debug_options(self, py_db, args, start_reason):
        rules = args.get('rules')
        stepping_resumes_all_threads = args.get('steppingResumesAllThreads',
                                                True)
        self.api.set_stepping_resumes_all_threads(
            py_db, stepping_resumes_all_threads)

        terminate_child_processes = args.get('terminateChildProcesses', True)
        self.api.set_terminate_child_processes(py_db,
                                               terminate_child_processes)

        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server,
                lambda msg: self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._options.update_fom_debug_options(debug_options)
        self._options.update_from_args(args)

        self.api.set_use_libraries_filter(py_db,
                                          not self._options.debug_stdlib)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)

        if self._options.redirect_output:
            py_db.enable_output_redirection(True, True)
        else:
            py_db.enable_output_redirection(False, False)

        self.api.set_show_return_values(py_db, self._options.show_return_value)

        if not self._options.break_system_exit_zero:
            ignore_system_exit_codes = [0]
            if self._options.django_debug:
                ignore_system_exit_codes += [3]

            self.api.set_ignore_system_exit_codes(py_db,
                                                  ignore_system_exit_codes)

        if self._options.stop_on_entry and start_reason == 'launch':
            self.api.stop_on_entry()
コード例 #9
0
ファイル: domotica_servidor.py プロジェクト: Veltys/RPPGCT
def main(argv):
    if DEBUG_REMOTO:
        setup_client_server_paths(config.PYDEV_REMOTE_PATHS)

        pydevd.settrace(config.IP_DEP_REMOTA, trace_only_current_thread=False)

    app = domotica_servidor(config, os.path.basename(sys.argv[0]))
    err = app.arranque()

    if err == 0:
        app.bucle()

    else:
        sys.exit(err)
コード例 #10
0
ファイル: reiniciar_router.py プロジェクト: Veltys/RPPGCT
def main(argv):
    if DEBUG_REMOTO:
        setup_client_server_paths(config.PYDEV_REMOTE_PATHS)

        pydevd.settrace(config.IP_DEP_REMOTA)

    app = reiniciar_router(config, os.path.basename(argv[0]))

    err = app.arranque()

    if err == 0:
        app.bucle()

    else:
        sys.exit(err)
コード例 #11
0
ファイル: domotica_cliente.py プロジェクト: Veltys/RPPGCT
def main(argv):
    if DEBUG_REMOTO:
        setup_client_server_paths(config.PYDEV_REMOTE_PATHS)

        pydevd.settrace(config.IP_DEP_REMOTA)

    app = domotica_cliente(config, argv)

    err = app.arranque()

    if err == 0:
        app.bucle()

    else:
        sys.exit(err)
コード例 #12
0
 def turnOnRemoteDebug( self ):
     # CANNOT RUN FROM HERE, YOU HAVE TO COPY THE CONTENT OF THIS FOLDER TO THE EXECUTABLE WHERE YOU RUN THE CODE AND RUN IT FROM THERE
     # THIS IS KEPT FOR CLEAN DOCUMENTATION PURPOSES
     # from pydevd_file_utils import setup_client_server_paths
     # server_path = '/root/nmr_pcb20_hdl10_2018/MAIN_nmr_code/'
     # client_path = 'D:\\GDrive\\WORKSPACES\\Eclipse_Python_2018\\RemoteSystemsTempFiles\\DAJO-DE1SOC\\root\\nmr_pcb20_hdl10_2018\\MAIN_nmr_code\\'
     # PATH_TRANSLATION = [(client_path, server_path)]
     # setup_client_server_paths(PATH_TRANSLATION)
     # pydevd.settrace("dajo-compaqsff")
     from pydevd_file_utils import setup_client_server_paths
     PATH_TRANSLATION = [( self.client_path, self.server_path )]
     setup_client_server_paths( PATH_TRANSLATION )
     print( "---server:%s---client:%s---" %
           ( self.server_ip, self.client_ip ) )
     pydevd.settrace( self.client_ip, stdoutToServer = True,
                     stderrToServer = True )
コード例 #13
0
    def _set_debug_options(self, py_db, args, start_reason):
        rules = args.get('rules')
        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server,
                lambda msg: self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        self._debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._debug_options['args'] = args

        debug_stdlib = self._debug_options.get('DEBUG_STDLIB', False)
        self.api.set_use_libraries_filter(py_db, not debug_stdlib)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)

        if self._debug_options.get('REDIRECT_OUTPUT', False):
            py_db.enable_output_redirection(True, True)
        else:
            py_db.enable_output_redirection(False, False)

        self.api.set_show_return_values(
            py_db, self._debug_options.get('SHOW_RETURN_VALUE', False))

        if self._debug_options.get('STOP_ON_ENTRY',
                                   False) and start_reason == 'launch':
            self.api.stop_on_entry()
コード例 #14
0
ファイル: sonda_dht11.py プロジェクト: Veltys/RPPGCT
def main(argv):
    if DEBUG_REMOTO:
        setup_client_server_paths(config.PYDEV_REMOTE_PATHS)

        pydevd.settrace(config.IP_DEP_REMOTA, trace_only_current_thread = False)

    app = sonda_dht11(config, os.path.basename(argv[0]))

    err = app.arranque()

    if err == 0:
        # Inicialización de los puertos GPIO, ya que no es posible hacerlo en el arranque
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.cleanup()

        app.argumentos(argv)
        app.bucle()

    else:
        sys.exit(err)
コード例 #15
0
    def _set_debug_options(self, py_db, args, start_reason):
        rules = args.get('rules')
        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server, lambda msg: self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        self._debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._debug_options['args'] = args

        debug_stdlib = self._debug_options.get('DEBUG_STDLIB', False)
        self.api.set_use_libraries_filter(py_db, not debug_stdlib)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)

        if self._debug_options.get('REDIRECT_OUTPUT', False):
            py_db.enable_output_redirection(True, True)
        else:
            py_db.enable_output_redirection(False, False)

        self.api.set_show_return_values(py_db, self._debug_options.get('SHOW_RETURN_VALUE', False))

        if self._debug_options.get('STOP_ON_ENTRY', False) and start_reason == 'launch':
            self.api.stop_on_entry()
コード例 #16
0
ファイル: correo_electronico.py プロジェクト: Veltys/RPPGCT
def mandar_correo(de, para, asunto, correo):
    if DEBUG_REMOTO:
        setup_client_server_paths(config.PYDEV_REMOTE_PATHS)

        pydevd.settrace(config.IP_DEP_REMOTA)

    mensaje             = MIMEText(correo)                                                  # Creación de un mensaje de correo en formato MIME
    mensaje['Subject']  = asunto
    mensaje['From']     = de
    mensaje['To']       = para

    try:                                                                                    # Bloque try
        s = SMTP(host = config.SERVIDOR)                                                    #     Conexión al servidor SMTP
        s.starttls(context = ssl.create_default_context())                                  #     Contexto SSL de seguridad
        s.login(config.USUARIO, config.CONTRASENYA)                                         #     Inicio de sesión

    except ConnectionRefusedError:                                                          # Rechazo de conexión por parte del servidor
        res = False

    except gaierror:                                                                        # Fallo de conectividad a Internet
        res = False

    except SMTPAuthenticationError:                                                         # Fallo de autenticación contra el servidor
        res = False

    else:                                                                                   # Si no hay excepciones
        s.send_message(mensaje)                                                             #     Envío del mensaje

        res = True

    finally:
        try:                                                                                # Bloque try
            if s:                                                                           #     Si el objeto existe y es válido
                s.quit()                                                                    #         Cierre de la sesión SMTP

        except UnboundLocalError:                                                           # Si el objeto no existe
            pass                                                                            #     No es necesaria ninguna operación adicional

    return res
コード例 #17
0
def test_to_server_and_to_client(tmpdir):
    try:

        def check(obtained, expected):
            assert obtained == expected
            assert isinstance(obtained, str)  # bytes on py2, unicode on py3
            assert isinstance(expected, str)  # bytes on py2, unicode on py3

        import pydevd_file_utils
        import sys
        if sys.platform == 'win32':
            # Check with made-up files

            # Client and server are on windows.
            pydevd_file_utils.set_ide_os('WINDOWS')
            in_eclipse = 'c:\\foo'
            in_python = 'c:\\bar'
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            check(pydevd_file_utils.norm_file_to_server('c:\\foo\\my'),
                  'c:\\bar\\my')
            check(
                pydevd_file_utils.norm_file_to_server(
                    'c:\\foo\\áéíóú'.upper()), 'c:\\bar\\áéíóú')
            check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'),
                  'c:\\foo\\my')

            # Client on unix and server on windows
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = 'c:\\bar'
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            check(pydevd_file_utils.norm_file_to_server('/foo/my'),
                  'c:\\bar\\my')
            check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'),
                  '/foo/my')

            # Test with 'real' files
            # Client and server are on windows.
            pydevd_file_utils.set_ide_os('WINDOWS')

            test_dir = str(tmpdir.mkdir("Foo"))
            os.makedirs(os.path.join(test_dir, "Another"))

            in_eclipse = os.path.join(os.path.dirname(test_dir), 'Bar')
            in_python = test_dir
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)

            assert pydevd_file_utils.norm_file_to_server(
                in_eclipse) == in_python.lower()
            found_in_eclipse = pydevd_file_utils.norm_file_to_client(in_python)
            assert found_in_eclipse.endswith('Bar')

            assert pydevd_file_utils.norm_file_to_server(
                os.path.join(in_eclipse,
                             'another')) == os.path.join(in_python,
                                                         'another').lower()
            found_in_eclipse = pydevd_file_utils.norm_file_to_client(
                os.path.join(in_python, 'another'))
            assert found_in_eclipse.endswith('Bar\\Another')

            # Client on unix and server on windows
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = test_dir
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                '/foo').lower() == in_python.lower()
            assert pydevd_file_utils.norm_file_to_client(
                in_python) == in_eclipse

            # Test without translation in place (still needs to fix case and separators)
            pydevd_file_utils.set_ide_os('WINDOWS')
            PATHS_FROM_ECLIPSE_TO_PYTHON = []
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                test_dir) == test_dir.lower()
            assert pydevd_file_utils.norm_file_to_client(test_dir).endswith(
                '\\Foo')

        else:
            # Client on windows and server on unix
            pydevd_file_utils.set_ide_os('WINDOWS')
            in_eclipse = 'c:\\foo'
            in_python = '/bar'
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                'c:\\foo\\my') == '/bar/my'
            assert pydevd_file_utils.norm_file_to_client(
                '/bar/my') == 'c:\\foo\\my'

            # Files for which there's no translation have only their separators updated.
            assert pydevd_file_utils.norm_file_to_client(
                '/usr/bin') == '\\usr\\bin'
            assert pydevd_file_utils.norm_file_to_server(
                '\\usr\\bin') == '/usr/bin'

            # Client and server on unix
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = '/bar'
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                '/foo/my') == '/bar/my'
            assert pydevd_file_utils.norm_file_to_client(
                '/bar/my') == '/foo/my'
    finally:
        pydevd_file_utils.setup_client_server_paths([])
コード例 #18
0
    def __init__( self, data_folder, en_remote_dbg ):
        # Output control signal to FPGA via I2C
        self.PSU_15V_TX_P_EN_ofst = ( 0 )
        self.PSU_15V_TX_N_EN_ofst = ( 1 )
        self.AMP_HP_LT1210_EN_ofst = ( 2 )
        self.PSU_5V_TX_N_EN_ofst = ( 3 )
        self.PAMP_IN_SEL_TEST_ofst = ( 4 )
        self.PAMP_IN_SEL_RX_ofst = ( 5 )
        self.GPIO_GEN_PURP_1_ofst = ( 6 )
        self.PSU_5V_ADC_EN_ofst = ( 7 )
        self.RX_AMP_GAIN_2_ofst = ( 8 )
        self.RX_AMP_GAIN_1_ofst = ( 9 )
        self.RX_AMP_GAIN_4_ofst = ( 10 )
        self.RX_AMP_GAIN_3_ofst = ( 11 )
        self.RX_IN_SEL_1_ofst = ( 12 )
        self.RX_IN_SEL_2_ofst = ( 13 )
        self.PSU_5V_ANA_P_EN_ofst = ( 14 )
        self.PSU_5V_ANA_N_EN_ofst = ( 15 )
        # Output control signal mask to FPGA via I2C
        self.PSU_15V_TX_P_EN_msk = ( 1 << self.PSU_15V_TX_P_EN_ofst )
        self.PSU_15V_TX_N_EN_msk = ( 1 << self.PSU_15V_TX_N_EN_ofst )
        self.AMP_HP_LT1210_EN_msk = ( 1 << self.AMP_HP_LT1210_EN_ofst )
        self.PSU_5V_TX_N_EN_msk = ( 1 << self.PSU_5V_TX_N_EN_ofst )
        self.PAMP_IN_SEL_TEST_msk = ( 1 << self.PAMP_IN_SEL_TEST_ofst )
        self.PAMP_IN_SEL_RX_msk = ( 1 << self.PAMP_IN_SEL_RX_ofst )
        self.GPIO_GEN_PURP_1_msk = ( 1 << self.GPIO_GEN_PURP_1_ofst )
        self.PSU_5V_ADC_EN_msk = ( 1 << self.PSU_5V_ADC_EN_ofst )
        self.RX_AMP_GAIN_2_msk = ( 1 << self.RX_AMP_GAIN_2_ofst )
        self.RX_AMP_GAIN_1_msk = ( 1 << self.RX_AMP_GAIN_1_ofst )
        self.RX_AMP_GAIN_4_msk = ( 1 << self.RX_AMP_GAIN_4_ofst )
        self.RX_AMP_GAIN_3_msk = ( 1 << self.RX_AMP_GAIN_3_ofst )
        self.RX_IN_SEL_1_msk = ( 1 << self.RX_IN_SEL_1_ofst )
        self.RX_IN_SEL_2_msk = ( 1 << self.RX_IN_SEL_2_ofst )
        self.PSU_5V_ANA_P_EN_msk = ( 1 << self.PSU_5V_ANA_P_EN_ofst )
        self.PSU_5V_ANA_N_EN_msk = ( 1 << self.PSU_5V_ANA_N_EN_ofst )

        # General control defaults for the FPGA
        self.gnrl_cnt = 0

        # Numeric conversion of the hardware
        self.pamp_gain_dB = 60  # preamp gain
        self.rx_gain_dB = 20  # rx amp gain
        self.totGain = 10 ** ( ( self.pamp_gain_dB + self.rx_gain_dB ) / 20 )
        self.uvoltPerDigit = 3.2 * ( 10 ** 6 ) / 16384  # ADC conversion, in microvolt
        self.fir_gain = 21513  # downconversion FIR filter gain (sum of all coefficients)
        self.dconv_gain = 0.707106781  # downconversion gain factor due to sine(45,135,225,315) multiplication

        # ip addresses settings for the system
        self.server_ip = '192.168.137.10'
        self.client_ip = '192.168.137.1'
        self.server_path = '/root/NMR_PCBv2_HDLv1_2018_PyDev/MAIN_nmr_code/'
        # client path with samba
        self.client_path = 'Z:\\NMR_PCBv2_HDLv1_2018_PyDev\\MAIN_nmr_code\\'

        if en_remote_dbg:
            from pydevd_file_utils import setup_client_server_paths
            PATH_TRANSLATION = [( self.client_path, self.server_path )]
            setup_client_server_paths( PATH_TRANSLATION )
            print( "---server:%s---client:%s---" %
                  ( self.server_ip, self.client_ip ) )
            pydevd.settrace( self.client_ip, stdoutToServer = True,
                            stderrToServer = True )

        # variables
        self.data_folder = data_folder
        self.exec_folder = "/c_exec/"

        # directories
        self.work_dir = os.getcwd()
        # only do this after remote debug initialization
        os.chdir( self.data_folder )
コード例 #19
0
    def __init__(self, data_folder, en_remote_dbg):
        self.PCBVer = 'v5.0'  # options are v4.0_and_below, v5.0

        if self.PCBVer == 'v4.0_and_below':
            # Output control signal to FPGA via I2C
            self.PSU_15V_TX_P_EN_ofst = (0)
            self.PSU_15V_TX_N_EN_ofst = (1)
            self.AMP_HP_LT1210_EN_ofst = (2)
            self.PSU_5V_TX_N_EN_ofst = (3)
            self.PAMP_IN_SEL_TEST_ofst = (4)
            self.PAMP_IN_SEL_RX_ofst = (5)
            self.GPIO_GEN_PURP_1_ofst = (6)
            self.PSU_5V_ADC_EN_ofst = (7)
            self.RX_AMP_GAIN_2_ofst = (8)
            self.RX_AMP_GAIN_1_ofst = (9)
            self.RX_AMP_GAIN_4_ofst = (10)
            self.RX_AMP_GAIN_3_ofst = (11)
            self.RX_IN_SEL_1_ofst = (12)
            self.RX_IN_SEL_2_ofst = (13)
            self.PSU_5V_ANA_P_EN_ofst = (14)
            self.PSU_5V_ANA_N_EN_ofst = (15)
            # Output control signal mask to FPGA via I2C
            self.PSU_15V_TX_P_EN_msk = (1 << self.PSU_15V_TX_P_EN_ofst)
            self.PSU_15V_TX_N_EN_msk = (1 << self.PSU_15V_TX_N_EN_ofst)
            self.AMP_HP_LT1210_EN_msk = (1 << self.AMP_HP_LT1210_EN_ofst)
            self.PSU_5V_TX_N_EN_msk = (1 << self.PSU_5V_TX_N_EN_ofst)
            self.PAMP_IN_SEL_TEST_msk = (1 << self.PAMP_IN_SEL_TEST_ofst)
            self.PAMP_IN_SEL_RX_msk = (1 << self.PAMP_IN_SEL_RX_ofst)
            self.GPIO_GEN_PURP_1_msk = (1 << self.GPIO_GEN_PURP_1_ofst)
            self.PSU_5V_ADC_EN_msk = (1 << self.PSU_5V_ADC_EN_ofst)
            self.RX_AMP_GAIN_2_msk = (1 << self.RX_AMP_GAIN_2_ofst)
            self.RX_AMP_GAIN_1_msk = (1 << self.RX_AMP_GAIN_1_ofst)
            self.RX_AMP_GAIN_4_msk = (1 << self.RX_AMP_GAIN_4_ofst)
            self.RX_AMP_GAIN_3_msk = (1 << self.RX_AMP_GAIN_3_ofst)
            self.RX_IN_SEL_1_msk = (1 << self.RX_IN_SEL_1_ofst)
            self.RX_IN_SEL_2_msk = (1 << self.RX_IN_SEL_2_ofst)
            self.PSU_5V_ANA_P_EN_msk = (1 << self.PSU_5V_ANA_P_EN_ofst)
            self.PSU_5V_ANA_N_EN_msk = (1 << self.PSU_5V_ANA_N_EN_ofst)

        elif self.PCBVer == 'v5.0':
            # chip offset declaration (look at the KiCAD for the designated
            # chip name)
            self.i2c_U21_ofst = 0
            self.i2c_U71_ofst = 16
            self.spi_pamp_U32 = 32

            # Output control signal to FPGA via I2C addr:0x40
            self.RX_FL_ofst = (0 + self.i2c_U21_ofst)
            self.RX_FH_ofst = (1 + self.i2c_U21_ofst)
            self.RX_SEL2_ofst = (2 + self.i2c_U21_ofst)
            self.RX_SEL1_ofst = (3 + self.i2c_U21_ofst)
            self.RX3_L_ofst = (4 + self.i2c_U21_ofst)
            self.RX3_H_ofst = (5 + self.i2c_U21_ofst)
            self.RX1_2L_ofst = (6 + self.i2c_U21_ofst)
            self.RX1_2H_ofst = (7 + self.i2c_U21_ofst)
            # self.___(8 + self.i2c_U21_ofst)
            # self.___(9 + self.i2c_U21_ofst)
            # self.___(10 + self.i2c_U21_ofst)
            self.PAMP_RDY_ofst = (11 + self.i2c_U21_ofst)
            self.RX1_1H_ofst = (12 + self.i2c_U21_ofst)
            self.RX1_1L_ofst = (13 + self.i2c_U21_ofst)
            self.RX2_H_ofst = (14 + self.i2c_U21_ofst)
            self.RX2_L_ofst = (15 + self.i2c_U21_ofst)

            self.RX_FL_msk = (1 << self.RX_FL_ofst)
            self.RX_FH_msk = (1 << self.RX_FH_ofst)
            self.RX_SEL2_msk = (1 << self.RX_SEL2_ofst)
            self.RX_SEL1_msk = (1 << self.RX_SEL1_ofst)
            self.RX3_L_msk = (1 << self.RX3_L_ofst)
            self.RX3_H_msk = (1 << self.RX3_H_ofst)
            self.RX1_2L_msk = (1 << self.RX1_2L_ofst)
            self.RX1_2H_msk = (1 << self.RX1_2H_ofst)
            # self.___(8)
            # self.___(9)
            # self.___(10)
            self.PAMP_RDY_msk = (1 << self.PAMP_RDY_ofst)
            self.RX1_1H_msk = (1 << self.RX1_1H_ofst)
            self.RX1_1L_msk = (1 << self.RX1_1L_ofst)
            self.RX2_H_msk = (1 << self.RX2_H_ofst)
            self.RX2_L_msk = (1 << self.RX2_L_ofst)

            # Output control signal to FPGA via I2C addr:0x41
            # self.___(0 + self.i2c_U71_ofst)
            # self.___(1 + self.i2c_U71_ofst)
            # self.___(2 + self.i2c_U71_ofst)
            # self.___(3 + self.i2c_U71_ofst)
            # self.___(4 + self.i2c_U71_ofst)
            # self.___(5 + self.i2c_U71_ofst)
            self.DUP_STAT_ofst = (6 + self.i2c_U71_ofst)
            self.QSW_STAT_ofst = (7 + self.i2c_U71_ofst)
            self.PSU_5V_ADC_EN_ofst = (8 + self.i2c_U71_ofst)
            self.PSU_5V_ANA_N_EN_ofst = (9 + self.i2c_U71_ofst)
            self.PSU_5V_ANA_P_EN_ofst = (10 + self.i2c_U71_ofst)
            self.MTCH_NTWRK_RST_ofst = (11 + self.i2c_U71_ofst)
            self.PSU_15V_TX_P_EN_ofst = (12 + self.i2c_U71_ofst)
            self.PSU_15V_TX_N_EN_ofst = (13 + self.i2c_U71_ofst)
            self.PSU_5V_TX_N_EN_ofst = (14 + self.i2c_U71_ofst)
            # self.___(15 + self.i2c_U71_ofst)
            # self.___(0 + 16)
            # self.___(1 + 16)
            # self.___(2 + 16)
            # self.___(3 + 16)
            # self.___(4 + 16)
            # self.___(5 + 16)
            self.DUP_STAT_msk = (1 << self.DUP_STAT_ofst)
            self.QSW_STAT_msk = (1 << self.QSW_STAT_ofst)
            self.PSU_5V_ADC_EN_msk = (1 << self.PSU_5V_ADC_EN_ofst)
            self.PSU_5V_ANA_N_EN_msk = (1 << self.PSU_5V_ANA_N_EN_ofst)
            self.PSU_5V_ANA_P_EN_msk = (1 << self.PSU_5V_ANA_P_EN_ofst)
            self.MTCH_NTWRK_RST_msk = (1 << self.MTCH_NTWRK_RST_ofst)
            self.PSU_15V_TX_P_EN_msk = (1 << self.PSU_15V_TX_P_EN_ofst)
            self.PSU_15V_TX_N_EN_msk = (1 << self.PSU_15V_TX_N_EN_ofst)
            self.PSU_5V_TX_N_EN_msk = (1 << self.PSU_5V_TX_N_EN_ofst)
            # self.___(15 + 16)

            # definition for spi pamp input control
            self.PAMP_IN_SEL1_ofst = (2 + self.spi_pamp_U32)
            self.PAMP_IN_SEL2_ofst = (3 + self.spi_pamp_U32)
            self.PAMP_IN_SEL1_msk = (1 << self.PAMP_IN_SEL1_ofst)
            self.PAMP_IN_SEL2_msk = (1 << self.PAMP_IN_SEL2_ofst)

        # General control defaults for the FPGA
        self.gnrl_cnt = 0

        # ip addresses settings for the system
        self.server_ip = '192.168.137.10'  # '129.22.143.88'
        self.client_ip = '192.168.137.1'  # '129.22.143.39'
        self.server_path = '/root/nmr_pcb20_hdl10_2018/MAIN_nmr_code/'
        # client path with samba
        self.client_path = 'Z:\\nmr_pcb20_hdl10_2018\\MAIN_nmr_code\\'

        if en_remote_dbg:
            from pydevd_file_utils import setup_client_server_paths
            PATH_TRANSLATION = [(self.client_path, self.server_path)]
            setup_client_server_paths(PATH_TRANSLATION)
            print("---server:%s---client:%s---" %
                  (self.server_ip, self.client_ip))
            pydevd.settrace(self.client_ip, stdoutToServer=True,
                            stderrToServer=True)

        # variables
        self.data_folder = data_folder
        self.exec_folder = "/c_exec/"

        # directories
        self.work_dir = os.getcwd()
        # only do this after remote debug initialization
        os.chdir(self.data_folder)
コード例 #20
0
def test_to_server_and_to_client(tmpdir):
    try:

        def check(obtained, expected):
            assert obtained == expected, '%s (%s) != %s (%s)' % (obtained, type(obtained), expected, type(expected))
            if isinstance(obtained, tuple):
                assert isinstance(obtained[0], str)  # bytes on py2, unicode on py3
            else:
                assert isinstance(obtained, str)  # bytes on py2, unicode on py3

            if isinstance(expected, tuple):
                assert isinstance(expected[0], str)  # bytes on py2, unicode on py3
            else:
                assert isinstance(expected, str)  # bytes on py2, unicode on py3

        import pydevd_file_utils
        if IS_WINDOWS:
            # Check with made-up files

            pydevd_file_utils.setup_client_server_paths([('c:\\foo', 'c:\\bar'), ('c:\\foo2', 'c:\\bar2')])

            stream = io.StringIO()
            with log_context(0, stream=stream):
                pydevd_file_utils.map_file_to_server('y:\\only_exists_in_client_not_in_server')
            assert r'pydev debugger: unable to find translation for: "y:\only_exists_in_client_not_in_server" in ["c:\foo", "c:\foo2"] (please revise your path mappings).' in stream.getvalue()

            # Client and server are on windows.
            pydevd_file_utils.set_ide_os('WINDOWS')
            for in_eclipse, in_python  in ([
                    ('c:\\foo', 'c:\\bar'),
                    ('c:/foo', 'c:\\bar'),
                    ('c:\\foo', 'c:/bar'),
                    ('c:\\foo', 'c:\\bar\\'),
                    ('c:/foo', 'c:\\bar\\'),
                    ('c:\\foo', 'c:/bar/'),
                    ('c:\\foo\\', 'c:\\bar'),
                    ('c:/foo/', 'c:\\bar'),
                    ('c:\\foo\\', 'c:/bar'),

                ]):
                PATHS_FROM_ECLIPSE_TO_PYTHON = [
                    (in_eclipse, in_python)
                ]
                pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
                check(pydevd_file_utils.map_file_to_server('c:\\foo\\my'), 'c:\\bar\\my')
                check(pydevd_file_utils.map_file_to_server('c:/foo/my'), 'c:\\bar\\my')
                check(pydevd_file_utils.map_file_to_server('c:/foo/my/'), 'c:\\bar\\my')
                check(pydevd_file_utils.map_file_to_server('c:\\foo\\áéíóú'.upper()), 'c:\\bar' + '\\áéíóú'.upper())
                check(pydevd_file_utils.map_file_to_client('c:\\bar\\my'), ('c:\\foo\\my', True))

            # Client on unix and server on windows
            pydevd_file_utils.set_ide_os('UNIX')
            for in_eclipse, in_python  in ([
                    ('/foo', 'c:\\bar'),
                    ('/foo', 'c:/bar'),
                    ('/foo', 'c:\\bar\\'),
                    ('/foo', 'c:/bar/'),
                    ('/foo/', 'c:\\bar'),
                    ('/foo/', 'c:\\bar\\'),
                ]):

                PATHS_FROM_ECLIPSE_TO_PYTHON = [
                    (in_eclipse, in_python)
                ]
                pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
                check(pydevd_file_utils.map_file_to_server('/foo/my'), 'c:\\bar\\my')
                check(pydevd_file_utils.map_file_to_client('c:\\bar\\my'), ('/foo/my', True))
                check(pydevd_file_utils.map_file_to_client('c:\\bar\\my\\'), ('/foo/my', True))
                check(pydevd_file_utils.map_file_to_client('c:/bar/my'), ('/foo/my', True))
                check(pydevd_file_utils.map_file_to_client('c:/bar/my/'), ('/foo/my', True))

            # Test with 'real' files
            # Client and server are on windows.
            pydevd_file_utils.set_ide_os('WINDOWS')

            test_dir = str(tmpdir.mkdir("Foo"))
            os.makedirs(os.path.join(test_dir, "Another"))

            in_eclipse = os.path.join(os.path.dirname(test_dir), 'Bar')
            in_python = test_dir
            PATHS_FROM_ECLIPSE_TO_PYTHON = [
                (in_eclipse, in_python)
            ]
            pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)

            assert pydevd_file_utils.map_file_to_server(in_eclipse) == in_python.lower()
            found_in_eclipse = pydevd_file_utils.map_file_to_client(in_python)[0]
            assert found_in_eclipse.endswith('Bar')

            assert pydevd_file_utils.map_file_to_server(
                os.path.join(in_eclipse, 'another')) == os.path.join(in_python, 'another').lower()
            found_in_eclipse = pydevd_file_utils.map_file_to_client(
                os.path.join(in_python, 'another'))[0]
            assert found_in_eclipse.endswith('Bar\\Another')

            # Client on unix and server on windows
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = test_dir
            PATHS_FROM_ECLIPSE_TO_PYTHON = [
                (in_eclipse, in_python)
            ]
            pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.map_file_to_server('/foo').lower() == in_python.lower()
            assert pydevd_file_utils.map_file_to_client(in_python) == (in_eclipse, True)

            # Test without translation in place (still needs to fix case and separators)
            pydevd_file_utils.set_ide_os('WINDOWS')
            PATHS_FROM_ECLIPSE_TO_PYTHON = []
            pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.map_file_to_server(test_dir) == test_dir
            assert pydevd_file_utils.map_file_to_client(test_dir.lower())[0].endswith('\\Foo')
        else:
            # Client on windows and server on unix
            pydevd_file_utils.set_ide_os('WINDOWS')

            PATHS_FROM_ECLIPSE_TO_PYTHON = [
                ('c:\\BAR', '/bar')
            ]

            pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.map_file_to_server('c:\\bar\\my') == '/bar/my'
            assert pydevd_file_utils.map_file_to_client('/bar/my') == ('c:\\BAR\\my', True)

            for in_eclipse, in_python  in ([
                    ('c:\\foo', '/báéíóúr'),
                    ('c:/foo', '/báéíóúr'),
                    ('c:/foo/', '/báéíóúr'),
                    ('c:/foo/', '/báéíóúr/'),
                    ('c:\\foo\\', '/báéíóúr/'),
                ]):

                PATHS_FROM_ECLIPSE_TO_PYTHON = [
                    (in_eclipse, in_python)
                ]

                pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
                assert pydevd_file_utils.map_file_to_server('c:\\foo\\my') == '/báéíóúr/my'
                assert pydevd_file_utils.map_file_to_server('C:\\foo\\my') == '/báéíóúr/my'
                assert pydevd_file_utils.map_file_to_server('C:\\foo\\MY') == '/báéíóúr/MY'
                assert pydevd_file_utils.map_file_to_server('C:\\foo\\MY\\') == '/báéíóúr/MY'
                assert pydevd_file_utils.map_file_to_server('c:\\foo\\my\\file.py') == '/báéíóúr/my/file.py'
                assert pydevd_file_utils.map_file_to_server('c:\\foo\\my\\other\\file.py') == '/báéíóúr/my/other/file.py'
                assert pydevd_file_utils.map_file_to_server('c:/foo/my') == '/báéíóúr/my'
                assert pydevd_file_utils.map_file_to_server('c:\\foo\\my\\') == '/báéíóúr/my'
                assert pydevd_file_utils.map_file_to_server('c:/foo/my/') == '/báéíóúr/my'

                assert pydevd_file_utils.map_file_to_client('/báéíóúr/my') == ('c:\\foo\\my', True)
                assert pydevd_file_utils.map_file_to_client('/báéíóúr/my/') == ('c:\\foo\\my', True)

                # Files for which there's no translation have only their separators updated.
                assert pydevd_file_utils.map_file_to_client('/usr/bin/x.py') == ('\\usr\\bin\\x.py', False)
                assert pydevd_file_utils.map_file_to_client('/usr/bin') == ('\\usr\\bin', False)
                assert pydevd_file_utils.map_file_to_client('/usr/bin/') == ('\\usr\\bin', False)
                assert pydevd_file_utils.map_file_to_server('\\usr\\bin') == '/usr/bin'
                assert pydevd_file_utils.map_file_to_server('\\usr\\bin\\') == '/usr/bin'

                # When we have a client file and there'd be no translation, and making it absolute would
                # do something as '$cwd/$file_received' (i.e.: $cwd/c:/another in the case below),
                # warn the user that it's not correct and the path that should be translated instead
                # and don't make it absolute.
                assert pydevd_file_utils.map_file_to_server('c:\\Another') == 'c:/Another'

                assert pydevd_file_utils.map_file_to_server('c:/FoO/my/BAR') == '/báéíóúr/my/BAR'
                assert pydevd_file_utils.map_file_to_client('/báéíóúr/my/BAR') == ('c:\\foo\\my\\BAR', True)

            # Client and server on unix
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = '/báéíóúr'
            PATHS_FROM_ECLIPSE_TO_PYTHON = [
                (in_eclipse, in_python)
            ]
            pydevd_file_utils.setup_client_server_paths(PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.map_file_to_server('/foo/my') == '/báéíóúr/my'
            assert pydevd_file_utils.map_file_to_client('/báéíóúr/my') == ('/foo/my', True)
    finally:
        pydevd_file_utils.setup_client_server_paths([])
コード例 #21
0
    def _set_debug_options(self, py_db, args, start_reason):
        rules = args.get('rules')
        stepping_resumes_all_threads = args.get('steppingResumesAllThreads', True)
        self.api.set_stepping_resumes_all_threads(py_db, stepping_resumes_all_threads)

        terminate_child_processes = args.get('terminateChildProcesses', True)
        self.api.set_terminate_child_processes(py_db, terminate_child_processes)

        variable_presentation = args.get('variablePresentation', None)
        if isinstance(variable_presentation, dict):

            def get_variable_presentation(setting, default):
                value = variable_presentation.get(setting, default)
                if value not in ('group', 'inline', 'hide'):
                    pydev_log.info(
                        'The value set for "%s" (%s) in the variablePresentation is not valid. Valid values are: "group", "inline", "hide"' % (
                            setting, value,))
                    value = default

                return value

            default = get_variable_presentation('all', 'group')

            special_presentation = get_variable_presentation('special', default)
            function_presentation = get_variable_presentation('function', default)
            class_presentation = get_variable_presentation('class', default)
            protected_presentation = get_variable_presentation('protected', default)

            self.api.set_variable_presentation(py_db, self.api.VariablePresentation(
                special_presentation,
                function_presentation,
                class_presentation,
                protected_presentation
            ))

        exclude_filters = []

        if rules is not None:
            exclude_filters = _convert_rules_to_exclude_filters(
                rules, self.api.filename_to_server, lambda msg: self.api.send_error_message(py_db, msg))

        self.api.set_exclude_filters(py_db, exclude_filters)

        debug_options = _extract_debug_options(
            args.get('options'),
            args.get('debugOptions'),
        )
        self._options.update_fom_debug_options(debug_options)
        self._options.update_from_args(args)

        self.api.set_use_libraries_filter(py_db, self._options.just_my_code)

        path_mappings = []
        for pathMapping in args.get('pathMappings', []):
            localRoot = pathMapping.get('localRoot', '')
            remoteRoot = pathMapping.get('remoteRoot', '')
            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
            if (localRoot != '') and (remoteRoot != ''):
                path_mappings.append((localRoot, remoteRoot))

        if bool(path_mappings):
            pydevd_file_utils.setup_client_server_paths(path_mappings)

        if self._options.redirect_output:
            py_db.enable_output_redirection(True, True)
        else:
            py_db.enable_output_redirection(False, False)

        self.api.set_show_return_values(py_db, self._options.show_return_value)

        if not self._options.break_system_exit_zero:
            ignore_system_exit_codes = [0]
            if self._options.django_debug:
                ignore_system_exit_codes += [3]

            self.api.set_ignore_system_exit_codes(py_db, ignore_system_exit_codes)

        if self._options.stop_on_entry and start_reason == 'launch':
            self.api.stop_on_entry()
コード例 #22
0
    def __init__(self, client_data_folder, en_remote_dbg, en_remote_computing):

        # chip offset declaration (look at the KiCAD for the designated
        # chip name)
        self.i2c_U21_ofst = 0
        self.i2c_U71_ofst = 16
        self.spi_pamp_U32 = 32

        # Output control signal to FPGA via I2C addr:0x40
        self.RX_FL_ofst = (0 + self.i2c_U21_ofst)
        self.RX_FH_ofst = (1 + self.i2c_U21_ofst)
        self.RX_SEL2_ofst = (2 + self.i2c_U21_ofst)
        self.RX_SEL1_ofst = (3 + self.i2c_U21_ofst)
        self.RX3_L_ofst = (4 + self.i2c_U21_ofst)
        self.RX3_H_ofst = (5 + self.i2c_U21_ofst)
        self.RX1_2L_ofst = (6 + self.i2c_U21_ofst)
        self.RX1_2H_ofst = (7 + self.i2c_U21_ofst)
        # self.___(8 + self.i2c_U21_ofst)
        # self.___(9 + self.i2c_U21_ofst)
        # self.___(10 + self.i2c_U21_ofst)
        # self.PAMP_RDY_ofst = (11 + self.i2c_U21_ofst)
        self.RX1_1H_ofst = (12 + self.i2c_U21_ofst)
        self.RX1_1L_ofst = (13 + self.i2c_U21_ofst)
        self.RX2_H_ofst = (14 + self.i2c_U21_ofst)
        self.RX2_L_ofst = (15 + self.i2c_U21_ofst)

        self.RX_FL_msk = (1 << self.RX_FL_ofst)
        self.RX_FH_msk = (1 << self.RX_FH_ofst)
        self.RX_SEL2_msk = (1 << self.RX_SEL2_ofst)
        self.RX_SEL1_msk = (1 << self.RX_SEL1_ofst)
        self.RX3_L_msk = (1 << self.RX3_L_ofst)
        self.RX3_H_msk = (1 << self.RX3_H_ofst)
        self.RX1_2L_msk = (1 << self.RX1_2L_ofst)
        self.RX1_2H_msk = (1 << self.RX1_2H_ofst)
        # self.___(8)
        # self.___(9)
        # self.___(10)
        # self.PAMP_RDY_msk = (1 << self.PAMP_RDY_ofst)
        self.RX1_1H_msk = (1 << self.RX1_1H_ofst)
        self.RX1_1L_msk = (1 << self.RX1_1L_ofst)
        self.RX2_H_msk = (1 << self.RX2_H_ofst)
        self.RX2_L_msk = (1 << self.RX2_L_ofst)

        # Output control signal to FPGA via I2C addr:0x41
        # self.___(0 + self.i2c_U71_ofst)
        # self.___(1 + self.i2c_U71_ofst)
        # self.___(2 + self.i2c_U71_ofst)
        # self.___(3 + self.i2c_U71_ofst)
        # self.___(4 + self.i2c_U71_ofst)
        # self.___(5 + self.i2c_U71_ofst)
        self.DUP_STAT_ofst = (6 + self.i2c_U71_ofst)
        self.QSW_STAT_ofst = (7 + self.i2c_U71_ofst)
        self.PSU_5V_ADC_EN_ofst = (8 + self.i2c_U71_ofst)
        self.PSU_5V_ANA_N_EN_ofst = (9 + self.i2c_U71_ofst)
        self.PSU_5V_ANA_P_EN_ofst = (10 + self.i2c_U71_ofst)
        self.MTCH_NTWRK_RST_ofst = (11 + self.i2c_U71_ofst)
        self.PSU_15V_TX_P_EN_ofst = (12 + self.i2c_U71_ofst)
        self.PSU_15V_TX_N_EN_ofst = (13 + self.i2c_U71_ofst)
        self.PSU_5V_TX_N_EN_ofst = (14 + self.i2c_U71_ofst)
        # self.___(15 + self.i2c_U71_ofst)
        # self.___(0 + 16)
        # self.___(1 + 16)
        # self.___(2 + 16)
        # self.___(3 + 16)
        # self.___(4 + 16)
        # self.___(5 + 16)
        self.DUP_STAT_msk = (1 << self.DUP_STAT_ofst)
        self.QSW_STAT_msk = (1 << self.QSW_STAT_ofst)
        self.PSU_5V_ADC_EN_msk = (1 << self.PSU_5V_ADC_EN_ofst)
        self.PSU_5V_ANA_N_EN_msk = (1 << self.PSU_5V_ANA_N_EN_ofst)
        self.PSU_5V_ANA_P_EN_msk = (1 << self.PSU_5V_ANA_P_EN_ofst)
        self.MTCH_NTWRK_RST_msk = (1 << self.MTCH_NTWRK_RST_ofst)
        self.PSU_15V_TX_P_EN_msk = (1 << self.PSU_15V_TX_P_EN_ofst)
        self.PSU_15V_TX_N_EN_msk = (1 << self.PSU_15V_TX_N_EN_ofst)
        self.PSU_5V_TX_N_EN_msk = (1 << self.PSU_5V_TX_N_EN_ofst)
        # self.___(15 + 16)

        # definition for spi pamp input control
        self.PAMP_IN_SEL1_ofst = (2 + self.spi_pamp_U32)
        self.PAMP_IN_SEL2_ofst = (3 + self.spi_pamp_U32)
        self.PAMP_IN_SEL1_msk = (1 << self.PAMP_IN_SEL1_ofst)
        self.PAMP_IN_SEL2_msk = (1 << self.PAMP_IN_SEL2_ofst)

        # definition for FFT hardware measurement
        self.SAV_ALL_FFT = -1
        self.NO_SAV_FFT = 0

        # General control defaults for the FPGA
        self.gnrl_cnt = 0

        # Numeric conversion of the hardware
        self.pamp_gain_dB = 60  # preamp gain
        self.rx_gain_dB = 20  # rx amp gain
        self.totGain = 10**((self.pamp_gain_dB + self.rx_gain_dB) / 20)
        self.uvoltPerDigit = 3.2 * (10**
                                    6) / 16384  # ADC conversion, in microvolt
        self.fir_gain = 21513  # downconversion FIR filter gain (sum of all coefficients)
        self.dconv_gain = 0.707106781  # downconversion gain factor due to sine(45,135,225,315) multiplication

        # ip addresses settings for the system
        self.server_ip = '192.168.137.5'  # '129.22.143.88'
        self.client_ip = '192.168.137.1'  # '129.22.143.39'
        self.server_path = '/root/NMR_PCBv6_HDLv1_2020_PyDev/MAIN_nmr_code/'
        # client path with samba
        self.client_path = 'W:\\NMR_PCBv6_HDLv1_2020_PyDev\\MAIN_nmr_code\\'
        self.ssh_usr = '******'
        self.ssh_passwd = 'dave'
        # data folder
        self.server_data_folder = "/root/NMR_DATA"
        self.client_data_folder = client_data_folder
        self.exec_folder = "/c_exec/"

        # configuration table to be loaded
        self.S11_table = "genS11Table.txt"  # filename for S11 tables
        self.S21_table = "genS21Table.txt"

        if en_remote_computing:
            self.data_folder = self.client_data_folder
            en_remote_dbg = 0  # force remote debugging to be disabled
        else:
            self.data_folder = self.server_data_folder

        if en_remote_dbg:
            from pydevd_file_utils import setup_client_server_paths
            PATH_TRANSLATION = [(self.client_path, self.server_path)]
            setup_client_server_paths(PATH_TRANSLATION)
            print("---server:%s---client:%s---" %
                  (self.server_ip, self.client_ip))
            pydevd.settrace(self.client_ip,
                            stdoutToServer=True,
                            stderrToServer=True)

        # This variable supports processing on the SoC/server (old method) and show the result on client via remote X window.
        # It also supports processing on the PC/client (new method) and show the result directly on client (much faster).
        # When en_remote_computing is 1, make sure to run the python code on the PC/client side.
        # When en_remote_computing is 0, make sure to run the python code on the SoCFPGA/server side.
        self.en_remote_computing = en_remote_computing

        if not en_remote_computing:
            # directories
            self.work_dir = os.getcwd()
            # only do this after remote debug initialization
            os.chdir(self.data_folder)
        else:
            self.ssh, self.scp = init_ntwrk(self.server_ip, self.ssh_usr,
                                            self.ssh_passwd)
コード例 #23
0
#!/usr/bin/env python
import os, sys, ptvsd, pydevd
from pydevd_file_utils import setup_client_server_paths
from configurations.management import execute_from_command_line  #

# use debug.py to run the development server with remote debugging enabled

if __name__ == "__main__":

    # only attach to ptvsd in the main thread, allows using runserver without --noreload flag
    # https://github.com/Microsoft/PTVS/issues/1057
    if os.environ.get('IDE_REMOTE_DEBUG') == 'vscode':
        if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
            ptvsd.enable_attach(address=('0.0.0.0', 3000),
                                redirect_output=True)

    if os.environ.get('IDE_REMOTE_DEBUG') == 'eclipse':
        if os.environ.get('RUN_MAIN') or os.environ.get('WERKZEUG_RUN_MAIN'):
            MY_PATHS_FROM_ECLIPSE_TO_PYTHON = [
                (os.environ.get('ECLIPSE_LOCAL_PATH'),
                 os.environ.get('ECLIPSE_REMOTE_PATH')),
            ]
            setup_client_server_paths(MY_PATHS_FROM_ECLIPSE_TO_PYTHON)
            pydevd.settrace('host.docker.internal')
    execute_from_command_line(sys.argv)
コード例 #24
0
def test_to_server_and_to_client(tmpdir):
    try:

        def check(obtained, expected):
            assert obtained == expected, '%s (%s) != %s (%s)' % (
                obtained, type(obtained), expected, type(expected))
            assert isinstance(obtained, str)  # bytes on py2, unicode on py3
            assert isinstance(expected, str)  # bytes on py2, unicode on py3

        import pydevd_file_utils
        if IS_WINDOWS:
            # Check with made-up files

            # Client and server are on windows.
            pydevd_file_utils.set_ide_os('WINDOWS')
            for in_eclipse, in_python in ([
                ('c:\\foo', 'c:\\bar'),
                ('c:/foo', 'c:\\bar'),
                ('c:\\foo', 'c:/bar'),
                ('c:\\foo', 'c:\\bar\\'),
                ('c:/foo', 'c:\\bar\\'),
                ('c:\\foo', 'c:/bar/'),
                ('c:\\foo\\', 'c:\\bar'),
                ('c:/foo/', 'c:\\bar'),
                ('c:\\foo\\', 'c:/bar'),
            ]):
                PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
                pydevd_file_utils.setup_client_server_paths(
                    PATHS_FROM_ECLIPSE_TO_PYTHON)
                check(pydevd_file_utils.norm_file_to_server('c:\\foo\\my'),
                      'c:\\bar\\my')
                check(pydevd_file_utils.norm_file_to_server('c:/foo/my'),
                      'c:\\bar\\my')
                check(pydevd_file_utils.norm_file_to_server('c:/foo/my/'),
                      'c:\\bar\\my')
                check(
                    pydevd_file_utils.norm_file_to_server(
                        'c:\\foo\\áéíóú'.upper()), 'c:\\bar\\áéíóú')
                check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'),
                      'c:\\foo\\my')

            # Client on unix and server on windows
            pydevd_file_utils.set_ide_os('UNIX')
            for in_eclipse, in_python in ([
                ('/foo', 'c:\\bar'),
                ('/foo', 'c:/bar'),
                ('/foo', 'c:\\bar\\'),
                ('/foo', 'c:/bar/'),
                ('/foo/', 'c:\\bar'),
                ('/foo/', 'c:\\bar\\'),
            ]):

                PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
                pydevd_file_utils.setup_client_server_paths(
                    PATHS_FROM_ECLIPSE_TO_PYTHON)
                check(pydevd_file_utils.norm_file_to_server('/foo/my'),
                      'c:\\bar\\my')
                check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my'),
                      '/foo/my')
                check(pydevd_file_utils.norm_file_to_client('c:\\bar\\my\\'),
                      '/foo/my')
                check(pydevd_file_utils.norm_file_to_client('c:/bar/my'),
                      '/foo/my')
                check(pydevd_file_utils.norm_file_to_client('c:/bar/my/'),
                      '/foo/my')

            # Test with 'real' files
            # Client and server are on windows.
            pydevd_file_utils.set_ide_os('WINDOWS')

            test_dir = str(tmpdir.mkdir("Foo"))
            os.makedirs(os.path.join(test_dir, "Another"))

            in_eclipse = os.path.join(os.path.dirname(test_dir), 'Bar')
            in_python = test_dir
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)

            assert pydevd_file_utils.norm_file_to_server(
                in_eclipse) == in_python.lower()
            found_in_eclipse = pydevd_file_utils.norm_file_to_client(in_python)
            assert found_in_eclipse.endswith('Bar')

            assert pydevd_file_utils.norm_file_to_server(
                os.path.join(in_eclipse,
                             'another')) == os.path.join(in_python,
                                                         'another').lower()
            found_in_eclipse = pydevd_file_utils.norm_file_to_client(
                os.path.join(in_python, 'another'))
            assert found_in_eclipse.endswith('Bar\\Another')

            # Client on unix and server on windows
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = test_dir
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                '/foo').lower() == in_python.lower()
            assert pydevd_file_utils.norm_file_to_client(
                in_python) == in_eclipse

            # Test without translation in place (still needs to fix case and separators)
            pydevd_file_utils.set_ide_os('WINDOWS')
            PATHS_FROM_ECLIPSE_TO_PYTHON = []
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                test_dir) == test_dir.lower()
            assert pydevd_file_utils.norm_file_to_client(test_dir).endswith(
                '\\Foo')
        else:
            # Client on windows and server on unix
            pydevd_file_utils.set_ide_os('WINDOWS')
            for in_eclipse, in_python in ([
                ('c:\\foo', '/báéíóúr'),
                ('c:/foo', '/báéíóúr'),
                ('c:/foo/', '/báéíóúr'),
                ('c:/foo/', '/báéíóúr/'),
                ('c:\\foo\\', '/báéíóúr/'),
            ]):

                PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]

                pydevd_file_utils.setup_client_server_paths(
                    PATHS_FROM_ECLIPSE_TO_PYTHON)
                assert pydevd_file_utils.norm_file_to_server(
                    'c:\\foo\\my') == '/báéíóúr/my'
                assert pydevd_file_utils.norm_file_to_server(
                    'C:\\foo\\my') == '/báéíóúr/my'
                assert pydevd_file_utils.norm_file_to_server(
                    'C:\\foo\\MY') == '/báéíóúr/MY'
                assert pydevd_file_utils.norm_file_to_server(
                    'C:\\foo\\MY\\') == '/báéíóúr/MY'
                assert pydevd_file_utils.norm_file_to_server(
                    'c:\\foo\\my\\file.py') == '/báéíóúr/my/file.py'
                assert pydevd_file_utils.norm_file_to_server(
                    'c:\\foo\\my\\other\\file.py'
                ) == '/báéíóúr/my/other/file.py'
                assert pydevd_file_utils.norm_file_to_server(
                    'c:/foo/my') == '/báéíóúr/my'
                assert pydevd_file_utils.norm_file_to_server(
                    'c:\\foo\\my\\') == '/báéíóúr/my'
                assert pydevd_file_utils.norm_file_to_server(
                    'c:/foo/my/') == '/báéíóúr/my'

                assert pydevd_file_utils.norm_file_to_client(
                    '/báéíóúr/my') == 'c:\\foo\\my'
                assert pydevd_file_utils.norm_file_to_client(
                    '/báéíóúr/my/') == 'c:\\foo\\my'

                # Files for which there's no translation have only their separators updated.
                assert pydevd_file_utils.norm_file_to_client(
                    '/usr/bin/x.py') == '\\usr\\bin\\x.py'
                assert pydevd_file_utils.norm_file_to_client(
                    '/usr/bin') == '\\usr\\bin'
                assert pydevd_file_utils.norm_file_to_client(
                    '/usr/bin/') == '\\usr\\bin'
                assert pydevd_file_utils.norm_file_to_server(
                    '\\usr\\bin') == '/usr/bin'
                assert pydevd_file_utils.norm_file_to_server(
                    '\\usr\\bin\\') == '/usr/bin'

                # When we have a client file and there'd be no translation, and making it absolute would
                # do something as '$cwd/$file_received' (i.e.: $cwd/c:/another in the case below),
                # warn the user that it's not correct and the path that should be translated instead
                # and don't make it absolute.
                assert pydevd_file_utils.norm_file_to_server(
                    'c:\\another') == 'c:/another'

            # Client and server on unix
            pydevd_file_utils.set_ide_os('UNIX')
            in_eclipse = '/foo'
            in_python = '/báéíóúr'
            PATHS_FROM_ECLIPSE_TO_PYTHON = [(in_eclipse, in_python)]
            pydevd_file_utils.setup_client_server_paths(
                PATHS_FROM_ECLIPSE_TO_PYTHON)
            assert pydevd_file_utils.norm_file_to_server(
                '/foo/my') == '/báéíóúr/my'
            assert pydevd_file_utils.norm_file_to_client(
                '/báéíóúr/my') == '/foo/my'
    finally:
        pydevd_file_utils.setup_client_server_paths([])
コード例 #25
0
import matplotlib.pyplot as plt
from scipy import signal
import pydevd

# variables
data_folder = "/root/NMR_DATA"
en_fig = 1
en_remote_dbg = 0

# remote debug setup
if en_remote_dbg:
    from pydevd_file_utils import setup_client_server_paths
    server_path = '/root/nmr_pcb20_hdl10_2018/MAIN_nmr_code/'
    client_path = 'D:\\GDrive\\WORKSPACES\\Eclipse_Python_2018\\RemoteSystemsTempFiles\\129.22.143.88\\root\\nmr_pcb20_hdl10_2018\\MAIN_nmr_code\\'
    PATH_TRANSLATION = [(client_path, server_path)]
    setup_client_server_paths(PATH_TRANSLATION)
    # pydevd.settrace("dajo-compaqsff")
    pydevd.settrace("129.22.143.39")

# system setup
nmrObj = tunable_nmr_system_2018(data_folder)

nmrObj.initNmrSystem()
# nmrObj.turnOnPower()
# nmrObj.assertControlSignal(nmrObj.PSU_15V_TX_P_EN_msk | nmrObj.PSU_15V_TX_N_EN_msk | nmrObj.PSU_5V_TX_N_EN_msk |
#                           nmrObj.PSU_5V_ADC_EN_msk | nmrObj.PSU_5V_ANA_P_EN_msk | nmrObj.PSU_5V_ANA_N_EN_msk)
#nmrObj.setPreampTuning(-3.35, -1.4)
#nmrObj.setMatchingNetwork(19, 66)
# nmrObj.setSignalPath()
# nmrObj.assertControlSignal(nmrObj.AMP_HP_LT1210_EN_msk |
#                           nmrObj.PAMP_IN_SEL_RX_msk | nmrObj.RX_IN_SEL_1_msk)
コード例 #26
0
    def __init__(self, data_folder, en_remote_dbg):
        self.PCBVer = 'v5.0'  # options are v4.0_and_below, v5.0

        if self.PCBVer == 'v4.0_and_below':
            # Output control signal to FPGA via I2C
            self.PSU_15V_TX_P_EN_ofst = (0)
            self.PSU_15V_TX_N_EN_ofst = (1)
            self.AMP_HP_LT1210_EN_ofst = (2)
            self.PSU_5V_TX_N_EN_ofst = (3)
            self.PAMP_IN_SEL_TEST_ofst = (4)
            self.PAMP_IN_SEL_RX_ofst = (5)
            self.GPIO_GEN_PURP_1_ofst = (6)
            self.PSU_5V_ADC_EN_ofst = (7)
            self.RX_AMP_GAIN_2_ofst = (8)
            self.RX_AMP_GAIN_1_ofst = (9)
            self.RX_AMP_GAIN_4_ofst = (10)
            self.RX_AMP_GAIN_3_ofst = (11)
            self.RX_IN_SEL_1_ofst = (12)
            self.RX_IN_SEL_2_ofst = (13)
            self.PSU_5V_ANA_P_EN_ofst = (14)
            self.PSU_5V_ANA_N_EN_ofst = (15)
            # Output control signal mask to FPGA via I2C
            self.PSU_15V_TX_P_EN_msk = (1 << self.PSU_15V_TX_P_EN_ofst)
            self.PSU_15V_TX_N_EN_msk = (1 << self.PSU_15V_TX_N_EN_ofst)
            self.AMP_HP_LT1210_EN_msk = (1 << self.AMP_HP_LT1210_EN_ofst)
            self.PSU_5V_TX_N_EN_msk = (1 << self.PSU_5V_TX_N_EN_ofst)
            self.PAMP_IN_SEL_TEST_msk = (1 << self.PAMP_IN_SEL_TEST_ofst)
            self.PAMP_IN_SEL_RX_msk = (1 << self.PAMP_IN_SEL_RX_ofst)
            self.GPIO_GEN_PURP_1_msk = (1 << self.GPIO_GEN_PURP_1_ofst)
            self.PSU_5V_ADC_EN_msk = (1 << self.PSU_5V_ADC_EN_ofst)
            self.RX_AMP_GAIN_2_msk = (1 << self.RX_AMP_GAIN_2_ofst)
            self.RX_AMP_GAIN_1_msk = (1 << self.RX_AMP_GAIN_1_ofst)
            self.RX_AMP_GAIN_4_msk = (1 << self.RX_AMP_GAIN_4_ofst)
            self.RX_AMP_GAIN_3_msk = (1 << self.RX_AMP_GAIN_3_ofst)
            self.RX_IN_SEL_1_msk = (1 << self.RX_IN_SEL_1_ofst)
            self.RX_IN_SEL_2_msk = (1 << self.RX_IN_SEL_2_ofst)
            self.PSU_5V_ANA_P_EN_msk = (1 << self.PSU_5V_ANA_P_EN_ofst)
            self.PSU_5V_ANA_N_EN_msk = (1 << self.PSU_5V_ANA_N_EN_ofst)

        elif self.PCBVer == 'v5.0':
            # chip offset declaration (look at the KiCAD for the designated
            # chip name)
            self.i2c_U21_ofst = 0
            self.i2c_U71_ofst = 16
            self.spi_pamp_U32 = 32

            # Output control signal to FPGA via I2C addr:0x40
            self.RX_FL_ofst = (0 + self.i2c_U21_ofst)
            self.RX_FH_ofst = (1 + self.i2c_U21_ofst)
            self.RX_SEL2_ofst = (2 + self.i2c_U21_ofst)
            self.RX_SEL1_ofst = (3 + self.i2c_U21_ofst)
            self.RX3_L_ofst = (4 + self.i2c_U21_ofst)
            self.RX3_H_ofst = (5 + self.i2c_U21_ofst)
            self.RX1_2L_ofst = (6 + self.i2c_U21_ofst)
            self.RX1_2H_ofst = (7 + self.i2c_U21_ofst)
            # self.___(8 + self.i2c_U21_ofst)
            # self.___(9 + self.i2c_U21_ofst)
            # self.___(10 + self.i2c_U21_ofst)
            # self.PAMP_RDY_ofst = (11 + self.i2c_U21_ofst)
            self.RX1_1H_ofst = (12 + self.i2c_U21_ofst)
            self.RX1_1L_ofst = (13 + self.i2c_U21_ofst)
            self.RX2_H_ofst = (14 + self.i2c_U21_ofst)
            self.RX2_L_ofst = (15 + self.i2c_U21_ofst)

            self.RX_FL_msk = (1 << self.RX_FL_ofst)
            self.RX_FH_msk = (1 << self.RX_FH_ofst)
            self.RX_SEL2_msk = (1 << self.RX_SEL2_ofst)
            self.RX_SEL1_msk = (1 << self.RX_SEL1_ofst)
            self.RX3_L_msk = (1 << self.RX3_L_ofst)
            self.RX3_H_msk = (1 << self.RX3_H_ofst)
            self.RX1_2L_msk = (1 << self.RX1_2L_ofst)
            self.RX1_2H_msk = (1 << self.RX1_2H_ofst)
            # self.___(8)
            # self.___(9)
            # self.___(10)
            # self.PAMP_RDY_msk = (1 << self.PAMP_RDY_ofst)
            self.RX1_1H_msk = (0 << self.RX1_1H_ofst)
            self.RX1_1L_msk = (1 << self.RX1_1L_ofst)
            self.RX2_H_msk = (1 << self.RX2_H_ofst)
            self.RX2_L_msk = (1 << self.RX2_L_ofst)

            # Output control signal to FPGA via I2C addr:0x41
            # self.___(0 + self.i2c_U71_ofst)
            # self.___(1 + self.i2c_U71_ofst)
            # self.___(2 + self.i2c_U71_ofst)
            # self.___(3 + self.i2c_U71_ofst)
            # self.___(4 + self.i2c_U71_ofst)
            # self.___(5 + self.i2c_U71_ofst)
            self.DUP_STAT_ofst = (6 + self.i2c_U71_ofst)
            self.QSW_STAT_ofst = (7 + self.i2c_U71_ofst)
            self.PSU_5V_ADC_EN_ofst = (8 + self.i2c_U71_ofst)
            self.PSU_5V_ANA_N_EN_ofst = (9 + self.i2c_U71_ofst)
            self.PSU_5V_ANA_P_EN_ofst = (10 + self.i2c_U71_ofst)
            self.MTCH_NTWRK_RST_ofst = (11 + self.i2c_U71_ofst)
            self.PSU_15V_TX_P_EN_ofst = (12 + self.i2c_U71_ofst)
            self.PSU_15V_TX_N_EN_ofst = (13 + self.i2c_U71_ofst)
            self.PSU_5V_TX_N_EN_ofst = (14 + self.i2c_U71_ofst)
            # self.___(15 + self.i2c_U71_ofst)
            # self.___(0 + 16)
            # self.___(1 + 16)
            # self.___(2 + 16)
            # self.___(3 + 16)
            # self.___(4 + 16)
            # self.___(5 + 16)
            self.DUP_STAT_msk = (1 << self.DUP_STAT_ofst)
            self.QSW_STAT_msk = (1 << self.QSW_STAT_ofst)
            self.PSU_5V_ADC_EN_msk = (1 << self.PSU_5V_ADC_EN_ofst)
            self.PSU_5V_ANA_N_EN_msk = (1 << self.PSU_5V_ANA_N_EN_ofst)
            self.PSU_5V_ANA_P_EN_msk = (1 << self.PSU_5V_ANA_P_EN_ofst)
            self.MTCH_NTWRK_RST_msk = (1 << self.MTCH_NTWRK_RST_ofst)
            self.PSU_15V_TX_P_EN_msk = (1 << self.PSU_15V_TX_P_EN_ofst)
            self.PSU_15V_TX_N_EN_msk = (1 << self.PSU_15V_TX_N_EN_ofst)
            self.PSU_5V_TX_N_EN_msk = (1 << self.PSU_5V_TX_N_EN_ofst)
            # self.___(15 + 16)

            # definition for spi pamp input control
            self.PAMP_IN_SEL1_ofst = (2 + self.spi_pamp_U32)
            self.PAMP_IN_SEL2_ofst = (3 + self.spi_pamp_U32)
            self.PAMP_IN_SEL1_msk = (1 << self.PAMP_IN_SEL1_ofst)
            self.PAMP_IN_SEL2_msk = (1 << self.PAMP_IN_SEL2_ofst)

        # General control defaults for the FPGA
        self.gnrl_cnt = 0

        # Numeric conversion of the hardware
        self.pamp_gain_dB = 60  # preamp gain
        self.rx_gain_dB = 20  # rx amp gain
        self.totGain = 10**((self.pamp_gain_dB + self.rx_gain_dB) / 20)
        self.uvoltPerDigit = 3.2 * (10**
                                    6) / 16384  # ADC conversion, in microvolt
        self.fir_gain = 21513  # downconversion FIR filter gain (sum of all coefficients)
        self.dconv_gain = 0.707106781  # downconversion gain factor due to sine(45,135,225,315) multiplication

        # ip addresses settings for the system
        self.server_ip = '192.168.137.3'  # '129.22.143.88'
        self.client_ip = '192.168.137.14'  # '129.22.143.39'
        self.server_path = '/root/nmr_pcb20_hdl10_2018/MAIN_nmr_code/'
        # client path with samba
        self.client_path = 'V:\\nmr_pcb20_hdl10_2018\\MAIN_nmr_code\\'

        if en_remote_dbg:
            from pydevd_file_utils import setup_client_server_paths
            PATH_TRANSLATION = [(self.client_path, self.server_path)]
            setup_client_server_paths(PATH_TRANSLATION)
            print("---server:%s---client:%s---" %
                  (self.server_ip, self.client_ip))
            pydevd.settrace(self.client_ip,
                            stdoutToServer=True,
                            stderrToServer=True)

        # variables
        self.data_folder = data_folder
        self.exec_folder = "/c_exec/"

        # directories
        self.work_dir = os.getcwd()
        # only do this after remote debug initialization
        os.chdir(self.data_folder)