Skip to content

Commit

Permalink
python3 fixes, mode fix, create /usr/share/php & fix
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmckechnie committed Jan 14, 2020
1 parent 882005b commit ff9da39
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions bin/user/wxobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from weeutil.weeutil import to_bool
from weewx.cheetahgenerator import SearchList

wxobs_version = "0.7.0"
wxobs_version = "0.7.1"

def logmsg(level, msg):
syslog.syslog(level,'wxobs: %s' % msg)
Expand Down Expand Up @@ -75,14 +75,14 @@ def wxrsync(rsync_user, rsync_server, rsync_options, rsync_loc_file,
rsynccmd = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
stdout = rsynccmd.communicate()[0]
stroutput = stdout.encode("utf-8").strip()
stroutput = stdout.decode("utf-8").strip()
#rsyncpid = rsynccmd.pid
#loginf(" pre.wait rsync pid is %s" % rsyncpid)
#rsynccmd.wait()
#rsyncpid = rsynccmd.pid
#loginf(" post.wait rsync pid is %s" % rsyncpid)
#subprocess.call( ('ps', '-l') )
except OSError, e:
except OSError as e:
#print "EXCEPTION"
if e.errno == errno.ENOENT:
logerr("rsync does not appear to be installed on this system. \
Expand Down Expand Up @@ -484,12 +484,13 @@ def __init__(self, generator):
# phpinfo.php shows include_path as .:/usr/share/php, we'll put it
# in there and hopefully that will work for most users.
# I use/prefer /tmp/wxobs_inc.inc

inc_file = ("wxobs_%s.inc" % id_match)
if self.dest_dir != '':
# create an empty index.html to obscure directory listing
self.zero_html = self.dest_dir+"/index.html"
if not os.path.exists(self.dest_dir):
os.makedirs(self.dest_dir, 0755)
os.makedirs(self.dest_dir, mode=0o0755)
if not os.path.isfile(self.zero_html):
with open(self.zero_html, 'a') as z: # Create file if does not exist
pass # and auto close it
Expand All @@ -515,13 +516,13 @@ def __init__(self, generator):
% (org_location, new_location))
try:
os.symlink(org_location, new_location)
except OSError, e:
except OSError as e:
logerr("error creating database symlink %s" % e)

try:
if not os.access(self.include_file, os.W_OK):
os.makedirs(self.inc_path)
except OSError, e:
except OSError as e:
if e.errno == os.errno.EEXIST:
pass
else:
Expand All @@ -530,9 +531,16 @@ def __init__(self, generator):
# use the skin.conf include_path, either default or the override.
self.inc_path = self.generator.skin_dict['wxobs'].get(
'include_path', '/usr/share/php')
# phpinfo.php include_path is referenced but missing in some cases - php7.3?
# possibly installed with php-pear ?
# FIXME: a quick and harmless fix is to create it.
if not os.path.exists(self.inc_path):
os.makedirs(self.inc_path, mode=0o0755)
loginf("Created %s" % self.inc_path)
self.include_file = ("%s/%s" % (self.inc_path, inc_file))

if self.send_inc and self.dest_dir != '':
#if self.send_inc and self.dest_dir != '':
if self.send_inc:
php_inc = open(self.include_file, 'w')
php_inc.writelines(v_al)
if self.php_zone != '':
Expand Down

0 comments on commit ff9da39

Please sign in to comment.