Skip to content

Commit

Permalink
corrections for php 8.x and python3 compliancy
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonb3 committed Oct 8, 2021
1 parent 44af282 commit f46d070
Show file tree
Hide file tree
Showing 411 changed files with 4,369 additions and 4,360 deletions.
28 changes: 14 additions & 14 deletions bubba-backend/AppleVolumes.default
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
# [allowed_hosts:IPv4 address[/IPv4 netmask bits]] \
# [denied_hosts:IPv4 address[/IPv4 netmask bits]] \
# ... more, see below ...
#
#
# name: volume name. it can't include the ':' character
#

#
# variable substitutions:
# you can use variables for both <path> and <name> now. here are the
# rules:
# 1) if you specify an unknown variable, it will not get converted.
# 1) if you specify an unknown variable, it will not get converted.
# 2) if you specify a known variable, but that variable doesn't have
# a value, it will get ignored.
#
# the variables:
# $b -> basename of path
# $c -> client's ip or appletalk address
# $d -> volume pathname on server
# $d -> volume pathname on server
# $f -> full name (whatever's in the gecos field)
# $g -> group
# $h -> hostname
# $i -> client ip without tcp port or appletalk network
# $h -> hostname
# $i -> client ip without tcp port or appletalk network
# $s -> server name (can be the hostname)
# $u -> username (if guest, it's whatever user guest is running as)
# $v -> volume name (either ADEID_NAME or basename of path)
Expand Down Expand Up @@ -122,32 +122,32 @@
# ro -> mount the volume as read-only.
# mswindows -> enforce filename restrictions imposed by MS
# Windows. this will also invoke a default
# codepage (iso8859-1) if one isn't already
# codepage (iso8859-1) if one isn't already
# specified.
# nohex -> don't do :hex translations for anything
# except dot files. specify usedots as well if
# you want that turned off. note: this option
# makes the / character illegal.
# usedots -> don't do :hex translation for dot files. note: when
# usedots -> don't do :hex translation for dot files. note: when
# this option gets set, certain file names
# become illegal. these are .Parent and
# anything that starts with .Apple.
# invisibledots -> don't do :hex translation for dot files. note: when
# invisibledots -> don't do :hex translation for dot files. note: when
# this option gets set, certain file names
# become illegal. these are .Parent and
# anything that starts with .Apple. also, dot
# files created on the unix side are marked invisible.
# files created on the unix side are marked invisible.
# limitsize -> limit disk size reporting to 2GB. this is
# here for older macintoshes using newer
# appleshare clients. yucko.
# nofileid -> don't advertise createfileid, resolveid, deleteid
# nofileid -> don't advertise createfileid, resolveid, deleteid
# calls
# root_preexec_close -> a non-zero return code from root_preexec close the
# root_preexec_close -> a non-zero return code from root_preexec close the
# volume being mounted.
# preexec_close -> a non-zero return code from preexec close the
# preexec_close -> a non-zero return code from preexec close the
# volume being mounted.
# nostat -> don't stat volume path when enumerating volumes list
# upriv -> use unix privilege.
# upriv -> use unix privilege.
# illegalseq -> encode illegal sequence in filename asis,
# ex "\217-", which is not a valid SHIFT-JIS char,
# is encoded as U\217 -
Expand All @@ -158,7 +158,7 @@
# nocnidcache -> Don't store and read CNID to/from AppleDouble file.
# This should not be used as it also prevents a CNID
# database rebuild with `dbd`!
# caseinsensitive -> The underlying FS is case insensitive (only
# caseinsensitive -> The underlying FS is case insensitive (only
# test with JFS in OS2 mode)
# dropbox -> Allows a volume to be declared as being a "dropbox."
# Note that netatalk must be compiled with dropkludge
Expand Down
32 changes: 16 additions & 16 deletions bubba-backend/airprint-generate
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,20 @@ class AirPrintGenerate(object):
self.directory = directory
self.prefix = prefix
self.adminurl = adminurl

if self.user:
cups.setUser(self.user)

def generate(self):
if not self.host:
conn = cups.Connection()
else:
if not self.port:
self.port = 631
conn = cups.Connection(self.host, self.port)

printers = conn.getPrinters()

for p, v in printers.items():
if v['printer-is-shared']:
attrs = conn.getPrinterAttributes(p)
Expand Down Expand Up @@ -148,17 +148,17 @@ class AirPrintGenerate(object):
rp = uri.path
else:
rp = uri[2]

re_match = re.match(r'^//(.*):(\d+)(/.*)', rp)
if re_match:
rp = re_match.group(3)

#Remove leading slashes from path
#TODO XXX FIXME I'm worried this will match broken urlparse
#results as well (for instance if they don't include a port)
#the xml would be malform'd either way
rp = re.sub(r'^/+', '', rp)

path = Element('txt-record')
path.text = 'rp=%s' % (rp)
service.append(path)
Expand Down Expand Up @@ -209,12 +209,12 @@ class AirPrintGenerate(object):
admin = Element('txt-record')
admin.text = 'adminurl=%s' % (v['printer-uri-supported'])
service.append(admin)

fname = '%s%s.service' % (self.prefix, p)

if self.directory:
fname = os.path.join(self.directory, fname)

f = open(fname, 'w')

if etree:
Expand All @@ -226,7 +226,7 @@ class AirPrintGenerate(object):
doc.insertBefore(dt, doc.documentElement)
doc.writexml(f)
f.close()

if self.verbose:
sys.stderr.write('Created: %s%s' % (fname, os.linesep))

Expand All @@ -249,18 +249,18 @@ if __name__ == '__main__':
default='AirPrint-')
parser.add_option('-a', '--admin', action="store_true", dest="adminurl",
help="Include the printer specified uri as the adminurl")

(options, args) = parser.parse_args()

# TODO XXX FIXME -- if cups login required, need to add
# air=username,password
from getpass import getpass
cups.setPasswordCB(getpass)

if options.directory:
if not os.path.exists(options.directory):
os.mkdir(options.directory)

apg = AirPrintGenerate(
user=options.username,
host=options.hostname,
Expand All @@ -270,5 +270,5 @@ if __name__ == '__main__':
prefix=options.prefix,
adminurl=options.adminurl,
)

apg.generate()
2 changes: 1 addition & 1 deletion bubba-backend/bubba-run-backupjobs
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,5 @@ for job, schedules in local_jobs.items():
except MountError as e:
syslog.syslog(syslog.LOG_ERR, "Failed to mount device with {uuid} for {schedule} backup".format(uuid=job, schedule=args.schedule))
finally:
os.rmdir(mountdir)
os.rmdir(mountdir)
write_status(retval, job, args.schedule, selection)
2 changes: 1 addition & 1 deletion bubba-backend/cups-list-printers
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ except:
# we just ignore exceptions
pass

print json.dumps(printers)
print( json.dumps(printers) )
6 changes: 3 additions & 3 deletions bubba-backend/default_web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<title>Loading...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--
<!--
If you want to create your own homepage, remove the meta tag below,
This wont affect the usabillity of the admin interface, only that it wont redirect
This wont affect the usabillity of the admin interface, only that it wont redirect
automatically there
-->
<meta http-equiv="Refresh" content="0; url=/admin">
Expand All @@ -24,7 +24,7 @@
text-decoration : none;
}
</style>

</head>
<body>
<!-- This body is only shown for browsers which doesn't adhere the meta refresh tag -->
Expand Down
4 changes: 2 additions & 2 deletions bubba-backend/dhclient-fallback/fallback
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ if [ "$interface" == "eth1" ] || [ "$interface" == "br0" ]; then

echo "Enter Fallback ($reason)";
FALLBACK_IP="192.168.10.1";
if [ $reason == "PREINIT" ]; then
if [ $reason == "PREINIT" ]; then
if [ -f "/var/run/dnsmasq/dnsmasq.pid" ]; then
echo "Shutting down dnsmasq";
/etc/init.d/dnsmasq stop;
fi
fi

if [ $reason == "TIMEOUT" ] && [ $new_ip_address == $FALLBACK_IP ]; then
echo "DHCP timeout detected. Using fallback ip ($FALLBACK_IP)";
start-stop-daemon --stop --oknodo --name dnsmasq
Expand Down
2 changes: 1 addition & 1 deletion bubba-backend/dhclient-fallback/firewall_rewrite
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ else
# Update firewall config.
echo "Update firewall config"
sed -i "s/PREROUTING -d [0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\/[0-9]*/PREROUTING -d $new_ip_address\/32/" /etc/network/firewall.conf

echo "Activate updated firewall config."
/sbin/iptables-restore /etc/network/firewall.conf

Expand Down
Loading

0 comments on commit f46d070

Please sign in to comment.