IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 24, 2019, 11:12:13 AM (7 years ago)
Author:
fairlamb
Message:

modified generic utils to throw ValidationErrors, also forgot to commit subprocess changes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-132_automate_jira_conf_backups/utils/python/subprocess_utils.py

    r40885 r40895  
    22
    33# Plans are to flesh this out a bit more to make some smarter copying etc
     4
     5
     6class SubprocessError(Exception):
     7    """Errors in Popen stderr subprocess"""
     8
     9
     10def _args_check(args, function_name):
     11    if args is None:
     12        print("Error: no arguments provided in ", function_name)
     13        return 2
     14    if type(args) != list or len(args) == 0:
     15        print("Error: at least 1 arg must be given for ", function_name)
     16        return 2
     17    return 0
    418
    519
     
    1832
    1933
     34def chmod_wrapper(args: [str]):
     35    if args is None:
     36        return 2
     37    command_and_args = ["chmod"] + args
     38    return simple_unix_wrapper(command_and_args)
     39
     40
    2041def simple_unix_wrapper(command_and_args: [str]):
    21     if command_and_args is None:
    22         print("error: unix wrapper needs some arguments")
    23         return 2
    24     if type(command_and_args) != list or len(command_and_args) == 0:
    25         print("error: unix wrapper requires at least 1 arg")
    26         return 2
     42    """ This should provide the program name and all arguments in a list.
     43
     44Only a single command should be called.
     45    """
     46    arg_check = _args_check(command_and_args, simple_unix_wrapper.__name__)
     47    if arg_check != 0:
     48        return arg_check
    2749
    2850    try:
Note: See TracChangeset for help on using the changeset viewer.