2018-12-11 Fred Gleason <fredg@paravelsystems.com>

* Renamed 'apis/PyPAD/examples/pypad_test.py' to
	'apisPyPAD/tests/pad_test.py'.
	* Added a 'hostName' field to the JSON PAD 'padUpdate' object.
	* Added a 'PyPAD.Update::hostName()' method.
	* Added a 'shortHostName' field to the JSON PAD 'padUpdate' object.
	* Added a 'PyPAD.Update::shortHostName()' method.
	* Added a 'PyPAD.Update::resolveFilepath()' method.
	* Added 'apis/PyPAD/tests/filepath_test.py.
	* Added 'api/PyPAD/examples/pypad_filewrite.py'.
This commit is contained in:
Fred Gleason
2018-12-12 13:20:24 -05:00
parent e6b46cca76
commit 0302445c0b
12 changed files with 184 additions and 154 deletions

View File

@@ -23,6 +23,10 @@
rivendelldir = $(pyexecdir)
rivendell_PYTHON = PyPAD.py
##install-exec-am:
## ../../../helpers/install_python.sh PyPAD.py $(pyexecdir)/PyPAD.py
##EXTRA_DIST = PyPAD.py
CLEANFILES = *~\
*.idb\
*ilk\

View File

@@ -1,5 +1,3 @@
#!/usr/bin/python
# PyPAD.py
#
# PAD processor for Rivendell
@@ -129,7 +127,7 @@ class Update(object):
def __replaceWildcard(self,wildcard,sfield,stype,string,esc):
try:
if isinstance(self.__fields['padUpdate'][stype][sfield],unicode):
if isinstance(self.__fields['padUpdate'][stype][sfield],str):
string=string.replace('%'+wildcard,self.escape(self.__fields['padUpdate'][stype][sfield],esc))
else:
string=string.replace('%'+wildcard,str(self.__fields['padUpdate'][stype][sfield]))
@@ -687,18 +685,18 @@ class Receiver(object):
"""
sock=socket.socket(socket.AF_INET)
conn=sock.connect((hostname,port))
c=""
line=""
c=bytes()
line=bytes()
msg=""
while 1<2:
c=sock.recv(1)
line+=c
if c[0]=="\n":
msg+=line
if line=="\r\n":
if c[0]==10:
msg+=line.decode('utf-8')
if line.decode('utf-8')=="\r\n":
self.__PyPAD_Process(Update(json.loads(msg)))
msg=""
line=""
line=bytes()