From 8c9c02c975f07bb832a0891178b2113c6879d483 Mon Sep 17 00:00:00 2001 From: Julen Landa Alustiza Date: Wed, 7 Feb 2024 12:26:42 +0100 Subject: awxkit: allow to modify api base url (#14835) Signed-off-by: Julen Landa Alustiza --- tools/scripts/compilemessages.py | 29 +++++++++++++++-------------- tools/scripts/firehose.py | 2 +- tools/scripts/list_fields.py | 6 +----- 3 files changed, 17 insertions(+), 20 deletions(-) (limited to 'tools/scripts') diff --git a/tools/scripts/compilemessages.py b/tools/scripts/compilemessages.py index 62dfadfbfc..5554c8c948 100644 --- a/tools/scripts/compilemessages.py +++ b/tools/scripts/compilemessages.py @@ -40,13 +40,12 @@ def popen_wrapper(args, os_err_exc_type=Exception, stdout_encoding='utf-8'): p = Popen(args, shell=False, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt') except OSError as e: strerror = force_text(e.strerror, DEFAULT_LOCALE_ENCODING, strings_only=True) - raise Exception(os_err_exc_type, os_err_exc_type('Error executing %s: %s' % - (args[0], strerror)), sys.exc_info()[2]) + raise Exception(os_err_exc_type, os_err_exc_type('Error executing %s: %s' % (args[0], strerror)), sys.exc_info()[2]) output, errors = p.communicate() return ( force_text(output, stdout_encoding, strings_only=True, errors='strict'), force_text(errors, DEFAULT_LOCALE_ENCODING, strings_only=True, errors='replace'), - p.returncode + p.returncode, ) @@ -65,7 +64,13 @@ def get_system_encoding(): _PROTECTED_TYPES = ( - type(None), int, float, Decimal, datetime.datetime, datetime.date, datetime.time, + type(None), + int, + float, + Decimal, + datetime.datetime, + datetime.date, + datetime.time, ) @@ -111,8 +116,7 @@ def force_text(s, encoding='utf-8', strings_only=False, errors='strict'): # working unicode method. Try to handle this without raising a # further exception by individually forcing the exception args # to unicode. - s = ' '.join(force_text(arg, encoding, strings_only, errors) - for arg in s) + s = ' '.join(force_text(arg, encoding, strings_only, errors) for arg in s) return s @@ -140,17 +144,14 @@ if __name__ == "__main__": print('processing file %s in %s\n' % (f, dirpath)) po_path = os.path.join(dirpath, f) if has_bom(po_path): - raise Exception("The %s file has a BOM (Byte Order Mark). " - "Django only supports .po files encoded in " - "UTF-8 and without any BOM." % po_path) + raise Exception( + "The %s file has a BOM (Byte Order Mark). " "Django only supports .po files encoded in " "UTF-8 and without any BOM." % po_path + ) base_path = os.path.splitext(po_path)[0] # Check writability on first location if i == 0 and not is_writable((base_path + '.mo')): - raise Exception("The po files under %s are in a seemingly not writable location. " - "mo files will not be updated/created." % dirpath) - args = [program] + program_options + [ - '-o', (base_path + '.mo'), (base_path + '.po') - ] + raise Exception("The po files under %s are in a seemingly not writable location. " "mo files will not be updated/created." % dirpath) + args = [program] + program_options + ['-o', (base_path + '.mo'), (base_path + '.po')] output, errors, status = popen_wrapper(args) if status: if errors: diff --git a/tools/scripts/firehose.py b/tools/scripts/firehose.py index d11edd47eb..4755cdf463 100755 --- a/tools/scripts/firehose.py +++ b/tools/scripts/firehose.py @@ -66,7 +66,7 @@ class YieldedRows(StringIO): def __init__(self, job_id, rows, created_stamp, modified_stamp, *args, **kwargs): self.rows = rows self.rowlist = [] - for (event, module) in itertools.product(EVENT_OPTIONS, MODULE_OPTIONS): + for event, module in itertools.product(EVENT_OPTIONS, MODULE_OPTIONS): event_data_json = {"task_action": module, "name": "Do a {} thing".format(module), "task": "Do a {} thing".format(module)} row = ( "\t".join( diff --git a/tools/scripts/list_fields.py b/tools/scripts/list_fields.py index 1e637e9c1b..e153a7394d 100755 --- a/tools/scripts/list_fields.py +++ b/tools/scripts/list_fields.py @@ -6,15 +6,11 @@ def _get_class_full_name(cls_): class _ModelFieldRow(object): - def __init__(self, field): self.field = field self.name = field.name self.type_ = _get_class_full_name(type(field)) - if self.field.many_to_many\ - or self.field.many_to_one\ - or self.field.one_to_many\ - or self.field.one_to_one: + if self.field.many_to_many or self.field.many_to_one or self.field.one_to_many or self.field.one_to_one: self.related_model = _get_class_full_name(self.field.remote_field.model) else: self.related_model = 'N/A' -- cgit v1.2.3