From 3e83b2f19f913dfa86cccc76fe4f91d9cf52380e Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 27 Jun 2017 12:11:16 +0200 Subject: standardskriver: Use a generic file location for getting the site name/id from. --- standardskriver | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'standardskriver') diff --git a/standardskriver b/standardskriver index 6ce0fe9..d56f882 100755 --- a/standardskriver +++ b/standardskriver @@ -24,7 +24,7 @@ # Name=standardskriver # StartupNotify=false -CUSTOMER_ID_FILE = '/etc/debian-edu/itzks.school' +SITE_ID_FILE = '/etc/standardskriver.site' CFG_FILE = '/etc/standardskriver.cfg' CFG_FILE_EXAMPLE = '''[settings] enable = yes @@ -63,14 +63,14 @@ import netaddr from optparse import OptionParser import ConfigParser -# check whose customer system we are on... -customer_id = None -if os.access(CUSTOMER_ID_FILE, os.R_OK): - with open(CUSTOMER_ID_FILE, 'r') as c_id_f: +# if configured, check on what site location we are currently running... +site_id = None +if os.access(SITE_ID_FILE, os.R_OK): + with open(SITE_ID_FILE, 'r') as c_id_f: # only read first line - customer_id = c_id_f.readline() + site_id = c_id_f.readline() # sanitize input... - customer_id = re.sub(r'([A-Z0-9]+)(.*\n)', r'\1', customer_id) + site_id = re.sub(r'([A-Z0-9]+)(.*\n)', r'\1', site_id) macaddrs = [open(a).read().replace(':', '').strip().lower() for a in glob('/sys/class/net/*/address')] macaddrs = [a for a in macaddrs if a] @@ -129,8 +129,8 @@ p.wait() def get_group_match(): group_sections = ['groups'] - if customer_id: - group_sections.append('groups.{customer}'.format(customer=customer_id)) + if site_id: + group_sections.append('groups.{site}'.format(site=site_id)) for section in group_sections: try: for group, printer in cfg.items(section): @@ -141,8 +141,8 @@ def get_group_match(): def get_machine_match(): machine_sections = ['machine'] - if customer_id: - machine_sections.append('machine.{customer}'.format(customer=customer_id)) + if site_id: + machine_sections.append('machine.{site}'.format(site=site_id)) for section in machine_sections: try: for machine, printer in cfg.items(section): -- cgit v1.2.3