moved logging config and fixed typos
This commit is contained in:
parent
4e11f462f7
commit
d0021f9536
14
clean.py
14
clean.py
|
@ -27,9 +27,9 @@ import configparser
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Parse all arguments
|
# Parse all arguments
|
||||||
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
parser = argparse.ArgumentParser(description="Clean Alkira tenant config with AlkirAPI")
|
||||||
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf")
|
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf)")
|
||||||
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0")
|
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0)")
|
||||||
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -50,6 +50,10 @@ except KeyError:
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
|
# Set logging.INFO to logging.DEBUG for debug information
|
||||||
|
logging.basicConfig(level=loglevel)
|
||||||
|
logging = logging.getLogger('AlkiraAPI')
|
||||||
|
|
||||||
# Tenant config
|
# Tenant config
|
||||||
if not os.path.isfile(ALKIRA_CONFIG):
|
if not os.path.isfile(ALKIRA_CONFIG):
|
||||||
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
||||||
|
@ -62,10 +66,6 @@ ALKIRA_USERNAME = alkira.get('alkira', 'ALKIRA_USERNAME')
|
||||||
ALKIRA_PASSWORD = alkira.get('alkira', 'ALKIRA_PASSWORD')
|
ALKIRA_PASSWORD = alkira.get('alkira', 'ALKIRA_PASSWORD')
|
||||||
ALKIRA_BASE_URI = f'https://{ALKIRA_TENANT}/api'
|
ALKIRA_BASE_URI = f'https://{ALKIRA_TENANT}/api'
|
||||||
|
|
||||||
# Set logging.INFO to logging.DEBUG for debug information
|
|
||||||
logging.basicConfig(level=loglevel)
|
|
||||||
logging = logging.getLogger('AlkiraAPI')
|
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
# Set default headers
|
# Set default headers
|
||||||
|
|
14
get.py
14
get.py
|
@ -27,9 +27,9 @@ import configparser
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Parse all arguments
|
# Parse all arguments
|
||||||
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
parser = argparse.ArgumentParser(description="Get JSON config to AlkirAPI")
|
||||||
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf")
|
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf)")
|
||||||
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0")
|
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -48,6 +48,10 @@ except KeyError:
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
|
# Set logging.INFO to logging.DEBUG for debug information
|
||||||
|
logging.basicConfig(level=loglevel)
|
||||||
|
logging = logging.getLogger('AlkiraAPI')
|
||||||
|
|
||||||
# Tenant config
|
# Tenant config
|
||||||
if not os.path.isfile(ALKIRA_CONFIG):
|
if not os.path.isfile(ALKIRA_CONFIG):
|
||||||
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
||||||
|
@ -60,10 +64,6 @@ ALKIRA_USERNAME = alkira.get('alkira', 'ALKIRA_USERNAME')
|
||||||
ALKIRA_PASSWORD = alkira.get('alkira', 'ALKIRA_PASSWORD')
|
ALKIRA_PASSWORD = alkira.get('alkira', 'ALKIRA_PASSWORD')
|
||||||
ALKIRA_BASE_URI = f'https://{ALKIRA_TENANT}/api'
|
ALKIRA_BASE_URI = f'https://{ALKIRA_TENANT}/api'
|
||||||
|
|
||||||
# Set logging.INFO to logging.DEBUG for debug information
|
|
||||||
logging.basicConfig(level=loglevel)
|
|
||||||
logging = logging.getLogger('AlkiraAPI')
|
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
# Set default headers
|
# Set default headers
|
||||||
|
|
|
@ -27,10 +27,12 @@ import configparser
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Parse all arguments
|
# Parse all arguments
|
||||||
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
parser = argparse.ArgumentParser(description="Push JSON config to AlkirAPI (debug)")
|
||||||
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf")
|
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnfi)")
|
||||||
parser.add_argument("-f", "--file", type=str, help="location of the JSON connector file")
|
parser.add_argument("-f", "--file", type=str, help="location of the JSON connector file")
|
||||||
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
||||||
|
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0)")
|
||||||
|
|
||||||
if len(sys.argv)==1:
|
if len(sys.argv)==1:
|
||||||
parser.print_help(sys.stderr)
|
parser.print_help(sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -44,8 +46,20 @@ except argparse.ArgumentError as e:
|
||||||
print(str(e))
|
print(str(e))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
try:
|
||||||
|
loglevel = {
|
||||||
|
0: logging.INFO,
|
||||||
|
1: logging.DEBUG
|
||||||
|
}[args.verbose]
|
||||||
|
except KeyError:
|
||||||
|
loglevel = logging.INFO
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
|
# Set loglevel (logging.INFO, logging.DEBUG)
|
||||||
|
logging.basicConfig(level=loglevel)
|
||||||
|
logging = logging.getLogger('AlkiraAPI')
|
||||||
|
|
||||||
# Tenant config
|
# Tenant config
|
||||||
if not os.path.isfile(ALKIRA_CONFIG):
|
if not os.path.isfile(ALKIRA_CONFIG):
|
||||||
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
||||||
|
|
18
push.py
18
push.py
|
@ -27,11 +27,11 @@ import configparser
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Parse all arguments
|
# Parse all arguments
|
||||||
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
parser = argparse.ArgumentParser(description="Push JSON config to AlkirAPI")
|
||||||
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf")
|
parser.add_argument("-t", "--tenant", type=str, default='alkira.cnf', help="location of alikira.cnf (default: alkira.cnf)")
|
||||||
parser.add_argument("-f", "--folder", type=str, default='config', help="location of the JSON connector files (default: config")
|
parser.add_argument("-f", "--folder", type=str, default='config', help="location of the JSON connector files (default: config)")
|
||||||
parser.add_argument("-c", "--config", type=str, default='connectors.cnf', help="location of the connector config (default: config/connectors.cnf")
|
parser.add_argument("-c", "--config", type=str, default='connectors.cnf', help="location of the connector config (default: config/connectors.cnf)")
|
||||||
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0")
|
parser.add_argument("-v", "--verbose", type=int, default=0, help="Verbose level 0 or 1 (default: 0)")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
@ -53,6 +53,10 @@ except KeyError:
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
|
# Set loglevel (logging.INFO, logging.DEBUG)
|
||||||
|
logging.basicConfig(level=loglevel)
|
||||||
|
logging = logging.getLogger('AlkiraAPI')
|
||||||
|
|
||||||
# Tenant config
|
# Tenant config
|
||||||
if not os.path.isfile(ALKIRA_CONFIG):
|
if not os.path.isfile(ALKIRA_CONFIG):
|
||||||
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
logging.error(f"The config file {ALKIRA_CONFIG} doesn't exist")
|
||||||
|
@ -71,10 +75,6 @@ if not os.path.isfile(CONNECTOR_CONFIG):
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(CONNECTOR_CONFIG)
|
config.read(CONNECTOR_CONFIG)
|
||||||
|
|
||||||
# Set loglevel (logging.INFO, logging.DEBUG)
|
|
||||||
logging.basicConfig(level=loglevel)
|
|
||||||
logging = logging.getLogger('AlkiraAPI')
|
|
||||||
|
|
||||||
###############################################
|
###############################################
|
||||||
|
|
||||||
# Set default headers
|
# Set default headers
|
||||||
|
|
|
@ -21,7 +21,7 @@ import json
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Parse all arguments
|
# Parse all arguments
|
||||||
parser = argparse.ArgumentParser(description="Push JSON connfig to AlkirAPI")
|
parser = argparse.ArgumentParser(description="Validate JSON config")
|
||||||
parser.add_argument("-f", "--file", type=str, help="location of the JSON connector file")
|
parser.add_argument("-f", "--file", type=str, help="location of the JSON connector file")
|
||||||
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
parser.add_argument("-p", "--pretty", help="make the JSON pretty!", action="store_true")
|
||||||
if len(sys.argv)==1:
|
if len(sys.argv)==1:
|
||||||
|
|
Loading…
Reference in New Issue