Compare commits
No commits in common. "cba08629cbfd9427213cb8e1719d2ce1e601bdfc" and "81d8a074cc91ffc9099ec57a4bb31fdd522e740e" have entirely different histories.
cba08629cb
...
81d8a074cc
@ -11,6 +11,7 @@ import configparser
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
class Conf(object):
|
class Conf(object):
|
||||||
confobj = configparser.RawConfigParser()
|
confobj = configparser.RawConfigParser()
|
||||||
cfgfile = ''
|
cfgfile = ''
|
||||||
@ -56,10 +57,7 @@ class Conf(object):
|
|||||||
"""
|
"""
|
||||||
if not self.cfgfile:
|
if not self.cfgfile:
|
||||||
raise Exception('No config file set')
|
raise Exception('No config file set')
|
||||||
try:
|
|
||||||
return self.confobj.get(section, option)
|
return self.confobj.get(section, option)
|
||||||
except configparser.NoOptionError:
|
|
||||||
raise ValueError('Option does not exist')
|
|
||||||
|
|
||||||
def set(self, section, option, value):
|
def set(self, section, option, value):
|
||||||
"""docstring for update"""
|
"""docstring for update"""
|
||||||
|
@ -8,7 +8,7 @@ Created by Marcus Stoegbauer on 2013-01-10.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
from operator import itemgetter
|
|
||||||
|
|
||||||
class Checks(object):
|
class Checks(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -23,7 +23,7 @@ class Checks(object):
|
|||||||
|
|
||||||
# def getShortHostname
|
# def getShortHostname
|
||||||
|
|
||||||
def __classes_for_host__(self, reverse=False):
|
def __classes_for_host__(self):
|
||||||
"""docstring for __classesForHost"""
|
"""docstring for __classesForHost"""
|
||||||
classes = []
|
classes = []
|
||||||
for c in dir(self):
|
for c in dir(self):
|
||||||
@ -32,7 +32,7 @@ class Checks(object):
|
|||||||
ret = getattr(self, c)()
|
ret = getattr(self, c)()
|
||||||
if type(ret) == tuple and len(ret) == 3:
|
if type(ret) == tuple and len(ret) == 3:
|
||||||
classes.append(ret)
|
classes.append(ret)
|
||||||
return map(lambda k: (k[1], k[2]), sorted(classes, key=itemgetter(0), reverse=reverse))
|
return map(lambda k: (k[1], k[2]), sorted(classes, key=lambda k: k[0]))
|
||||||
|
|
||||||
def header(self):
|
def header(self):
|
||||||
"""docstring for header"""
|
"""docstring for header"""
|
||||||
|
10
install.sh
10
install.sh
@ -1,10 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if type pip3 >/dev/null 2>&1; then
|
|
||||||
pip3 install --user git+https://git.lys.is/lysis/pyuserconfig.git
|
|
||||||
git clone git@git.lys.is:lysis/userconfig.git ~/.userconfig
|
|
||||||
mkdir ~/.config
|
|
||||||
PYTHONPATH=~/.local/lib ~/.local/bin/userconfig.py
|
|
||||||
else
|
|
||||||
echo "No pip3 installed, cannot proceed."
|
|
||||||
fi
|
|
@ -14,7 +14,6 @@ import tempfile
|
|||||||
import re
|
import re
|
||||||
import getopt
|
import getopt
|
||||||
import time
|
import time
|
||||||
import subprocess
|
|
||||||
|
|
||||||
#
|
#
|
||||||
import Userconfig.cfgfile as cfgfile
|
import Userconfig.cfgfile as cfgfile
|
||||||
@ -47,6 +46,7 @@ def workconf(directory, depth=2):
|
|||||||
for d in dirs:
|
for d in dirs:
|
||||||
name = directory+"/"+d
|
name = directory+"/"+d
|
||||||
if os.path.isdir(name):
|
if os.path.isdir(name):
|
||||||
|
# fixme: create name if it does not exist
|
||||||
workconf(name, depth+1)
|
workconf(name, depth+1)
|
||||||
if name.endswith(".swp"):
|
if name.endswith(".swp"):
|
||||||
continue
|
continue
|
||||||
@ -81,18 +81,9 @@ def workdir(directory):
|
|||||||
# key is the destination filename, values are all classes filenames that are used to
|
# key is the destination filename, values are all classes filenames that are used to
|
||||||
# build the file
|
# build the file
|
||||||
destfiles = {}
|
destfiles = {}
|
||||||
# FIXME: reverse_order should really be a bool in .cfg, implement variable types in cfg file
|
|
||||||
reverse_sort = False
|
|
||||||
try:
|
|
||||||
reverse_sort = (dir_config.get("Main", "reverse") == 'True')
|
|
||||||
except ValueError:
|
|
||||||
reverse_sort = False
|
|
||||||
|
|
||||||
if os.access(directory + "/install.sh", os.X_OK):
|
|
||||||
subprocess.call([directory + "/install.sh"])
|
|
||||||
|
|
||||||
# walk through all know classes in directory and find filenames
|
# walk through all know classes in directory and find filenames
|
||||||
for h in classchecks.__classes_for_host__(reverse_sort):
|
for h in classchecks.__classes_for_host__():
|
||||||
# build classes directory
|
# build classes directory
|
||||||
if h[0] != "":
|
if h[0] != "":
|
||||||
classdir = directory+"/"+h[0]+"_"+h[1]
|
classdir = directory+"/"+h[0]+"_"+h[1]
|
||||||
@ -166,12 +157,6 @@ def process_all_files(destfiles, dir_config):
|
|||||||
debug.debug(" ================ process_all_files ===============", 1)
|
debug.debug(" ================ process_all_files ===============", 1)
|
||||||
for df in destfiles.keys():
|
for df in destfiles.keys():
|
||||||
debug.debug(" ??? Processing source files for %s." % df, 2)
|
debug.debug(" ??? Processing source files for %s." % df, 2)
|
||||||
if not os.path.exists(os.path.dirname(df)):
|
|
||||||
debug.debug(" +++ Directory %s does not exist, creating" % os.path.dirname(df), 1)
|
|
||||||
os.mkdir(os.path.dirname(df))
|
|
||||||
if not os.path.isdir(os.path.dirname(df)):
|
|
||||||
debug.debug(" --- Destination directory %s does not exist, skipping." % os.path.dirname(df), 1)
|
|
||||||
return False
|
|
||||||
# assemble file to tmp
|
# assemble file to tmp
|
||||||
commentstring = ""
|
commentstring = ""
|
||||||
if dir_config.check("Main", "commentstring"):
|
if dir_config.check("Main", "commentstring"):
|
||||||
@ -200,13 +185,8 @@ def process_all_files(destfiles, dir_config):
|
|||||||
debug.debug(" ================ process_all_files ===============", 1)
|
debug.debug(" ================ process_all_files ===============", 1)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
configfile_destinations = [os.environ['HOME'] + "/etc/",
|
configfile = os.environ['HOME']+"/etc/userconfig.cfg"
|
||||||
os.environ['HOME'] + "/.local/etc"]
|
|
||||||
configfile = ''
|
|
||||||
for directory in configfile_destinations:
|
|
||||||
if os.path.isfile(directory + "/userconfig.cfg"):
|
|
||||||
configfile = directory + "/userconfig.cfg"
|
|
||||||
break
|
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:], "hdc:v", ["help", "debug", "config="])
|
opts, args = getopt.getopt(sys.argv[1:], "hdc:v", ["help", "debug", "config="])
|
||||||
|
Loading…
Reference in New Issue
Block a user