Re: Error, DVSwitch.ini file not found.. But it's right there?!


sigmazgfx@...
 

interesting thing though. 
I manually invoked python and tried the ConfigParser myself and sure enough it can read it.. 

>>> import configparser
>>> config = configparser.ConfigParser()
>>> config.read("/opt/MMDVM_Bridge/DVSwitch.ini")
['/opt/MMDVM_Bridge/DVSwitch.ini']
>>> for sect in parser.sections():
...    print('Section:', sect)
...    for k,v in parser.items(sect):
...       print(' {} = {}'.format(k,v))
...    print()
...
Section: QUANTAR
 logfilepath = /var/log/Quantar_Bridge.log
 address = 127.0.0.1             ; Address to send AMBE TLV frames to (export)
 txport = 34103                  ; Port to send AMBE TLV frames to (export)
 rxport = 34100                  ; Port to listen on (import)
 quantarport = 1994              ; HDLC frames To/From the Quantar repeater
 loglevel = 2                    ; Show messages and above 0=No logging, 1=Debug, 2=Message, 3=Info, 4=Warning, 5=Error, 6=Fatal
 debug = 0                       ; Debug 0 = off, 1 = on (adds lots of additional messages)
 
Section: DMR
 address = 127.0.0.1             ; Address to send AMBE TLV frames to (export)
 txport = 31100                  ; Port to send AMBE TLV frames to (export)
 rxport = 31103                  ; Port to listen on (import)
 slot = 2                        ; Export slot
 
Section: DSTAR
 address = 127.0.0.1             ; Address to send AMBE TLV frames to (export)
 txport = 32100                  ; Port to send AMBE TLV frames to (export)
 rxport = 32103                  ; Port to listen on (import)
 fallbackid = 1234567            ; In case we can not find a valid DMR id in the database, export this one
 exporttg = 9                    ; Which TG to export
 slot = 2                        ; Export slot
 
Section: NXDN
 address = 127.0.0.1             ; Address to send AMBE TLV frames to (export)
 txport = 33100                  ; Port to send AMBE TLV frames to (export)
 rxport = 33103                  ; Port to listen on (import)
 fallbackid = 1234567            ; In case we can not find a valid DMR id in the database, export this one
 nxdnfallbackid = 12345         ; Use this ID when the input DMR ID is not found in the database
 translate = 1234=4321           ; Translate NXDN TG < -- > DMR TG (bidirectional)
 slot = 2                        ; Export slot
 
Section: P25
 address = 127.0.0.1             ; Address to send AMBE TLV frames to (export)
 txport = 34100                  ; Port to send AMBE TLV frames to (export)
 rxport = 34103                  ; Port to listen on (import)
 slot = 2                        ; Export slot
 
Section: YSF
 address = 127.0.0.1             ; Address to send AMBE TLV frames to (export)
 txport = 35100                  ; Port to send AMBE TLV frames to (export)
 rxport = 35103                  ; Port to listen on (import)
 fallbackid = 1234567            ; In case we can not find a valid DMR id in the database, export this one
 exporttg = 1234                 ; Which TG to export
 slot = 2                        ; Export slot
 
I came to realize that the parser section defines the import as ConfigParser and config = ConfigParser.ConfigParser when I tried that manually Python would get quite angry and complain that there is no module named "ConfigParser".
Also realizing that the unable to read DVSwitch.ini error message is just the default fail out message..

Changed the parseINIFile() function to reflect the name of the module it was happy with:

function parseIniFile() {
python - <<END
#!/usr/bin/env python
try:
    import sys, configparser
    config = configparser.ConfigParser()
    config.read("$1")
    print( config.get('$2', '$3') )
except:
    exit(1)
END
}

So with these changes I get this output now.. which is promising because it is reading and parsing... albeit still with an error further down the line, 
-----
parseIniFile "$DVSWITCH_INI" "$_MODE" "TXPort"
++ parseIniFile /opt/MMDVM_Bridge/DVSwitch.ini DSTAR TXPort
++ python -
+ _MBTX='32100                  ; Port to send AMBE TLV frames to (export)'
parseIniFile "$DVSWITCH_INI" "$_MODE" "RXPort"
++ parseIniFile /opt/MMDVM_Bridge/DVSwitch.ini DSTAR RXPort
++ python -
+ _MBRX='32103                  ; Port to listen on (import)'
+ '[' '!' -z 32100 ';' Port to send AMBE TLV frames to '(export)' ']'
./dvswitch.sh: line 812: [: too many arguments
+ echo 'Error, DVSwitch.ini file not found'
Error, DVSwitch.ini file not found
 

Join main@DVSwitch.groups.io to automatically receive all group messages.