mirror of
https://github.com/altlinux/gpupdate.git
synced 2025-03-21 10:50:35 +03:00
util.arguments: module to preprocess complex CLI arguments
This commit is contained in:
parent
de16239a8d
commit
990ca53f7c
40
gpoa/util/arguments.py
Normal file
40
gpoa/util/arguments.py
Normal file
@ -0,0 +1,40 @@
|
||||
import logging
|
||||
|
||||
def set_loglevel(loglevel_num=None):
|
||||
'''
|
||||
Set the log level global value.
|
||||
'''
|
||||
loglevels = ['NOTSET', 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'FATAL']
|
||||
log_num = loglevel_num
|
||||
log_level = 10
|
||||
|
||||
# A little bit of defensive programming
|
||||
if not log_num:
|
||||
log_num = 1
|
||||
if 0 > log_num:
|
||||
log_num = 0
|
||||
if 5 < log_num:
|
||||
log_num = 5
|
||||
|
||||
log_level = 10 * log_num
|
||||
|
||||
print('Setting log level to {}'.format(loglevels[log_num]))
|
||||
logging.getLogger().setLevel(log_level)
|
||||
|
||||
def process_target(target_name=None):
|
||||
'''
|
||||
The target may be 'All', 'Computer' or 'User'. This function
|
||||
determines which one was specified.
|
||||
'''
|
||||
target = 'All'
|
||||
|
||||
if 'Computer' == target_name:
|
||||
target = 'Computer'
|
||||
|
||||
if 'User' == target_name:
|
||||
target = 'User'
|
||||
|
||||
logging.debug('Target is: {}'.format(target))
|
||||
|
||||
return target
|
||||
|
Loading…
x
Reference in New Issue
Block a user