Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed pypad_nautel.py so it will run without errors. #672

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -20770,3 +20770,5 @@
the Rivendell services are not running.
2021-06-06 Fred Gleason <fredg@paravelsystems.com>
* Incremented the package version to 3.6.1.
2021-06-07 Jake Tremper <jaketremper@usicllc.com>
* Fixed pypad_nautel.py so it will run without errors.
25 changes: 9 additions & 16 deletions apis/pypad/scripts/pypad_nautel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import sys
import socket
Expand All @@ -30,14 +29,6 @@
def eprint(*args,**kwargs):
print(*args,file=sys.stderr,**kwargs)


def sendvar(var):
if(len(var)!=0):
send_sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
send_sock.connect((ipaddr,port))
send_sock.sendall(var.encode('utf-8'))
send_sock.close()

def getval(val, update, section):
try:
configval = update.config().get(section,val)
Expand All @@ -47,7 +38,7 @@ def getval(val, update, section):

def encode(srcdata, fieldname, update):
if(len(srcdata)!=0):
enc=fieldname+'='+update.resolvePadFields(srcdata,pypad.ESCAPE_NONE)+'\r\n'
enc=fieldname+'='+update.resolvePadFields(srcdata,pypad.ESCAPE_NONE).ljust(64)+'\r\n'
else:
enc=''
return enc
Expand All @@ -60,7 +51,6 @@ def ProcessPad(update):
section='Rds'+str(n)
while(update.config().has_section(section)):
if update.shouldBeProcessed(section) and update.hasPadType(pypad.TYPE_NOW):
dps=''
dps=getval_encode('DynamicPS',"DPS",update,section)
ps=getval_encode('ProgramService',"PS",update,section)
text=getval_encode('RadioText',"TEXT",update,section)
Expand Down Expand Up @@ -104,18 +94,22 @@ def ProcessPad(update):
dpsm=getval_encode('DPSMode',"DPSM",update,section)


def sendvar(var):
if(len(var)!=0):
ipaddr=update.config().get(section,'IpAddress')
port=int(update.config().get(section,'TcpPort'))
send_sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
send_sock.connect((ipaddr, port))
send_sock.sendall(var.encode('utf-8'))
send_sock.close

#
# Use TCP output
#
waittime=int(update.config().get(section,'Delay'))
time.sleep(waittime)
ipaddr=update.config().get(section,'IpAddress')
port=int(update.config().get(section,'TcpPort'))
sendvar(dps)
sendvar(ps)
sendvar(text)

sendvar(picode)
sendvar(pty)
sendvar(ptyn)
Expand Down Expand Up @@ -155,7 +149,6 @@ def ProcessPad(update):
sendvar(dpsr)
sendvar(dpsm)


n=n+1
section='Rds'+str(n)

Expand Down